Browse
Coding

Explain this code like I'll have to maintain it

Paste a function or file you didn't write and get a plain explanation of what it does, why it's built that way, and where it's likely to break.

No votes yet this week
Output
Text
Written with
Claude Fable 5.1
Added

The prompt

I've inherited this code and I'll be the one maintaining it. Explain it to me properly.

Language and framework, if it matters: [e.g. Python 3.12, no framework]
What I already know about it: [e.g. it runs nightly and sends invoices, that's all I know]

```
[PASTE THE CODE]
```

Take it in this order:
1. What does it do, in two or three sentences? Speak to a developer who's never seen it.
2. Walk through it top to bottom. For each part, say what it does and, where you can tell, why it was done that way.
3. Anything surprising: hidden side effects, global state, things it assumes about its input, error handling that swallows problems.
4. Where is it most likely to break, and how would I notice?
5. If you had one hour to make it safer without changing what it does, what would you do first?

Don't rewrite it unless I ask. And if you're guessing at the intent behind something, say "I'm guessing" rather than stating it as fact.
  • code-reading
  • legacy
  • documentation

What it generates

Example

NoteThis is an example. Results change between runs and model versions. Claude Prompts is a fan project and is not affiliated with Anthropic.

Getting the most from this prompt

When you'd reach for it

Any time code lands on your desk without its author: a colleague left, a contractor's project came back, an old script started failing. It's also useful before a code review of something outside your usual area.

Give it context

The "what I already know" line is worth filling in even when the answer is "almost nothing", because it sets the level of the explanation. Paste one function or one file at a time. A whole module produces an explanation nobody reads.

Why no rewrite

The prompt asks Claude not to rewrite the code, and that's deliberate. A rewrite of code you don't understand yet is how bugs get a second life. Understand it first, then decide what to change. Pay attention to the "I'm guessing" markers in the answer. Those are the places to check with someone who was around when the code was written.

How to use this prompt

  1. [01] Copy

    Copy the prompt

    Use the copy button above. The full text is included, nothing is cut off.

  2. [02] Fill in

    Replace the yellow parts

    Everything highlighted in yellow is a placeholder. Swap it for your own topic, audience or data.

  3. [03] Vote

    Run it in Claude and vote

    If the result helped, press the heart. Votes decide which prompts make the weekly top 10.

More like this

All coding prompts
Text output

In one paragraph. This is a bookings app for small gyms. A React front end talks to an Express API in /server. Data lives in Postgres and is accessed through Prisma. Anything slow (emails, PDF invoices) goes through a job...

First day codebase tour

Paste a file tree and a few key files and get the tour a senior engineer would give you: how a request flows, where things live, what to avoid.

Text output

What the error means. Cannot read properties of undefined (reading 'map') means orders was undefined at the moment the component rendered. The array never arrived, or it arrived under a different name. Most likely causes 1...

Find the bug before you fix it

Stops Claude from patching symptoms. It ranks the likely causes, tells you what to check first, and only then writes the fix.

Learn the technique

All articles