AI-Assisted Software Development: Coding Agents in PracticeContext engineering for codebases · Lesson 5 of 17

Repo maps, skills, MCP and the context budget

Article · 13 min · 9 min lecture

Video lecture

Repo maps, skills, MCP and the context budget

14 chapters · about 9 min · full transcript

Coming soon

Chapter 1 of 14

Repo maps and the context budget

  • Context as a budget
  • Repo maps • Skills • MCP
  • Subagents for noisy work

The narrated lecture is in production

Every chapter is scripted and ready. Browse the chapters and read the full transcript now — the video will appear here when it’s published.

Chapters

The context budget

Context engineering is the discipline of putting the right information in front of the model at the right time, and nothing else. For coding agents, you are managing a budget with three constraints: window size, cost per turn, and the model's attention. A focused 20,000-token context usually beats a bloated 200,000-token one.

Think in layers:

LayerLoaded whenExamples
Always-onEvery sessionInstruction files (keep lean)
On demandWhen the task needs itSkills, docs pages, design notes, runbooks
DiscoveredAgent searches for itSource files, tests, grep results
ExternalVia toolsIssue tracker, database schema, browser, logs via MCP
IsolatedIn a separate contextSubagents doing broad searches and returning summaries

Repo maps: giving the agent a table of contents

Agents navigate large repositories by searching. You can speed that up and improve accuracy with a repo map: a compact description of structure and key entry points. Some tools build symbol maps automatically (for example, the open-source Aider popularized tree-sitter based repo maps); you can also maintain a short hand-written one.

## Repo map (docs/agents/repo-map.md)
- src/api/        HTTP handlers (thin). Route table: src/api/routes.ts
- src/domain/     Business rules. Invoices: domain/invoice/*, Tax: domain/tax/{pk,ae,gb}.ts
- src/infra/      DB (Drizzle), queues, email. No business logic here.
- test/           Mirrors src/. Fixtures in test/fixtures/. Factories in test/factories.ts
- Entry points: src/server.ts (API), src/worker.ts (background jobs)
- Hot spots: domain/tax/ae.ts changes often; read test/tax/ae.test.ts first.

Reference it from AGENTS.md ("For structure, read docs/agents/repo-map.md") so it loads on demand rather than every turn.

Skills and on-demand knowledge

Several tools now support skills: folders with a SKILL.md and optional scripts that the agent loads only when relevant (Claude Code popularized the format; other tools have adopted similar ideas). Use them for procedures you repeat: "add a new API endpoint", "write a database migration", "release checklist". Each skill costs almost nothing until it is needed.

---
name: add-endpoint
description: Use when adding a new HTTP endpoint to the invoicing API.
---
1. Add the zod schema in src/api/schemas/.
2. Add a thin handler in src/api/handlers/ that calls a domain function.
3. Register in src/api/routes.ts.
4. Add tests: test/api/<name>.test.ts (happy path, validation error, auth error).
5. Run: npm test && npm run check

MCP: bringing external context in safely

The Model Context Protocol lets agents query tools such as your issue tracker, documentation, database schema or a browser. Good uses: fetch the Jira or Linear ticket, read the OpenAPI spec, inspect a read-only staging database schema, view a page in a browser to verify UI changes. Rules:

  • Prefer read-only servers and credentials.
  • Install servers only from sources you trust, pinned to versions, and review what tools they expose.
  • Remember that content returned by MCP servers is untrusted input that can contain prompt injection (Module 5).

Subagents: isolate noisy work

When the agent must scan hundreds of files ("find every place we format currency"), do it in a subagent: a separate context that does the search and returns a short summary. The main session keeps a clean window for the actual change. Claude Code, Codex and other tools offer variants of this; even without built-in support, you can run a separate session and paste its summary.

Worked example: a migration in a 400k-line monorepo

A Riyadh fintech wanted to replace a deprecated logging library across a large TypeScript monorepo. The first attempt, one giant session, ran out of useful context and began making inconsistent edits. The second attempt:

  1. A subagent produced an inventory: files using the old logger, grouped by pattern (plain calls, child loggers, custom formatters).
  2. A skill described the exact replacement for each pattern, with a before/after example.
  3. Separate short sessions handled one package at a time, each ending with tests and a small PR.

Same model, same repo; the difference was context design.

Hands-on: audit your context

Run one real task and then ask the agent:

Before we finish: list every file you read in this session and every command you ran.
Which of them were necessary for the change? What information did you have to search for
that should have been in AGENTS.md or the repo map?

Use the answer to update your repo map and instruction file.

Pitfalls

  • Dumping whole directories into context "just in case".
  • Stale maps. Regenerate or review the repo map when structure changes.
  • Over-connected agents. Ten MCP servers mean more tools to confuse the model and more attack surface.

How to measure success

Watch tokens per completed task and the share of sessions that finish without restarts. Both should improve as context gets tighter.

Key takeaways

  • Treat context as a budget constrained by window size, cost and attention.
  • Layer context: always-on, on demand (skills, docs), discovered, external (MCP) and isolated (subagents).
  • A short repo map referenced from AGENTS.md speeds navigation in large codebases.
  • Use subagents for noisy searches and treat MCP output as untrusted input.

Check your understanding

Quick questions to lock in the lesson. They don’t count towards your certificate.

  1. An agent must find all currency formatting across 600 files before changing one module. What is the best approach?
  2. Which MCP practice is recommended for coding agents?

Put it into practice

Write a 10–15 line repo map for your project, reference it from AGENTS.md, and run the context-audit prompt after your next agent task.

Enrol for free to save your progress

Reading is always free. Enrol to keep your place, take the final assessment and earn a verifiable certificate.