Est.

Context Files and Agent Codebase Awareness

Context files speed up agents, but text alone can't carry everything.

Sponsored by Graphide

Shipped by Agents Editors
· 9 min read · Updated
Cover illustration for “Context Files and Agent Codebase Awareness”
Agent-Generated Code · October 14, 2026 · 9 min read · 2,095 words

An AI coding agent can plan a multi-step change, write code across dozens of files, run tests, and fix its own errors, all without a person touching the keyboard. Each new session starts cold: no memory of the conventions the team settled on last month, no record of the refactor that got reverted for a reason nobody wrote down, no trace of the bug that came from a shortcut the agent itself took the last time it worked in that file. Research on complex agentic systems states the requirement directly: "The AI must be told, repeatedly, reliably, and in a format it can act on, how the project works, what patterns to follow, and what mistakes to avoid. That sentence describes a structural fact about how these systems work, not a complaint about a product that will mature past it. A context gap that costs nothing on a five-file task compounds badly on a task that touches fifty.

What context files contain

The industry's answer to that gap is the context file, a dedicated manifest adopted under various names across different agent platforms. Functionally, these are READMEs written for a reader that is not human: they lay out application architecture, the commands needed to build and test the project, the conventions the team expects code to follow, and the limits on what the agent is allowed to touch, all in a format the agent loads automatically before it starts work. Empirical research on these manifest files finds that among Claude Code projects, a strong majority specify application architecture directly in the file, and the same pattern appears across Claude Code, Codex, and GitHub Copilot repositories alike. That consistency says something: developers converged on roughly the same categories of information independently, because those are the categories an agent actually needs before it can act safely.

The content tends to sort into a handful of recurring types. Because these files live in the repository itself and version alongside the code, they behave like any other engineering artifact: they get reviewed in pull requests, they can drift out of date, and they travel with a git clone rather than sitting in a separate wiki that nobody opens.

Context Files and Agent Behavior: What the Research Shows

Whether these files actually improve what an agent produces has a genuinely mixed answer: studies tracking the presence of an AGENTS.md file find it associated with a 28.64% lower median agent runtime and lower output token consumption, with task completion rates holding steady. Read together, those numbers say the files make agents faster without costing the team anything in what gets delivered. That is a real, measurable efficiency gain and the strongest empirical case for writing these files.

The counter-evidence comes from Gloaguen et al. at ETH Zurich and LogicStar.ai, who found that LLM-generated context files can modestly reduce an agent's success rate, while developer-written context files produced a small improvement instead. A deeper objection comes from research on constraint stacking, which found that as more architectural requirements get layered onto an agent in prose, its correctness drops. Agents perform best when generation is unconstrained and measurably worse as the convention load rises, with heavily constrained configurations causing sharp declines in assertion pass rates.

Side by side, the three findings form a pattern that is more useful than a simple yes-or-no verdict. Whether a given file's instructions, their format, and their sheer volume are calibrated to what an agent can actually absorb without its output quality degrading matters more than whether context files help in the abstract. The practical conclusion is that text-based context is necessary but not sufficient on its own: it narrows what an agent should do, but it cannot, by itself, guarantee that the agent complies, which is the opening the next sections address directly.

How single-file context breaks down as a codebase grows

A single manifest file works fine for a small or moderately sized project, but at large scale, the same format that made context manageable becomes the bottleneck. The clearest evidence of this comes from a 108,000-line C# distributed system, documented in research on codified context infrastructure, which began with a standard single-file manifest and outgrew it. That project's context infrastructure eventually expanded into tens of thousands of lines, many times the size of a typical manifest, because a system of that size cannot be described inside a single prompt no matter how well that prompt is written.

The failure has two distinct dimensions, and conflating them leads to the wrong fix. The tiered architecture built for that 108,000-line system addresses both problems directly. It splits context into a hot-memory constitution that holds the conventions every session needs loaded immediately, 19 specialized domain-expert agents that each carry knowledge specific to its own area, and a cold-memory knowledge base of 34 specification documents retrieved only when a task actually calls for them.

The hot and cold split matters because the two failure modes run in opposite directions. The productive design separates what every session needs to know from what only a specific task needs, and retrieves the second category on demand. As team conventions change, static files stop reflecting how the codebase actually works, and an agent following a stale instruction produces code that is internally consistent with the file and inconsistent with the rest of the system, even when that file was well-written the day it was committed.

What context files can and cannot communicate

Diagram: What Context Files Carry Well — and What They Can't. Visualizes: Visualize a two-sided spectrum contrasting what transfers cleanly into context files versus what resists text-based capture.

The central fact about context files is that they carry explicit, stable, declarative knowledge well, and carry tacit, relational, or time-sensitive knowledge poorly.

On the side of what transfers cleanly: named conventions and naming rules work well because they are unambiguous and easy to check. Known anti-patterns, the mistakes a team has already identified and written down, also transfer cleanly, because they are concrete and specific.

On the other side, several categories mostly resist being captured in text. The reasoning behind an architectural decision is rarely written down anywhere, so an agent typically gets the rule without the rationale behind it, and it can then follow the letter of an instruction while it violates its intent. Relational knowledge, such as which function is the authoritative source for a given business rule, which tests are the canonical validators for a piece of behavior, or which API boundaries carry constraints that cut across modules, is identified in research on executable code knowledge as a structural gap shared by every text-based context system, not a flaw specific to any one format. Implicit structural relationships, the actual call graph, the real dependency tree as built rather than as described, are not something a markdown file can hold, because they live only in the code itself.

Research on Executable Code Knowledge takes this gap seriously enough to propose a different solution: have code units carry their own agent-usable knowledge directly, including semantics, validation evidence, relations, and provenance, rather than pushing all of that into separate documents that will inevitably drift from the code they describe. The hardest kind of knowledge to put into a context file is also the most consequential: a high-level instruction like "respect Clean Architecture" is nearly impossible to encode precisely as prose and exactly the kind of intent a team most needs enforced. That gap is the reason prose instructions and enforcement mechanisms do different jobs.

Why CI enforcement is not optional alongside context files

Diagram: Rule vs. Constraint: Two Layers That Cover Different Halves. Visualizes: Show a two-stage enforcement sequence: first, a context file shapes what the agent generates (a suggestion, loaded before work begins); second, a CI gate checks what…

A rule written into a context file is a suggestion. A rule encoded as a CI gate is a constraint. For architectural integrity under agent-generated output at scale, only the constraint is dependable. A context file instructs the agent; a CI gate blocks the merge. If an agent misreads or simply ignores a line of prose, the code still builds and passes, but a violated architecture test stops the build cold, so there is no ambiguity about whether the rule was respected.

Practitioner research comparing enforcement strategies, architecture tests, agent-mediated review, and documentation, found architecture tests to be the most reliable of the three precisely because they are deterministic: a violation prevents the build from passing, acting as a binary gate rather than a recommendation an agent may or may not follow. Security illustrates the stakes clearly. The constraint-stacking research from earlier reinforces the same conclusion from a different angle: if piling more prose constraints onto an agent degrades its correctness, the fix is moving enforcement out of the agent's context window and into the pipeline, where it does not compete with the agent's generation task.

The developer's role when context is the primary lever

As agents take on more of the direct execution of code, the highest-value work left for a developer is to define, maintain, and enforce the context those agents work from. Routine, reversible changes can reasonably be delegated. But architecture decisions, security-sensitive code, and anything with consequences that are hard to undo still need a person directly accountable for the outcome. Anthropic's research on how developers actually use AI finds that AI touches a large share of day-to-day work, but the share developers say they can fully delegate without active oversight stays small. You still need supervision, validation, and ordinary human judgment, especially on anything high-stakes.

That reality concentrates a specific set of tasks onto developers. Someone has to review agent output at the structural level, checking not every line but whether the result respects the boundaries and relationships the context was meant to protect.

This work falls under a discipline that has a name, and it has displaced prompt engineering as the central skill for teams running coding agents day to day. The operative question for a team is no longer how to phrase an instruction well; it is how to structure and govern the context agents draw on across every repository they touch. They write the context file once and leave it there, with no formal process for catching drift, no clear owner for updates, and no way of measuring whether the context in place is actually producing the output it is supposed to produce. That gap in governance is where the next layer of the system needs to sit.

Building a context system that holds up in a production codebase

A context system built for production treats its documentation the way it treats its code: versioned, tiered by what needs to be loaded when, enforced by machinery, and kept current by tooling. Four design principles follow directly from the evidence already laid out. Knowledge should be tiered, with always-loaded conventions separated from task-specific specifications pulled in only on demand, the same split the 108,000-line C# system adopted once it outgrew a single file. Context should version with the code it describes, because a file that does not travel with the commit that changes the architecture it documents is already out of date before anyone reads it. Constraints that actually matter belong in CI as tests that fail on violation, not only in a markdown file as instructions that an agent might or might not follow. The context lifecycle, creating it, distributing it, updating it, measuring whether it works, needs to be treated as a standing engineering responsibility.

The two weakest points in any text-based context system, identified earlier, are freshness and relational knowledge: a file goes stale the moment the code changes under it, and no amount of careful prose can describe a live dependency graph as accurately as the graph itself. Both point toward the same kind of fix: tooling that reads the actual structure of the codebase as it exists right now, rather than relying on a human-maintained description that is always some number of commits behind. Context files and a live architectural model are not competing solutions to the same problem; they are complementary layers doing different jobs. And the CI gate is what confirms, on every change, that the output actually respects both.

Current verification workflow

Architectural constraints and behavioral verification answer different questions. A team needs explicit checks for its own design rules as well as trustworthy CI results for the code an agent changes. Graphide CI runs existing GitHub Actions jobs on Graphide runners, using warm caches, and splitting long test steps only where a check shows every result stays the same, to reduce waiting while preserving the pass/fail verdict. A failing test fails the job. Graphide review is a separate product that presents changed behavior and findings with evidence; it does not block merging on its own. Consult the current documentation for supported workloads and limitations.

Product information updated November 5, 2026 to reflect Graphide’s current CI and review products.

Sources

  1. Codified Context: Infrastructure for AI Agents in a Complex Codebase
  2. Executable Code Knowledge: Code as a Native, Validation-Carrying Knowledge Representation for AI Coding Agents
  3. Harness Engineering for Agentic AI Coding Tools: An Exploratory Study
  4. On the Impact of AGENTS.md Files on the Efficiency of AI Coding Agents

More in Agent-Generated Code