Context Engineering. The only engineering that matters in the era of AI agents.
Context engineering, AI management, agent drift issues, the importance of structured data, impact on performance, solutions for startups
Research from Anthropic has shown that agent drift—where an AI gradually loses coherence during long-running tasks—is almost entirely a problem of context management rather than reasoning. Let's dive into what context engineering actually is.
Today, there are about 8,000 startups created via vibe-coding that are already in need of refactoring costing anywhere from 50,000 to 500,000 dollars. According to Forrester, 75% of technical leaders will face significant technical debt from AI-generated code by the end of the year.
The Prompt Engineering Trap
Prompt engineering teaches you how to ask better questions. Context engineering teaches you how to build better environments. The difference is fundamental.
A perfect prompt within a broken context still produces garbage. A mediocre prompt within a rich, structured context consistently delivers useful results.
The solutions have become:
- context compaction
- structured notes
- multi-agent architectures that manage what enters the window
What is context engineering?
Context engineering is the discipline of designing:
- which information reaches the model
- when it appears
- in what structure
This isn't prompt engineering, which is responsible for phrasing the query. It isn't fine-tuning, which modifies the model. It is the architecture between knowledge and the model's attention.
It consists of three layers:
- Selection: what enters the context window
- Architecture: how information is structured
- Lifecycle: when the context is updated
The reason is known: context pollution accumulates. One hallucinated fact in the window creates new hallucinations further down the chain.
As tasks grow, context management becomes the task itself. When the context degrades, everything else degrades.
Four modes of context failure
Virtually every AI error falls into one of these types.
Context Pollution
Outdated or hallucinated information enters the window. The model trusts its context. If there is an error there, the entire subsequent chain inherits it.
Context Distraction
Too much irrelevant information. A 200k token window doesn't help if 180k of it is noise. The model fails to distinguish between important and secondary details and distributes attention almost uniformly.
Context Confusion
Too many tools and instructions. MCP initially exacerbated this problem. If a system prompt contains 50 tool definitions, the model spends its attention on unnecessary tools instead of the task.
Context Clash
Contradictory instructions within a single window. For example, CLAUDE.md says to use pnpm, while README says to use npm.
The model begins to switch between them. This results in teams experiencing inconsistent agent behavior between sessions.
The Revolution of Encoded Context
Not everything should be in the window at once. The model should find the necessary information rather than receiving it all upfront.
Separation of concerns:
- system architecture
- code conventions
- domain knowledge
Each category is stored separately. The model only loads what is necessary for the current task.
project/
├── CLAUDE.md # architecture + boundaries
├── .claude/
│ └── memory/
│ ├── MEMORY.md # routing document (< 200 lines)
│ ├── patterns.md # confirmed conventions
│ ├── decisions.md # architectural choices with reasoning
│ └── debugging.md # solutions to recurring problems
├── docs/
│ ├── architecture.md # system design (the model's map)
│ └── domain/ # business logic the model needs
└── src/ # the actual code
Specialized agents with pre-loaded domain context make significantly fewer mistakes than general-purpose agents.
In more than half of effective agent specifications, the context occupied more space than the instructions.
Why is a knowledge graph better than flat files?
Flat context scales linearly. One new fact adds one unit of value. A knowledge graph scales combinatorially.
This is exactly what agents need to navigate a knowledge base. The core pattern involves:
- atomic notes: one concept per file
- wikilinks: connections expressed via link text
- maps of content: navigational documents
- metadata: filtering and depth levels
- prose-as-title: titles as statements
Context engineering for enterprises
Every company is already a graph. The only question is whether it is navigable. Organizational knowledge is usually scattered across:
- Slack threads
- dozens of versions of Google Docs
- abandoned Notion pages
- knowledge trapped in employees' heads
A company's knowledge graph:
company/
├── org/
│ ├── decisions/ # every decision with reasoning attached
│ ├── strategy/ # vision, positioning, open dilemmas
│ ├── competitors/ # competitive landscape
│ └── risks/ # threats with triggers and mitigations
├── teams/
│ ├── engineering/ # standards, architecture, runbooks
│ ├── marketing/ # campaigns, positioning, analytics
│ └── sales/ # playbooks, objections, win-loss
├── projects/
│ ├── product-alpha/
│ │ ├── prd/ # product spec as a graph of claims
│ │ ├── features/ # backlog → shipped lifecycle
│ │ ├── repo/ # the actual codebase
│ │ └── decisions/ # architectural choices
│ └── product-beta/
├── research/ # deep domain knowledge
├── transcripts/ # mined meeting conversations
└── CLAUDE.md # teaches the agent how your company works
A self-improving context system
All wikis and knowledge bases died for one reason: no one maintained them. People forgot to update documentation. Agents, however, do not get tired of maintenance.
In a well-structured graph, an agent can:
- notice contradictions between notes
- find discrepancies between specification and code
- accumating friction signals
- propose architectural changes
In effect, the agent begins to refactor its own instructions. Context engineering is not a one-time setup. It is a living system that improves every time the agent works.
Practical Checklist
If there is one idea to take away from this article, it is simple:
- Audit your CLAUDE.md. Is it a configuration file or a training document? Rewrite it as an onboarding guide for a senior engineer.
- Separate your context: architecture, code conventions, and domain knowledge should be stored separately.
- Implement progressive disclosure. MEMORY.md should be a navigational document of no more than 200 lines.
- Use statements as filenames. A filename should answer the question, "Do I need to read this?"
- Extract knowledge from meetings. Record discussions, extract decisions, and add them to the knowledge graph.
- Let the agent maintain the system. Set up checks for contradictions, outdated context, and structural drift.
- Measure context health. Track metrics: re-explanation frequency, agent drift levels, and decision consistency between sessions. If an agent asks the same question twice, there is a hole in your context architecture.
If you are interested in AI, technology, and the future—welcome to my channel to discuss and share updates.
Translated from Russian. Original on vc.ru: Инженерия контекста. Единственная инженерия, которая имеет значение в эпоху ИИ агентов.