Skip to content
mentoor

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?

Choose one answer

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

  1. List the top-level modules in one line each: what it does, not what it contains. "billing/: invoices, payment retries, Stripe webhooks."
  2. Name the entry points. The server start file, the CLI main, the job runner, the route table.
  3. Add "to do X, start here" lines. "Add an API route: src/routes/, then register it in src/routes/index.ts." These are the most useful lines.
  4. Say what to leave alone. Generated code, vendored folders, migrations that were already applied.
  5. Name owners by team or role, not by person, so the line stays true when people move.
  6. 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?

Choose one answer

Check yourself · 3 of 3

Why list owners by team or role in a code map?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic