Capstone — ship a 200-line PR via prompts only

The code-explainer system prompt

5 min read

Most engineers underuse system prompts. They drop everything into the user message and re-paste the same instructions every conversation. The system prompt is where your role for the assistant lives — and for the capstone, you want a tight assistant whose only job is explaining unfamiliar code in the file you're about to touch.

A good prompt design exercise: write the system prompt yourself first, then ask the model to write one and compare. Here's the model's version:

Write a tight system prompt (under 200 words) for an internal AI tool whose ONLY job is to explain unfamiliar code to junior developers. Constraints the prompt must enforce on the assistant:

  • Always start the answer with a 1-sentence "what this code does" summary.
  • Then a numbered walkthrough, line by line, max 8 numbered items.
  • Refuse to write or modify code; this tool only EXPLAINS.
  • If the code seems intentionally malicious (rm -rf, credential exfil), refuse and say why in 1 sentence.
  • Never invent imports or behaviour not visible in the code.
  • Output in plain markdown only.

Output ONLY the system-prompt text. No commentary around it.

Claude Sonnet 4.5 returned:

You are a code explanation assistant for junior developers. Your sole purpose
is to explain unfamiliar code clearly and safely.

Mandatory structure for every response:
1. Start with exactly one sentence summarizing what the code does
2. Follow with a numbered walkthrough (maximum 8 items) explaining the code
   line-by-line or section-by-section
3. Use plain markdown only

Strict constraints:
- NEVER write, modify, suggest, or generate code
- If asked to write or modify code, refuse and redirect to explanation only
- If code appears malicious (e.g., rm -rf, credential theft, data
  exfiltration), refuse in one sentence explaining why
- Only explain what's actually present in the provided code—never assume or
  invent imports, functions, or behavior not shown
- Stick to factual explanation of the code's mechanics, not opinions on quality

If the user provides no code or asks non-explanation questions, remind them
you only explain existing code snippets.

Captured from Claude Sonnet 4.5 (claude-sonnet-4-5) on 2026-04-27. Re-runs may differ slightly.

This is the system prompt you'll use for the exploration phase of your capstone. Drop it in as the system message in your chat client. Now every paste of unfamiliar code gets a structured explanation: 1-sentence summary, up to 8-step walkthrough, no invented imports, no opinions on style.

Why these specific constraints? Each one closes a failure mode I've seen burn engineers:

ConstraintFailure it prevents
1-sentence summary first"What does this do?" buried under 6 paragraphs of detail
Max 8 numbered stepsWalkthrough that ramps to 30 items and re-explains itself
Refuse to write codeTool drift — exploration becomes accidental refactor
Refuse on malicious codeLiability and ethical guardrails
Never invent imports/behaviourHallucinated explanations of code that doesn't exist
Plain markdown onlyCleaner output for piping into notes

The "refuse to write code" constraint is the most useful of the bunch. Without it, the assistant will see an inefficient function and "helpfully" suggest a rewrite. That breaks your phase boundary — you wanted to understand the code, not change it. Save the change prompts for the next session, with the codegen skeleton system prompt.

A second system prompt to write for the capstone is the change-time one. You'll be asking the assistant to write the actual fix. The system prompt for that phase should enforce the four-block skeleton from module 1: every codegen reply must include INTENT, CONSTRAINTS, TESTS, FORMAT. Building this prompt is part of the capstone artifacts.

A practical workflow: keep the explainer system prompt and the codegen system prompt in two different chat sessions. Don't mix them. Switch sessions when you switch phases — exploring → writing → reviewing. Each session has the right tool installed for the work.

Next up: the rubric you'll grade yourself against. :::

Quiz

Module 6: Capstone

Take Quiz
Was this lesson helpful?

Sign in to rate

FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.