Topic 3 of 5 · 4 min read
Code maps for engineers and agents
Goal: Write or check a code map that lets a new engineer or agent find the right module for a task in one step.
A code map is a one-page guide that says where things live, what each module is for, and where to start for common tasks. It saves a new engineer an afternoon and saves an agent a long, expensive search.
Check yourself · 1 of 3
Which map line helps a new engineer most?
Why it matters
An agent starting a task has no memory of your repo. It lists directories, opens files and guesses. If the structure is clear, it finds the right place. If two folders are called utils and common, it may edit the wrong one or build a third. Project memory files such as AGENTS.md and CLAUDE.md are loaded at the start of a session, so a short map there is read every time. A good map also helps people, which is why it belongs in the repo and not in a chat.
How to do it
- List the top-level modules in one line each: what it does, not what it contains. "
billing/: invoices, payment retries, Stripe webhooks." - Name the entry points. The server start file, the CLI main, the job runner, the route table.
- Add "to do X, start here" lines. "Add an API route:
src/routes/, then register it insrc/routes/index.ts." These are the most useful lines. - Say what to leave alone. Generated code, vendored folders, migrations that were already applied.
- Name owners by team or role, not by person, so the line stays true when people move.
- Keep it short. If it grows past one screen, link to deeper pages. Ask the agent to draft it, then verify it.
Before and after
Weak map, generated in one shot: "src/core/: core application logic. src/lib/: library code. src/shared/: shared utilities." Every line is true and none of them helps anyone choose a folder.
Fixed map: "src/orders/: create, cancel and refund orders; start here for checkout bugs. src/payments/: talks to the payment provider only; no business rules. src/shared/: date and money helpers; do not add domain logic." Each line answers "would my task be here?"
What goes wrong
- Plausible but wrong paths. The agent lists a folder that was renamed last month. Check every path exists with
ls. - Describing the folder tree, not the purpose. A tree is already one command away.
- No maintenance. The map goes stale on the first big refactor. Make updating it part of any change that moves modules.
- Too long. A map no one finishes reading is not read by an agent either.
Examples
A map entry that routes a task
## Where to start
- Add an API route: `src/routes/`, register in `src/routes/index.ts`.
- Change an email template: `src/mail/templates/`; do not edit `dist/`.
- Add a database column: new file in `migrations/`; never edit old ones.
Each line names a task, a folder and a rule.
Checking a drafted map
The agent's map says src/services/notify/ handles push notifications. Running ls src/services shows only mail/ and sms/. The folder does not exist; push lives in src/push/. The reviewer asks the agent to re-check every path with a directory listing and to remove any line it cannot confirm.
Key points
- A code map answers where things live, what each module is for, and where to start for common tasks.
- Describe purpose, not contents; a directory listing is already one command away.
- Include 'to do X, start here' lines, because they are what newcomers and agents use most.
- Verify every path and claim in an agent-drafted map against the repo before committing it.
- Put it in a file the agent loads each session, such as AGENTS.md, and keep it to about one screen.
Common mistakes
- Accepting an agent-written map without checking that every listed path exists.
- Writing vague one-word descriptions such as 'helpers' or 'core' that do not help choose a file.
- Listing people by name as owners, so the map is wrong after a reorganisation.
- Letting the map grow into a full architecture book that nobody reads in one pass.
Check yourself · 2 of 3
An agent drafts a code map. What is the first check before you commit it?
Check yourself · 3 of 3
Why list owners by team or role in a code map?
Practice items, not counted towards your mastery.
Start here
- Architectural Decision Records (adr.github.io) (opens in a new tab)DocsFree
Templates, tooling and examples for ADRs, from the community that maintains the format.
- Documenting Architecture Decisions (Michael Nygard) (opens in a new tab)ArticleFree
The original short essay: title, status, context, decision and consequences, kept small and in the repo.
- Docs as Code (Write the Docs) (opens in a new tab)ArticleFree
Treat docs like code: version control, review, automated checks and the same pull request.
More for this topic
- AGENTS.md (opens in a new tab)DocsFree
An open convention for a plain file that tells coding agents how a repo is built and tested.
- How Claude remembers your project (Claude Code docs) (opens in a new tab)DocsFree
How project memory files such as CLAUDE.md are loaded, and how to keep them short and accurate.