Why Context Engineering Is Becoming an Engineering Discipline
Providing AI agents with more information does not necessarily improve their performance. This article examines how engineering knowledge can be structured, selected, maintained and evaluated to support more reliable AI-assisted software development.
On this page
Two AI coding agents receive the same development task and operate using the same underlying model.
The first receives a general description of the required functionality and access to the source code.
The second also receives the relevant architectural decisions, established business rules, repository conventions, acceptance conditions and known compatibility constraints.
Their capabilities are technically equivalent, but the information available to guide their decisions is different.
The second agent may be better positioned to produce an appropriate implementation. However, providing substantially more information does not guarantee a better result. If that information is outdated, contradictory, unnecessarily restrictive or irrelevant to the task, it may make the implementation more difficult.
This is the central challenge of context engineering.
It concerns the deliberate management of information available to an AI system so that the system can reason and act within an appropriate operational environment.
For software engineering, the subject extends considerably beyond writing better prompts. It involves deciding which project knowledge matters, where that knowledge originates, how it should be maintained, which information an agent should retrieve and how its usefulness can be evaluated.
These are familiar engineering concerns applied to a relatively new problem.
From Individual Prompts to Persistent Engineering Context
A prompt describes an immediate task. Engineering context establishes the environment in which that task must be understood.
Consider a request to modify the filtering behavior of a product-listing page.
The immediate instruction might require the application to preserve selected filters when customers change the sorting order.
Implementing this behavior requires more than understanding the sentence. The developer may need to determine how filters are represented in the URL, which component owns the application state, how search requests are constructed and what happens when customers navigate backward.
An engineer familiar with the application may already understand many of these relationships. A coding agent must discover them or receive sufficiently relevant information about them.
Persistent engineering context can reduce the need to reconstruct the same project knowledge for every task.
Repository-level instruction formats such as AGENTS.md provide a mechanism for communicating project conventions, commands and constraints to compatible coding agents [1].
However, a repository instruction file represents only one component of context engineering.
The broader environment includes source code, specifications, design decisions, schemas, issue descriptions, test results, operational records and information retrieved through external tools.
Anthropic’s guidance on context engineering emphasizes the deliberate selection and management of information available to an agent during execution [2].
The engineering challenge is therefore not simply to create instructions. It is to establish an information environment that supports appropriate reasoning without introducing unnecessary ambiguity or cognitive overhead.
What an Engineering Agent Actually Needs to Know
Useful project context can be organized into five complementary layers.
Project intent
This layer explains the purpose of the system, its intended users and the business objectives influencing its design.
Without this information, an agent may optimize technical behavior while weakening the product’s actual purpose.
For example, reducing the number of steps in an administrative workflow may appear beneficial until the agent discovers that one of those steps represents a required approval.
System knowledge
This includes architecture, component responsibilities, interfaces, dependencies, data models and important state transitions.
Its purpose is to help the agent understand where a change belongs and which existing behavior may be affected.
Engineering constraints
These are the conventions, compatibility obligations, security boundaries and implementation restrictions that govern permissible changes.
They should distinguish mandatory constraints from ordinary preferences.
A preference for a particular naming convention does not carry the same consequences as a requirement to preserve authorization boundaries.
Verification knowledge
This includes acceptance criteria, test commands, relevant fixtures, known limitations and the evidence required to evaluate a change.
Knowing how to run the entire test suite is useful. Knowing which tests establish the affected behavior is often more useful.
Current project state
This layer captures temporary decisions, ongoing changes, unresolved problems, accepted milestones and the latest relevant verification.
It prevents an agent from relying exclusively on an outdated description of the system.
| Context layer | Question it answers | Representative sources |
|---|---|---|
| Project intent | Why does the system exist? | Product objectives and business requirements |
| System knowledge | How does the system work? | Architecture, interfaces and source code |
| Engineering constraints | What must be preserved or avoided? | Standards, policies and compatibility rules |
| Verification knowledge | How should correctness be established? | Acceptance criteria, tests and evidence |
| Current project state | What is true at this particular point? | Decision records, revisions and handovers |
These layers need not become five separate documents.
Their value lies in distinguishing different kinds of knowledge, particularly when those kinds have different authorities, maintenance responsibilities and rates of change.
Organizing Requirements, Architecture and Repository Knowledge
A common mistake is to place every potentially useful instruction in a single repository-level document.
This approach initially appears convenient. The agent receives one source containing architectural descriptions, development conventions, commands, product requirements, testing procedures and historical decisions.
As the project evolves, however, the document can become difficult to maintain. Information may be duplicated across other sources, and temporary instructions may remain long after their original purpose has expired.
A more sustainable approach separates durable guidance from detailed and task-specific knowledge.
Consider the following illustrative repository structure:
| Location | Intended responsibility |
|---|---|
AGENTS.md |
Short, repository-wide rules and navigation |
docs/architecture/ |
System boundaries and architectural decisions |
docs/requirements/ |
Business rules and accepted behavioral requirements |
docs/verification/ |
Test procedures, quality gates and known coverage limitations |
docs/decisions/ |
Consequential decisions and their rationale |
docs/current-state.md |
Current revision, temporary constraints and unresolved work |
The exact structure should reflect the project rather than follow a universal template.
For a small application, a concise README and a short set of engineering instructions may be sufficient. A complex system with multiple packages, teams and deployment environments may benefit from more localized guidance.
The important principle is that a context file should direct the agent toward authoritative knowledge rather than attempt to reproduce the entire repository.
A worked example of task-specific context
Return to the product-filtering task.
The agent needs to preserve selected filters when the sorting order changes. A relevant context package might establish the following facts:
| Context element | Illustrative project decision |
|---|---|
| Required behavior | Changing sorting must preserve selected filters |
| State ownership | The URL query represents the shareable search state |
| Existing architecture | Search requests are produced through a shared query builder |
| Preserved behavior | Back navigation, pagination and filter clearing must retain their established semantics |
| Implementation constraint | Do not introduce a second independent filter-state mechanism |
| Verification | Exercise combined filters, sorting changes, navigation and request construction |
This is more useful than a large collection of unrelated frontend documentation because every element influences the task.
It also reveals information that the original request does not explicitly contain.
An agent that introduces a separate client-side filter store might appear to solve the immediate problem while creating inconsistencies between the browser URL, displayed filters and underlying search requests.
Relevant architectural context helps expose that risk before implementation.
The context does not eliminate the need to inspect the actual source code. It identifies what the investigation must establish.
Context Selection, Relevance and Information Overload
Larger context windows allow models to receive more information, but available capacity should not be confused with effective use.
Liu and colleagues investigated the ability of language models to retrieve relevant information from long inputs. Their results showed that performance could deteriorate when important information appeared in different positions within a lengthy context [3].
Although those experiments concerned specific retrieval and question-answering tasks rather than complete software engineering workflows, they challenge the assumption that additional input is always beneficial.
More directly relevant findings have emerged from recent coding-agent research.
In 2026, Gloaguen and colleagues evaluated repository-level context files using established software engineering tasks and repositories with developer-authored instructions. Across their evaluated configurations, providing context files did not improve task completion overall and increased inference costs by more than 20%. The researchers recommend limiting unnecessary instructions [4].
A separate 2026 workshop paper by Khatri examined two coding agents across 288 runs on real repository tasks. Within its experimental design, changing the context-injection strategy did not produce a measurable correctness improvement. The analysis suggested that many failures arose from implementation difficulties rather than information missing from repository instructions [5].
These findings are especially important because they contradict a convenient assumption: that sufficiently detailed documentation will reliably improve agent performance.
Documentation can help an agent discover the correct implementation boundary. It cannot necessarily compensate for limited reasoning ability, unsuitable implementation decisions or misunderstood technical relationships.
Context engineering should therefore optimize relevance rather than volume.
Selecting context according to its consequences
A useful selection process asks several questions.
Does this information establish a requirement that affects the task? Does it identify a system dependency? Does it constrain an implementation decision? Does it provide verification evidence? Would omitting it materially increase uncertainty or risk?
Information that does not answer such questions may be better retrieved when needed rather than included automatically.
Different tasks require different amounts of context. Correcting an isolated typographical error does not require the same architectural information as changing the behavior of a shared authorization mechanism.
The appropriate context should be determined by the task and its consequences.
Managing Conflicting Instructions and Outdated Documentation
Engineering knowledge changes over time.
A dependency is replaced, a deployment environment is updated, a previously accepted requirement changes or a temporary restriction becomes unnecessary.
If an agent receives obsolete context, it may follow an instruction that was once correct but is no longer appropriate.
The problem becomes more difficult when the same guidance is maintained in several formats.
A November 2026 preprint by Shanto and colleagues examined 3,387 agent instruction files across 1,000 GitHub repositories. Their manual comparison identified divergent guidance in 16.1% of 386 corresponding section pairs across coexisting instruction formats [6].
This is a documentation-consistency problem with direct implications for agent behavior.
Two agents working in the same repository may receive materially different instructions even when they have access to identical application code.
Establishing authority and validity
A useful context system should distinguish between:
- Approved requirements and proposed requirements.
- Current architectural decisions and historical alternatives.
- Mandatory constraints and implementation preferences.
- Verified observations and unconfirmed assumptions.
- Durable project rules and temporary task restrictions.
An important decision should be associated with its scope, responsible authority, effective status and supporting source.
For example, an architecture document might describe URL-based state ownership, while an older issue discussion proposes introducing a separate state store.
The presence of both documents should not authorize an agent to select whichever approach is easier to implement.
The conflict must be resolved using the applicable decision record or an authorized clarification.
Likewise, the existing source code provides evidence of current implementation, but it does not always establish intended behavior. Code may contain defects that contradict the approved requirement.
Different sources answer different questions.
Good context engineering makes those distinctions explicit.
Context Security, Permissions and Trust Boundaries
An engineering agent may receive information from source files, issue descriptions, external documentation, build output and connected services.
Not all of that information should possess the authority to direct its actions.
An issue description may contain untrusted user input. A third-party document may include inappropriate instructions. A retrieved file may contain information outside the authorized scope of the task.
This creates a security problem that cannot be solved merely by improving the organization of project documentation.
OWASP’s guidance on prompt injection explains the risks associated with instructions embedded in retrieved content and recommends controls including privilege restriction, separation of untrusted content and validation of consequential tool actions [7].
For engineering systems, three distinctions are particularly important.
Access is not authorization. An agent’s ability to read a resource does not automatically authorize it to modify, disclose or transmit that resource.
Content is not necessarily instruction. Text retrieved from a source should not automatically receive the authority of an approved engineering policy.
Instructions are not enforcement. A repository document instructing an agent not to access production credentials does not provide the same protection as an execution environment in which those credentials are unavailable.
Context architecture must therefore be supported by appropriate technical controls.
These may include restricted credentials, isolated environments, approved tool permissions and explicit authorization for consequential actions.
Sensitive information should not be included in persistent context simply because it might be useful during some future task.
The objective is to provide sufficient information for legitimate engineering work without creating unnecessary exposure or authority.
Evaluating and Maintaining Context as an Engineering Asset
If context engineering is to become a dependable practice, its effectiveness must be evaluated.
A long and carefully written instruction file is not necessarily a valuable engineering artifact.
Its value depends on whether it helps agents and developers make better decisions, reduces avoidable errors or improves the efficiency of legitimate work.
An organization can investigate this through a small comparative evaluation.
Select representative engineering tasks with independently established acceptance conditions. Evaluate those tasks under different context configurations while keeping the model, available tools, task definitions and resource budgets as consistent as possible.
For example, a comparison could include:
| Configuration | Context strategy |
|---|---|
| A | Task description and repository access |
| B | Repository access with general project instructions |
| C | Repository access with concise, task-relevant structured context |
The comparison should examine more than successful test execution.
Relevant outcomes include requirement satisfaction, unnecessary modifications, preservation of existing behavior, verification coverage, human review effort, execution time and resource consumption.
Use the same starting repository revision for each configuration and a clean isolated environment for each run. Define the acceptance rubric in advance, keep assessment fixtures separate from the agent’s supplied context, and record model versions, execution limits, failures and review effort as well as successful outcomes. Repeated runs may be necessary because agent behavior varies. Compare like-for-like tasks and do not count repeated attempts as independent projects. A higher test pass rate cannot compensate silently for violating a required compatibility or authorization constraint.
A small internal evaluation would not establish universal effectiveness. It could nevertheless help a team determine whether its own context practices deserve further investment.
Maintaining the context lifecycle
Context should be maintained as the project changes.
When an architectural decision changes, the corresponding guidance should be updated. When a temporary restriction expires, it should be removed. When a verification command becomes obsolete, the maintained instruction should be corrected rather than supplemented with another contradictory instruction.
Recurring agent errors can also provide useful diagnostic information.
If agents repeatedly introduce a prohibited dependency, it may indicate unclear project guidance, weak environmental enforcement or inadequate review controls.
Adding another sentence to the instruction file is only one possible response.
The appropriate response depends on the cause.
Context maintenance is therefore not merely a writing activity. It involves knowledge governance, verification and the evaluation of engineering behavior.
Engineering Knowledge Must Be Designed for Both Humans and Agents
Software projects have always depended on knowledge that extends beyond source code.
Requirements explain intended behavior. Architectural decisions preserve reasoning. Documentation supports collaboration. Tests establish selected expectations. Operational records describe the system under real conditions.
AI-assisted engineering changes how that knowledge is consumed and increases the importance of its structure, authority and availability.
However, the emerging research does not support treating additional context as an automatic solution to agent limitations.
Relevant information may improve decisions. Irrelevant information may increase costs. Conflicting information may introduce errors. Accurate information may still fail to compensate for insufficient implementation capability.
The engineering responsibility is to understand those distinctions.
A useful context environment should make important knowledge discoverable, preserve its authority, limit unnecessary information and support independent evaluation of the work produced.
Its success should be judged by engineering outcomes rather than document length or the sophistication of its prompts.
The objective of context engineering is not to tell an agent everything about a project.
It is to ensure that the information necessary for appropriate engineering decisions is available, trustworthy and usable when those decisions must be made.
References
[1] AGENTS.md. A Simple, Open Format for Guiding Coding Agents. https://agents.md/
[2] Anthropic. Effective Context Engineering for AI Agents. 2025. https://www.anthropic.com/research/effective-context-engineering-for-ai-agents
[3] Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., and Liang, P. Lost in the Middle: How Language Models Use Long Contexts. Transactions of the Association for Computational Linguistics, 12, 157–173, 2024. https://doi.org/10.1162/tacl_a_00638
[4] Gloaguen, T., Mündler, N., Müller, M. N., Raychev, V., and Vechev, M. Evaluating AGENTS.md: Are Repository-Level Context Files Helpful for Coding Agents? ICLR Workshop on Memory for LLM-Based Agentic Systems, 2026. https://openreview.net/forum?id=pLi3A8bscP. Research laboratory record
[5] Khatri, P. Do Context Files Help Coding Agents? A Two-Agent Ablation Study on Real Repositories. Proceedings of the Second Workshop for REsearch on Agent Language Models (REALM), pp. 57–67, 2026. https://doi.org/10.18653/2026.realm-1.5. ACL Anthology
[6] Shanto, M. H., Islam, M. A., Asaduzzaman, M., and Ngom, A. Toward an Evidence-Based Template for Agent Instruction Files: An Empirical Study of Adoption, Consistency, and Maintenance. arXiv preprint, 2026. https://arxiv.org/abs/2611.02383
[7] OWASP. LLM Prompt Injection Prevention Cheat Sheet. https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html