Explain unfamiliar code
Get an explanation pitched at the right level, that says what the code does rather than narrating it line by line.
When to use it
Landing in an unfamiliar codebase where you can read the syntax perfectly well and still have no idea why the code is shaped that way.
What it prevents
Line-by-line narration. The default explanation tells you what each line does, which you can already see. Asking why the unusual parts are unusual is what surfaces the intent.
The prompt
Explain what the code below does and why it is written this way. ### Context I am a competent developer but new to this codebase. I can read the syntax; what I lack is the intent. ### Requirements - Lead with the purpose in one sentence, before any detail. - Explain why the unusual parts are unusual — what would break with the obvious approach. - Output format: Two short paragraphs, then a bulleted list of any gotchas. - Avoid: narrating the code line by line, and explaining language syntax. ### Code """ const seen = new WeakMap(); export const memo = (fn) => (arg) => seen.has(arg) ? seen.get(arg) : (seen.set(arg, fn(arg)), seen.get(arg)); """
Instant checks
States a concrete task
PassedAvoids vague language
PassedSpecifies an output format
PassedGives context or audience
PassedAvoids dangling references
PassedAvoids over-aggressive phrasing
PassedDefines what a good answer looks like
Passed
Why each part is there
Every section of that prompt exists because a specific failure happens without it. These are the checks it passes, and what each one is protecting you from:
- States a concrete task — why this matters
- Avoids vague language — why this matters
- Specifies an output format — why this matters
- Gives context or audience — why this matters
- Avoids dangling references — why this matters
- Avoids over-aggressive phrasing — why this matters
- Defines what a good answer looks like — why this matters
How to adapt this one
Paste your own snippet and keep the two framing lines: “I can read the syntax, I lack the intent” and “explain why the unusual parts are unusual”. Those aim the model at the gap you actually have. Drop the level to “explain the syntax too” only if you genuinely are new to the language — otherwise you get the tutorial you did not need.
The mistake this prompt avoids
Accepting a line-by-line narration. The default explanation restates what each line does, which you could already see — it feels like an answer while telling you nothing new. The useful question is always “why is this shaped this way, and what would break with the obvious approach”. Intent, not translation.
A variation
Trying to understand a whole module rather than a function? Ask for the data flow first — “what goes in, what comes out, what state is touched on the way” — before any explanation of the parts. A map of the boundaries makes the internals legible; starting with the internals just gives you a longer version of the code you already have.
Check your version
Once you have adapted it, run it through the checker. The same nine checks that graded this page will grade yours, free and in your browser — paste it in, or build one from scratch by answering a few questions.