Architecture Map
The Claude Context Stack
A layered map of the information Claude can receive: instructions, examples, tools, retrieval, memory, history, and outputs.
"Claude responds well to clear, explicit instructions."
Source: Prompting best practices, Claude Platform Docs.
Layer 1: Purpose and success criteria
Before adding documents or tools, define the decision Claude is supposed to make. A task like "review this PR" needs different context from "write a release note" even if both involve the same repository. Purpose decides which facts are relevant and which facts are distraction.
Write success criteria in operational terms: expected output, audience, constraints, allowed actions, and evidence standard. This reduces the temptation to load every available source "just in case."
Layer 2: System and developer instructions
System and developer instructions define behavior. For Claude, keep them specific enough to guide decisions but not so procedural that they become brittle. Anthropic recommends sectioning prompts when they mix background, instructions, examples, and output requirements.
The altitude matters. "Be helpful" is too vague for a production agent. A 400-line decision tree can be too brittle. The useful middle is a small set of durable rules, clear boundaries, and examples that represent real work.
Layer 3: Examples and rubrics
Examples are high-leverage context because they show the intended shape of the answer. Use a few canonical examples that cover real edge cases. Avoid turning examples into a dump of every previous failure.
For review, evaluation, support, or extraction tasks, a compact rubric often beats more prose. The rubric tells Claude how to rank evidence and when to say that the answer is unknown.
Layer 4: Source material
Source material includes files, docs, transcripts, API responses, database rows, screenshots, or research notes. It can be loaded directly, retrieved just in time, represented as MCP resources, or summarized into a source packet. The right shape depends on how often it changes and how precise the answer must be.
The best source packet is not the longest one. It contains provenance, timestamp, relevance, and enough surrounding context for Claude to avoid quote-mining a single line.
Layer 5: Tools and MCP servers
Tools expand what Claude can do, but every tool definition is context. Bloated, overlapping tools increase decision cost. MCP servers add another routing layer: resources expose context, tools execute actions, and prompts can standardize workflows.
Audit tools by asking whether a human engineer could pick the right one from the name, description, and schema alone. If not, Claude is likely to hesitate, misuse a tool, or waste turns exploring.
Layer 6: Memory and durable notes
Memory is not the same as the current context window. It is external state that can be loaded back into context. Claude Code uses `CLAUDE.md` and auto memory for project and preference continuity; API agents may use a memory tool or their own file-backed notes.
Treat memory as an index and policy surface, not a pile of transcripts. If the memory itself grows without pruning, it becomes another context problem.
Layer 7: Conversation history and generated output
Conversation history is easy to underestimate because it accumulates silently. A long chat can contain early assumptions, outdated plans, huge tool results, and partial conclusions. Compaction and clearing are ways to turn raw history back into useful working state.
FAQ
What is the first layer to fix when Claude fails?
Start with the smallest layer that explains the failure. If the fact was absent, fix source retrieval. If the action was unclear, fix instructions. If history is noisy, compact or clear it.
Should tools be part of context engineering?
Yes. Tool names, descriptions, schemas, and results shape what Claude can infer and decide during a task.
Sources Used
- Effective context engineering for AI agents, Anthropic Engineering. Accessed 2026-07-06. Primary explanation of context engineering, context pollution, compaction, note-taking, and sub-agent architectures.
- Prompting best practices, Claude Platform Docs. Accessed 2026-07-06. Official guidance on clear instructions, examples, XML sections, long-context prompting, and tool-use prompting.
- Claude Code settings, Claude Code Docs. Accessed 2026-07-06. Configuration categories, including memory files, settings, skills, MCP servers, and precedence.
- Resources, Model Context Protocol Specification. Accessed 2026-07-06. Protocol definition for resources, resource templates, subscriptions, contents, and annotations.
Cite this page
Suggested citation: Claude Context, "The Claude Context Stack," updated 2026-07-06, https://claudecontext-com.pages.dev/context-stack/.
This page is an independent educational resource and is not affiliated with Anthropic.