You have inherited a service you did not write — a 120k-line Django monolith, say — and your first ticket touches invoicing. The classic failure mode is changing code whose blast radius you never mapped.
Tier: Foundation · Workflow area: Context & comprehension
This playbook uses a read-only agent pass to build a verified mental model in under an hour, before you edit a single line.
Skip it for code you already know well, or for a module small enough to read top-to-bottom in 20 minutes.
credit_note type to invoicing"). Comprehension without a goal produces trivia, not a map.State the mission, forbid edits. Open your agent at the repo root and anchor it:
You are in read-only mode: do not modify any files. I need to add a new
invoice type ("credit_note") to this codebase. Explore the repo and give me:
1. The 5-10 files most relevant to invoice creation and rendering.
2. The end-to-end path of an invoice: entry point -> business logic ->
persistence -> side effects (emails, webhooks, ledger entries).
3. Any state machines, feature flags, or enums that gate invoice behavior.
Cite file paths and line numbers for every claim.
Demand a trace, not a tour. Generic architecture summaries are cheap. Force a request trace:
Trace exactly what happens when POST /api/invoices is called with
type="standard". List every function in call order with file:line.
Note where the transaction boundary is and what happens after commit.
Spot-check three citations. Open three of the cited file:line locations yourself. If any citation is wrong or vague, tell the agent and make it re-verify the whole trace. Do not proceed on an unaudited map.
Hunt the implicit contracts. These are what break under change:
For the invoice module, list implicit contracts a new invoice type could
violate: enum exhaustiveness checks, serializers that switch on type,
DB constraints, Celery tasks that filter by type, template conditionals,
and any downstream consumer of the invoice webhook payload.
Write the one-page map. Ask for a summary in your own doc format (entry points, data flow, invariants, danger zones, open questions), then edit it by hand. Paste the open questions to a teammate who knows the code — their corrections are the highest-value review you will get this week.
The deliverable is not the chat transcript — it is a one-page, citation-backed map that you personally spot-checked, plus a list of implicit contracts your change must respect.
@codebase context; ask the same questions but expect to feed it specific files when retrieval misses.file:line citation, and you manually opened at least three of them.services/invoice_service.py) in repos that use different conventions. This is exactly why step 3 exists.Client contracts often forbid sending source to external APIs. Options in order of preference:
grep/IDE navigation and use the model to explain each hop.pyan/madge) instead of bodies.A directory listing plus schema names can itself be confidential under some NDAs — check what your engagement allows before pasting anything.