Repository Context for AI Agents, Explained
"Give the agent more context" is the most common advice for AI coding, and the vaguest. This article breaks down what repository context actually is, why pasting files or relying on a bigger context window isn't enough, and how to give an agent the context it needs.
What "repository context" means
Code is only one layer. An agent making a good change needs several:
| Layer | Question it answers |
|---|---|
| Code | What does this function do? |
| Structure | Which modules and files make up this area? |
| Relationships | What depends on this, and what does it depend on? |
| Features | Which code implements a given product behaviour? |
| Data | Which tables or collections does this read or write? |
| History | When and why did this change? |
| Organisation | Which other repositories are involved? |
Most agents start with only the first layer, plus whatever files they happen to open.
Why a bigger context window isn't the answer
Even with a large context window, two problems remain:
- The agent has to find the right files first. Context only helps if it's relevant. In a large codebase, much of an agent's effort goes into searching rather than reasoning.
- Relationships aren't written down in any one file. "Service A calls service B" might only exist as an HTTP call to a URL. Reading more files doesn't automatically reveal that.
So good context is less about more text and more about the right structure, prepared in advance.
Raw files vs an index
An agent can get repository context in two ways:
- Raw files
- the working tree on your machine, including your branch and uncommitted changes. It's always current, but the agent has to search it and rediscover how things connect on every task.
- An index
- structure such as symbols, imports, routes and dependencies, extracted in advance. The agent can look relationships up instead of rediscovering them, but the index reflects the code it was built from.
The best results combine both: the index to find what's relevant and how it connects, and the files themselves for the current detail.
How CodeZero provides repository context
CodeZero builds and maintains these layers, so they don't have to be rebuilt for every task:
- Code Graph: one view of how modules, files, data and repositories connect, across every repository you add.
- Feature Mapping: traces one product feature from where it starts, through the files involved, to the data it reads or writes and any other repository it depends on.
- Git Tree: repository history and everyday Git operations.
- Context-aware chat: ask questions answered from all of the above.
- Indexed on your machine: CodeZero indexes each repository's main branch locally. Only structural data, such as symbols, imports, routes and dependencies, goes to Frigga's server to build the cross-repository graph; your source code stays on your machine.
- Your working tree, read directly: the agent reads your local files, so it sees your current branch and uncommitted changes.
CodeZero runs inside VS Code alongside your coding agent. It supplies the context, and your agent writes the code.
FAQ
Is repository context the same as RAG?
Partly. Search-based retrieval finds similar text. Repository context also includes structure and relationships, such as what depends on what, which text similarity doesn't capture.
Does indexed context include uncommitted changes?
No. CodeZero indexes each repository's main branch. Your agent reads your local working tree directly, so it still sees uncommitted changes.