← ~/pillars / context-engineering / guide
Context engineering
What the agent sees decides what it does: CLAUDE.md and memory architecture, context-friendly repos, AI-legible docs, and the compaction discipline that keeps long sessions sharp.
updated 2026-07-05 ~3 min read
← back to context-engineering/
on this page
An agent’s output quality is bounded by what is in its context window at the moment it acts. Not by what is in your repo, your wiki, or your head, but by what is in the window. Anthropic frames the shift directly: prompt engineering was about writing a good instruction; context engineering is about curating “the smallest possible set of high-signal tokens” across everything the model sees: instructions, memory files, retrieved docs, tool results, and history (effective context engineering). Context is an engineered artifact. Treating it as an accident is the single most common reason capable models do mediocre work.
This pillar covers the supply side of that engineering: what you put in front of the agent, where it lives, and how it survives a long session. The demand side, forcing behaviour the model cannot forget, is enforcement, and it lives in the deterministic guardrails pillar.
The organising question
For every piece of guidance you want an agent to follow, ask: could a tool verify this without reading my mind? If yes (formatting, import order, naming patterns, layer boundaries), it does not belong in context at all; it belongs in a linter, enforced by a hook and CI. Prompt-space instructions achieve roughly 70–90% compliance under context pressure, while hooks achieve 100% because they execute outside the model’s reasoning chain (dotzlaw). Our own benchmark matrices were more precise about when that gap opens: on short, low-pressure tasks a frontier model followed written rules 100% of the time with no enforcement at all. The drift is a session-pressure phenomenon, not a property of prose itself (interpretation). A mechanical rule written in prose is still a double waste: it pays tokens every turn for a guarantee that holds only until the window fills.
What remains after that filter is judgment (when to refactor, which injection style, why the migration policy exists), and judgment is exactly what context is for. CLAUDE.md is loaded every session, and Anthropic recommends keeping each file under 200 lines because longer files consume more context and reduce adherence (best practices). Every line must earn its place.
Context is spent, not stored
The window fills, and performance degrades as it fills: attention gets thinner as the token count grows, which is why “just add more context” makes agents worse, not better (effective context engineering). Three consequences shape everything in this pillar:
- Always-on content is the most expensive real estate you own. CLAUDE.md, memory files, and skill listings load every session (memory docs). They should carry only what is true every session: commands, boundaries, judgment calls.
- Everything else should arrive just in time. Skills load on demand, MCP tool schemas defer until needed, and a repo the agent can navigate beats a repo dump. Retrieval at the moment of need keeps signal density high.
- Long sessions need an externalisation strategy. Compaction summarises history and loses detail (how Claude Code works); what must survive belongs in files (notes, plans, handoff documents), not in the conversation.
Applied to Java on AWS
The Spring Boot service CLAUDE.md and the monorepo root file apply this pillar to a Java estate. Java teams are unusually well served by the enforcement side of the boundary: the ecosystem has a deterministic tool for almost every mechanical rule class (Spotless, Checkstyle, Error Prone, ArchUnit), which means their CLAUDE.md files can stay short and purely judgment-focused. The linters as ground truth pattern shows the moving-out; this pillar governs what remains.