Context engineering is the practice of choosing what information an AI model sees. Learn how it differs from prompt engineering, and its main parts.

On this page
Summary
Context engineering is the practice of deciding what information an AI model sees before it writes a response, including instructions, retrieved documents, tool outputs and earlier messages, so the model gets the right information at the right size for the task at hand.
Want to go further? Ask
Context engineering is the work of building everything an AI model reads before it answers, not only the question you type. A model answers from its context window, the text it can use at one time. If the right facts are missing from that window, or the window is full of noise, the answer gets worse, even when the question is well written. Context engineering is the discipline that fixes this. It matters most for people who build AI agents, and for anyone who wants AI answers that are accurate and useful.
Context engineering is broader than prompt engineering. Prompt engineering is about how you word one request, such as the role you give the model, the examples you include and the format you ask for. Context engineering asks a different question: what information does the model need access to right now? In a comparison of the two, Elastic says that prompt engineering focuses on how you communicate with the model, while context engineering covers the information that reaches it. Anthropic's engineering article goes further and calls context engineering the natural progression of prompt engineering. It also notes that writing a prompt is a single task, while context engineering repeats each time you decide what to pass to the model.
Prompt engineering vs context engineering
Source: Anthropic, Effective context engineering for AI agents
In short, prompt engineering shapes the request, and context engineering shapes everything around it. You still need a clear prompt. But a clear prompt with the wrong documents still gives a wrong answer. For a method on writing the prompt itself, read how to write AI prompts that get useful answers, then come back here for the information side. The prompt engineering entry covers the wording side in more detail.
The context of an AI model is the full set of tokens it reads for one answer. Tokens are small pieces of text, often part of a word, so a token count is never the same as a word count. The Anthropic documentation on context windows says that everything in a request counts toward the window: the system prompt, every message, tool results, documents and tool definitions. Five parts make up most contexts.

Each part competes for the same space. A long history can push out a document that the answer needs. This is why context engineering treats the window as a budget: you decide which parts earn their place, and you remove the rest.
Context engineering uses a small set of techniques to keep the right information in front of the model. The most common one is retrieval. The system searches your content for passages that match the question and adds only those. Most retrieval steps compare embeddings, numeric representations of meaning, to find the closest text. Teams often store approved facts in a knowledge base so that retrieval has a clean source to search.
Other techniques are less visible. Anthropic's engineering article lists token-efficient tools, structured notes saved outside the window, and sub-agents that do a focused job and return a short summary. It also describes just-in-time retrieval, where an agent loads data only when it needs it. Tools reach the model through standards such as the Model Context Protocol, which defines how a model connects to outside data.
In practice, a context pipeline often looks like this:
context = system_instructions
context += retrieve_documents(question) # retrieval step
context += tool_results
context += recent_messages[-10:] # keep only the latest turns
context += question
answer = model.generate(context)
Tip
Start with the smallest context that can answer the question. Add more only when the answer is wrong or incomplete. Extra text takes space, and it can make the answer worse.
You keep the context window from filling up by removing what the next step does not need. Long conversations and agent runs grow fast, and every extra token takes space. Anthropic's documentation makes a clear point here: more context is not automatically better. As token count grows, accuracy and recall degrade, a phenomenon the documentation calls context rot.

The common fixes are simple. Summarize old turns once they are no longer needed. Clear tool results after the agent has used them. Load documents only when the task reaches the step that needs them. Some current Claude models accept up to 1M tokens in one window, according to the same documentation, but a large window only gives you room. It does not decide what matters.
Context engineering matters most when a task has several steps, uses tools or depends on facts that change. A single question with a short, complete prompt needs very little of it. An AI agent for customer support that reads your product pages, checks an order and drafts a reply needs a lot. The more steps and sources a task has, the more the choice of context decides the result.
It also matters when the facts are missing. If the model does not see the right information, it may guess, and a guess presented as fact is one form of AI hallucination. Giving the model the source text, and asking it to answer only from that text, is often the most direct fix.
For SEO and GEO, the context an AI model reads decides whether it can use your page at all. A page that states its answer early, is dated, and stays on one topic gives the model a clean passage to retrieve. A page that buries the answer under unrelated text is harder to pull out of a long context. For a checklist on this, see how to structure pages so AI can cite them. Write each section so it still makes sense if a model reads it alone.
Sorank applies the same idea to SEO. The SEO Chat bases its answers on a description of your business, your keyword plan and your search metrics, so its advice starts from your situation instead of a general guess.
Context engineering is the practice of choosing what an AI model sees before it answers. Prompt engineering still matters, but it is one part of the context. Start with the smallest context that works, add retrieved facts and tools as the task needs them, and remove what the next step does not use.
Sources
Prompt engineering is about how you word one request. Context engineering is about which information the model can see when it answers. Anthropic describes context engineering as the natural progression of prompt engineering.
The context includes the system instructions, retrieved documents, tool outputs, conversation history and examples. Everything in a request counts toward the context window, including tool definitions.
Not automatically. Anthropic's documentation says that as token count grows, accuracy and recall degrade, a phenomenon it calls context rot. What you put in the window matters as much as how much space it has.
