Explain Code
Explain Unfamiliar Code Line by Line
Understand inherited code fast: what it does, why, its dependencies and where it breaks.
The Prompt
explain-unfamiliar-code.md
Act as a patient senior developer onboarding me onto unfamiliar code. My experience level: {{level}} Code: ``` {{code}} ``` Explain in this order: 1. One-paragraph summary of what this code does and where it likely sits in the system 2. Walkthrough of the important blocks in execution order, in plain language 3. Inputs, outputs and side effects (network, filesystem, state, globals) 4. Assumptions the code makes that could break 5. Vocabulary or patterns used here that I should learn, with a one-line definition each 6. Three questions I should ask the original author Do not paraphrase every line. Focus on intent and risk, not syntax.
Negative prompt
Included when you copy the prompt
Do not paraphrase every line or recite syntax the reader already knows. Do not dump jargon without a one-line definition. Do not invent surrounding architecture that is not implied by the snippet. Do not turn the explanation into a full rewrite or unsolicited refactor plan. Do not skip risks, side effects, or assumptions. Do not talk down to the stated experience level or oversimplify past usefulness.
Fill in your details below - this prompt updates as you type, then copy it.
Fill in your details
0 of 2 filled. Preview updates as you type - then copy the finished prompt (negative prompt included when present).
explain-unfamiliar-code.md
Prompt preview
Act as a patient senior developer onboarding me onto unfamiliar code. My experience level: {{level}} Code: ``` {{code}} ``` Explain in this order: 1. One-paragraph summary of what this code does and where it likely sits in the system 2. Walkthrough of the important blocks in execution order, in plain language 3. Inputs, outputs and side effects (network, filesystem, state, globals) 4. Assumptions the code makes that could break 5. Vocabulary or patterns used here that I should learn, with a one-line definition each 6. Three questions I should ask the original author Do not paraphrase every line. Focus on intent and risk, not syntax.
Examples
Example input
Level: mid-level frontend, new to this backend repo Code: export async function reconcileInventory(sku: string) { const reserved = await redis.get(`reserve:${sku}`); const onHand = await db.stock.findUnique({ where: { sku } }); if (!onHand) throw new Error("missing sku"); const available = onHand.qty - Number(reserved ?? 0); await db.stock.update({ where: { sku }, data: { available } }); return available; }
What you should get
1. Summary: A backend helper that recomputes sellable stock for one SKU by subtracting Redis-held reservations from DB on-hand quantity, then writes available back to the DB. 2. Walkthrough: Read reservation count from Redis → load stock row → fail if SKU missing → compute available → persist available → return the number. 3. Side effects: Redis GET; two Prisma/DB calls (read + update). No HTTP. Mutates stock.available. 4. Assumptions that can break: reserved is always a numeric string; onHand.qty never null; no concurrent reconcile races; Redis key always means "units reserved." 5. Vocabulary: reconcile (recompute derived state from sources of truth); reservation (soft hold not yet purchased). 6. Ask the author: Who calls this and how often? Is there a lock around update? What happens if Redis is down - treat reserved as 0 or fail closed?
How to get a good result
Done when
1. Summary: A backend helper that recomputes sellable stock for one SKU by subtracting Redis-held reservations from DB on-hand quantity, then writes available back to the DB. 2. Walkthrough: Read reservation count from Redis → load stock row → fail if SKU missing → compute available → persist available → return the number. 3. Side effects: Redis GET; two Prisma/DB calls (read + update). No HTTP. Mutates stock.available. 4. Assumptions that can break: reserved is always a numeric string; onHand.qty never null; no concurrent reconcile races; Redis key always means "units reserved." 5. Vocabulary: reconcile (recompute derived state from sources of truth); reservation (soft hold not yet purchased). 6. Ask the author: Who calls this and how often? Is there a lock around update? What happens if Redis is down - treat reserved as 0 or fail closed?
FAQ
- What do I fill in before I copy this prompt?
- Replace these placeholders with your details: level, code. Required fields are marked on the page. The prompt text updates as you type.
- Which AI tools is this prompt written for?
- It works best with ChatGPT, Claude, Gemini, Cursor. Copy the filled prompt and paste it into the tool you already use.
- What should a good result look like?
- 1. Summary: A backend helper that recomputes sellable stock for one SKU by subtracting Redis-held reservations from DB on-hand quantity, then writes available back to the DB. 2. Walkthrough: Read reservation count from Redis → load stock row → fail if SKU missing → compute available → persist available → return the number. 3. Side effects: Redis GET; two Prisma/DB calls (read + update). No HTTP. Mutates stock.available. 4. Assumptions that can break: reserved is always a numeric string; on…
Best for
- Junior developers
- Students
- New team members
Related Prompts
More prompts like this — same topic and style.

