Explain unfamiliar code
A walkthrough pitched at your actual level, with the non-obvious decisions called out. Written for Claude, free to copy, with every placeholder explained below.
The prompt
<role>
You explain code to someone competent who has not seen this codebase.
</role>
<context>
My level: {{experience_level}}
What I already know: {{known}}
Why I am reading this: {{goal}}
</context>
<code>
{{code}}
</code>
<task>
Explain what this code does and why it is written this way.
</task>
<constraints>
- Define every term and pattern the first time it appears, at my stated level.
- Explain the non-obvious decisions, not the self-evident lines. Skip anything a
competent reader gets from the syntax alone.
- Call out anything that looks like a workaround, and say what it is working around.
- If any part is genuinely unclear or looks wrong, say so rather than rationalising it.
- Do not restate the code line by line.
</constraints>
<output_format>
1. What it does, in two sentences.
2. How it works, following the actual execution path.
3. Decisions worth knowing about, and why they were probably made.
4. Anything that looks suspicious.
</output_format>
Now explain the code above.Open this in the prompt builder to adapt it, score it, and re-render it for a different model.
What to replace
| Placeholder | What to put there |
|---|---|
| {{experience_level}} | Your level in this language, honestly. |
| {{known}} | Concepts you do not need explained. |
| {{goal}} | Why you are reading it — modify, debug, review. |
| {{code}} | The code to explain. |
Why this prompt works
- Level and prior knowledge stated
- Without both, explanations default to either condescending or over-assuming. Naming what you know is as useful as naming what you do not.
- Line-by-line explicitly banned
- Restating syntax is the default failure mode and carries almost no information.
- Permission to say it looks wrong
- Models rationalise existing code as intentional. Explicit permission surfaces genuine bugs.
More prompts
- Code review for correctness only — Findings with a triggering input, ranked by severity — and permission to find nothing.
- Debug from an error and stack trace — Ranked hypotheses with a test for each, instead of one confident guess.
- Unit tests written from the spec — Tests derived from requirements rather than from the implementation, so they can fail.
- SQL query from a plain-English question — A query with its assumptions stated, so you can check them before running it.
- Blog post from an outline — Turn a rough outline into a full draft that keeps your structure and does not pad.
- Rewrite for clarity without changing meaning — Tighten prose while keeping the author's voice and every factual claim intact.
Browse the full prompt library, all coding & development prompts, or read the guides.