Repository map

Also known as: repo map

On this page 7

A repository map (or repo map) is a condensed, machine-generated outline of a codebase that lists its files together with the most important symbols, such as classes, functions, method signatures and type definitions, without their full bodies. In AI for coding, a repository map gives a language model a whole-project overview within a small token budget, so it can locate relevant code, respect existing interfaces and plan edits across files.

The idea was popularized by the open-source assistant Aider, which builds its map from syntax trees and ranks symbols by how often they are referenced. Similar structures now appear in many coding agents, sometimes under names such as project outline or code skeleton.

How a repository map is built

A repository map is produced by static analysis, not by the language model itself. The tool parses every source file, extracts definitions and references, ranks them by importance and then renders the most relevant entries as text that fits a fixed token budget.

  1. Parsing: a parser such as Tree-sitter turns each file into a concrete syntax tree, which works across dozens of languages with one interface.
  2. Symbol extraction: queries collect definitions (classes, functions, constants) and references (calls, imports, type uses).
  3. Graph construction: files become nodes, and an edge links a file that references a symbol to the file that defines it.
  4. Ranking: a graph algorithm such as personalized PageRank scores symbols, weighting files the user is editing or has mentioned.
  5. Rendering: the top-ranked signatures are printed under their file paths until the budget is reached, often 1,000 to 8,000 tokens.

Because ranking is personalized, the map changes with the task. When a developer adds a payment module to the chat, symbols that the module calls or that call it move to the top, while unrelated utilities drop out of view.

What a repository map contains

A good repository map keeps interfaces and drops implementations. A model rarely needs the body of a helper function to call it correctly, but it does need the exact name, parameters and return type. The following table shows typical content and its value to the model.

ElementExampleWhy the model needs it
File pathssrc/billing/invoice.pyLocate where code belongs
Class namesclass InvoiceServiceUnderstand domain structure
Function signaturesdef total(items, currency)Call existing code correctly
Type definitionsinterface User { id: string }Respect data contracts
Key constantsMAX_RETRIES = 5Reuse configuration values
Elision markers… (body omitted)Signal that detail exists elsewhere
Typical elements of a repository map

Comments, docstrings and private helpers are usually omitted to save tokens. Some tools include the first docstring line for public functions, which can improve accuracy when names alone are ambiguous.

Repository map compared with other context methods

A repository map is one of several ways to give a coding model context beyond the open file. It complements, rather than replaces, codebase indexing and semantic code search, which retrieve specific snippets on demand.

MethodWhat the model receivesStrengthLimitation
Repository mapRanked outline of symbolsGlobal structure at low costNo function bodies
Full-file contextComplete source of chosen filesExact detailExpensive, few files fit
Embedding retrievalSemantically similar chunksFinds code by meaningMisses structural links
Agentic explorationResults of grep, read and list toolsPrecise, on demandMany steps and tokens
Project rules fileHuman-written conventionsEncodes intent and styleManual upkeep, no symbols
Ways of supplying codebase context to a model

In practice, strong assistants combine methods: the repository map tells the model what exists and where, embedding search or agent tools fetch the details, and a rules file such as AGENTS.md states team conventions. Larger context windows reduce the need for maps on small projects, yet monorepos with millions of lines still exceed any window.

Configuring a repository map

The main setting is the token budget, which trades overview breadth against space for the task itself. Too small a budget hides relevant modules; too large a budget dilutes attention and raises cost on every request.

SituationSuggested budgetReason
Small project, under 50 files1,000 to 2,000 tokensMost symbols fit easily
Focused edit in a known module1,000 tokens or lessChat files already give detail
Cross-cutting refactor4,000 to 8,000 tokensModel must see many callers
Exploring an unfamiliar codebaseLarger map, no files addedOverview matters more than detail
Choosing a map budget by situation

Teams should also exclude generated and vendored code, such as build output, lock files and third-party libraries, because those symbols crowd out the project’s own interfaces. Caching parsed trees keeps map regeneration fast after each edit.

Limitations and failure modes

A repository map is a static, syntactic view. It cannot see runtime behavior, dependency injection, reflection or calls assembled from strings, so dynamically linked code may be ranked too low. Languages with weak parser support produce sparse maps.

  • Stale maps: if the map is not refreshed after edits, the model may call functions that were renamed.
  • Signature-only blindness: the model may assume behavior from a name that the body contradicts.
  • Ranking bias: heavily referenced utility modules can dominate while small but critical files disappear.
  • Budget overflow: in very large repositories, important areas may never surface without explicit file mentions.

These limits explain why a repository map is best treated as a navigation aid. When correctness depends on implementation detail, the assistant should open the actual file before editing it.

The idea in brief

A repository map is like the table of contents of a large book. It does not contain the full chapters. It lists the chapter titles, section names and where to find them.

An AI coding assistant cannot read every file of a big project at once. The map shows it which parts exist and how they connect. The assistant then knows where to look before it writes new code. This helps it reuse what is already there instead of inventing duplicates.

A practical scenario

A developer at a logistics startup maintains a Python backend of about 600 files and 90,000 lines. She asks a terminal-based coding assistant to add a discount field to shipping quotes. She adds only the quote API handler to the chat, and the assistant builds a 4,000-token repository map ranked around that file.

The map shows that a PricingRule class and a apply_rules(quote, rules) function already exist in a separate pricing module, along with a Quote data class in the models package. Instead of writing new discount logic inside the handler, the model extends the existing rule system, updates the data class and adjusts a serializer it found through the map. The change touches four files, the existing test suite passes, and code review finds no duplicated pricing logic, a common problem when the assistant worked without whole-project context.