Skip to content
Back to the six
02

Context

What does it know about your world, right now?

Putting what actually exists within reach: your code, who calls what, and the docs for the library version you have installed.

Memory01Context02Standards03Capability04Method05Control06

The idea that outlives the tools

The agent is not lying, it is completing. Give it something to check against and it stops guessing.

The model completes the most probable pattern. If it has never seen your code, the most probable function is the one that ought to exist. That is why hallucinations sound so good: they are built to sound good, not to be true.

The fix is not a bigger model. A better model lowers the error rate but does not touch the cause, because the cause is that it has nothing to check against. The fix is putting the truth within reach and making it cheap to query.

There are three kinds of context and they are not covered the same way. Structural: what exists in your repository and who uses it — that is a code index. External: how the version of the library you actually have installed is really used — that is fetching current documentation. And conversational: the files open in this chat, which is the only kind most people use.

Beware the reflex to shove everything in. Context is not volume, it is relevance. A window full of irrelevant files performs worse than a window with the three right ones, and costs more.

How it works, stage by stage

That was the why. This is the machine: what happens at each stage and, above all, which decision is yours at each one. If there is a stage where you decide nothing, that stage is being decided for you by the tool.

  1. 01

    Inventory

    What happens

    Before it answers anything, three distinct sources are available to the agent: an index of your repository, the documentation for the versions you actually have installed, and the files opened in this conversation.

    What you decide

    Which of the three really exist. Most people have only the third and believe they have all three.

  2. 02

    Selection

    What happens

    Each request draws a subset. With an index you can ask “who calls this function” and get ten exact fragments back, instead of reading thirty whole files to find them.

    What you decide

    Relevance. Context is not volume: three correct files outperform thirty loaded just in case, and cost less.

  3. 03

    Order

    What happens

    What was chosen is assembled in a fixed order: permanent rules first, then retrieved memory, then the conversation, and your request last. What arrives late, and what stands out, can carry disproportionate weight.

    What you decide

    What goes at the top and what goes at the bottom. A critical rule buried under two hundred lines of test output is competing with those lines, and losing.

  4. 04

    Budget

    What happens

    All of it lands in a finite window that you pay for twice: in tokens when you send it, and in accuracy when the model reasons over it. A bigger window moves the limit; it does not remove it.

    What you decide

    The split. Everything you load just in case is room the real problem will not have later.

  5. 05

    Eviction

    What happens

    When the window fills, something is dropped or summarised. The summary keeps the thread and loses the exact detail — which is usually the part that mattered.

    What you decide

    Cutting before it cuts for you. Work split into phases never reaches that point.

  6. 06

    Refresh

    What happens

    The index ages with every commit. If nobody syncs it, the agent answers you about a repository that no longer exists, with exactly its usual confidence.

    What you decide

    Making the sync automatic. An index somebody has to remember to update is an index that is out of date.

Signs you are missing it

  • It wrote a helper that already existed three folders over.
  • It uses a library API that went stale two versions ago.
  • It edited the wrong file because two had similar names.
  • You paste files into the chat by hand so it understands.

Common mistakes covering it

  • Confusing more context with better context. Filling the window degrades attention on what matters.
  • Letting the code index go stale. An old map is a new kind of lie.
  • Covering structural context and forgetting external context, which is where library hallucinations come from.

Jobs that lean on this discipline

Practices that cover it

Ways of working, not products. You apply them with whatever tool you already have.

Tools that cover this discipline

None of them is mandatory. Covering the discipline is mandatory; these are known ways of doing it.

CodeGraph

Colby McHenryIndex

An index of your code as a graph: symbols, who calls what, dependencies and blast radius.

Problem, mechanism & fit
The actual pain
Grepping and reading whole files to understand one function burns the window and still misses who calls it.
How it works
Indexes the repository as a graph of symbols and relations. One query returns the relevant source with line numbers, the call paths between symbols, and a summary of what breaks if you touch it — in a single round trip instead of a search-and-read loop.
When it fits
In any repository that no longer fits in one person's head. The gain is not only accuracy: the agent spends its context thinking rather than searching.

Context7

UpstashService

Pulls current, version-specific documentation for the library you are using straight into context.

Problem, mechanism & fit
The actual pain
The model learned a library's API at some point in the past. You have a different version installed. Out of that gap come the calls that look right and do not exist.
How it works
Connects as an external service and exposes two operations: resolve a library's identifier, and fetch its current documentation and examples for the right version.
When it fits
When you work with fast-moving libraries, or when the agent keeps insisting on an API that no longer exists. It connects in minutes and removes an entire cause of error.

Also helps with

gbrain

Garry TanService

Memory

A Markdown knowledge base with hybrid search, an entity graph, and synthesised answers with citations.

AGENTS.md

Open standard, Agentic AI FoundationFile

Standards

A file in the repository holding the project's rules, which the agent loads on its own at startup. An open format read by a couple of dozen agents, from Codex and Gemini CLI to Cursor, Copilot and Devin.

Cursor

AnysphereHarness

Capability

An editor with the agent built into the editing surface.

MCP

Anthropic, open standardProtocol

Capability

An open protocol connecting any agent to external tools, data and services.