Lesson 1 of 8 · 3 min read
Repository Context
In this lesson
TL;DR: Start the agent with a small map, not the code: the directory outline with each file's main classes and functions, the repository's instruction file, and how to build and test. Give it exact search for names, structural lookups for definitions and references, and semantic search only for vague questions. It reads slices of the files it finds, records what it learned in notes, and stops exploring once it can name the files to change and why. Context is spent on the code the task touches.
After this lesson, you should be able to explain why coding agents need a map and search tools rather than whole files, build a simple repository map, choose between exact, structural and semantic search, and use instruction files and notes to keep exploration short.
Before you read
Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.
1An agent must fix a bug in how invoice totals round. Its only tool is semantic search over code chunks, and it keeps returning formatting helpers. What tools would find the right code faster?
The map
A repository map is a compact outline: files and their top-level symbols, sometimes with signatures. Aider popularised the idea of a ranked repository map built from parsed source (as of 2024 to 2026); the general technique is simple to reproduce:
import ast
FILES = {
"billing/invoice.py": ("class Invoice:\n def total(self): ...\n"
" def lines(self): ...\n"),
"billing/rounding.py": ("def round_half_even(x, places=2): ...\n"
"def round_up(x): ...\n"),
"web/views.py": "def invoice_page(request): ...\n",
}
def repo_map(files, query_words):
rows = []
for path, src in files.items():
tree = ast.parse(src)
names = []
for node in tree.body:
if isinstance(node, ast.ClassDef):
methods = [f"{node.name}.{f.name}" for f in node.body
if isinstance(f, ast.FunctionDef)]
names += [node.name] + methods
elif isinstance(node, ast.FunctionDef):
names.append(node.name)
score = sum(w in (path + " ".join(names)).lower() for w in query_words)
rows.append((score, path, names))
rows.sort(key=lambda r: (-r[0], r[1]))
return [f"{p}: {', '.join(n)}" for _, p, n in rows]
top = repo_map(FILES, ["round", "invoice"])
print(top[0]) # => billing/invoice.py: Invoice, Invoice.total, Invoice.lines
print(top[1]) # => billing/rounding.py: round_half_even, round_up
A few hundred tokens of map for a large repository tells the agent where things are. Real maps rank by references between files, include signatures, and fit a token budget.
Ways to look
| Tool | Finds | Best when |
|---|---|---|
| Exact search (grep, glob) | Literal names, strings, error messages | You know a name or message |
| Structural (language server, symbol index) | Definitions, references, call sites, types | Following code from a known symbol |
| Semantic search (embeddings) | Code similar to a description | The question is vague ("where do we throttle uploads?") |
| Tests and build files | How code is exercised and built | Deciding what to run after a change |
| Version control history | Recent changes, blame | "When did this break?" |
Repository map
outline, instructions, how to test
Exact search
names and error messages
Structural lookups
definitions, references
Read slices
only the lines that matter
Name the files
notes, then stop exploring
Used less often
Semantic search
for vague questions with no exact name
Version history
when the question is when it broke
Coding agent products in 2025 and 2026 leaned heavily on agentic exact search, with semantic indexes as a complement; the reason is that code questions often contain exact identifiers.
Instructions the repository gives
Many repositories now include an instruction file for agents (AGENTS.md is a widely used convention; some tools read their own named files) with build and test commands, conventions and areas to avoid. Read it first; it is cheaper than discovering the same facts by trial.
Keep exploration short
- Read slices (a function, a class) rather than whole files.
- Record findings in notes: "rounding happens in billing/rounding.py:round_half_even; Invoice.total calls it".
- Stop when you can name the files to change and why; then edit.
Say it in 30 seconds
"Repositories are far bigger than any context, so a coding agent starts from a compact map of files and symbols, the repository's instruction file and the build and test layout. It looks things up with exact search for names, structural lookups for definitions and references, and semantic search for vague questions, reads slices rather than files, keeps what it learns in notes, and stops exploring once it can name the files it will change."
Check yourself
Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.
1Why is semantic search a complement rather than the main tool for coding agents?
2What does a repository map give the agent that a file list does not?
3When should exploration stop?