Building with Claude
Context engineering: giving models what they need to reason
Context engineering is the craft of deciding what an AI model sees at the moment it responds. It is how you move from a clever prompt to a system that stays accurate, grounded, and reliable at scale.
Definition
What context engineering is
A language model only knows what is in front of it. On every call it reads a window of text, then writes a response. Context engineering is the practice of curating that window: choosing which instructions, documents, examples, and tools to include, and arranging them so the model has what it needs and little that gets in the way.
It is broader than prompt engineering. Wording a single instruction well matters, but a production system is built from many moving parts: a system prompt, retrieved knowledge, prior turns of a conversation, tool definitions, and the shape of the expected output. Context engineering is the design of that whole payload, on every request. When people describe building reliable AI agents, most of the hard work turns out to be context engineering.
The goal is not to cram in as much as possible. A context window is a fixed budget of tokens, and information that is irrelevant competes with information that matters. Good context engineering is closer to editing than to writing: keep what is useful, order it clearly, and leave the rest out.
Core techniques
The building blocks of context engineering
Four techniques do most of the work. They are usually combined rather than used alone.
Structuring the prompt
Separate the durable instructions (role, task, rules, output format) from the variable input for this request. Clear sections, headings, and a stated output shape help the model tell instructions apart from data, which reduces errors and drift.
Retrieval
Instead of hoping the answer is in the model's training data, fetch the relevant documents at request time and place them in the window. Retrieval keeps responses grounded in your own sources, and it is how a general model answers questions about specific, current, or private information.
Managing the context window
The window is finite, so decide what earns a place in it. Summarise long histories, drop stale turns, chunk large documents and include only the relevant parts, and track the token budget. A focused window usually beats a full one.
Tool and context provisioning
Give the model tools it can call (search, code execution, database queries) and a clear description of each. The model then pulls in fresh context on demand rather than relying only on what you packed in advance. Tool use turns a static prompt into a system that can act.
Applied to Claude
Context engineering when you build with Claude
These techniques map directly onto the Claude Developer Platform. Here is where each one lives when you are building.
System prompts
Claude accepts a dedicated system prompt for the durable instructions, kept separate from the user's message for the turn. It is the natural home for the structuring work: role, rules, and output format.
Tool use
You can define tools that Claude may call during a response, describing each tool's inputs so Claude decides when to reach for it. This is how you provision live context and let Claude take actions rather than only answer.
The Model Context Protocol
The Model Context Protocol is an open standard for connecting AI applications to external data sources and tools through a common interface, so retrieval and tool provisioning are wired in once and reused.
Agent Skills
With agent skills you package instructions and resources that Claude can load when a task calls for them, a practical way to keep the working context focused instead of front-loading everything.
The through-line is the same one context engineering starts from: assemble the right information for each request. Structured system prompts handle the instructions, retrieval and tools bring in what is relevant, and standards like the Model Context Protocol keep that plumbing consistent across an application. The developer documentation covers the details of each.
FAQ
Common questions about context engineering
What is context engineering?
Context engineering is the practice of deciding what information an AI model sees at inference time, and how that information is arranged. It covers the system prompt, retrieved documents, tool definitions, prior turns, and the output format, all assembled to fit within the model's context window so the model has what it needs and little that distracts it.
How is it different from prompt engineering?
Prompt engineering is mostly about wording a single instruction well. Context engineering is broader: it is the design of the whole information payload the model receives on every call, including retrieval, tools, memory, and formatting. Prompt engineering is one part of context engineering.
What is a context window?
The context window is the maximum amount of text, measured in tokens, that a model can consider at once. Everything the model reads and writes on a single call, the prompt plus its response, must fit inside it. Managing the window means fitting the most relevant information into that budget.
What are the core techniques?
The main techniques are structuring the prompt clearly, retrieving only the relevant information, managing the context window so it stays focused, and provisioning tools and external context the model can call. Used together, they keep the model grounded in accurate, relevant information.
How does it apply to Claude?
When you build with Claude, context engineering is how you assemble the system prompt, documents, and tools for each request. Claude supports structured system prompts, tool use, and the Model Context Protocol for connecting external data and tools, so the same principles map directly onto the Claude Developer Platform.
Start engineering context with Claude
The developer documentation walks through system prompts, tool use, and the Model Context Protocol, with working examples.
Read the developer docs Build with Claude