Context engineering: what goes around the prompt
Guide
4 min
- Plain English
The short answer
Context engineering is deciding what the model sees before it answers, from 5 kinds of input: instructions, examples, retrieved facts, conversation history and tool output. A prompt's just one part of that. The goal is the smallest set of information that makes the right answer likely. Too little causes guesses, and too much buries the point.

What does context engineering mean?
Context engineering means choosing everything the model reads on a turn, so the smallest set of information makes the right answer likely. It's about selection over wording, and it isn't only for developers. The context window is everything the model can read on a turn, and it has a size limit: your message, the system prompt, earlier turns, files, tool results and anything retrieved from search all share it.
Anthropic describes the job as curating and maintaining the best set of tokens during inference; its post Effective context engineering for AI agents is the clearest source.
The working rule is the smallest useful set: give the model only what it needs for this step, since every extra page is one more thing it can misread.
How is context engineering different from prompt engineering?
Context engineering is different from prompt engineering in scope: prompt engineering words one instruction, and context engineering picks every input around it. A well-worded prompt can still fail when the material around it is missing a key fact or full of noise, and that's usually where the fix starts. You can't word your way out of a missing fact.
The wording skill comes first, so readers new to this can start with prompt engineering examples and come back.
What goes in the context window, layer by layer?
The context window holds 5 layers: instructions, examples, retrieved facts, conversation history and tool output, and each one has a keep and a cut rule. The instruction layer is the easiest to get right first: write it once as a system prompt and every turn starts from the same rules, so you won't repeat them.
| Layer | Put in | Leave out |
|---|---|---|
| Instructions | The job, the rules, the output format | Rules the task never touches |
| Examples | 3 to 5 varied samples of the right output (2 can do for a simple format) | Ten near-identical samples |
| Retrieved facts | Only the passages that bear on this question | Whole documents "just in case" |
| Conversation history | Decisions already made, the current state | Dead ends and chit-chat |
| Tool output | The few tools and results this step needs | Every tool you own |
The before and after on this page runs the same task twice: once with a pasted 40-page file, once with only the refund clause, labelled and fenced by a rule for gaps. The two worked prompts audit what you're about to paste and compress a long chat into a clean thread.
What should a context engineering checklist cover before you send?
A context engineering checklist covers 5 checks: task placement, relevant facts, labelled sources, a rule for gaps and a fresh start for old chats.
- Task placement. State the task once, near the end. For long inputs, Anthropic and Google both advise putting the documents first and the question last.
- Relevant facts. Every fact in the context should be one the answer needs; cut what's left over.
- Labelled sources. Wrap each document in a tag or heading so the model can tell material from instructions.
- A rule for gaps. "Say so when it isn't in the material" beats a confident guess.
- A fresh start. After a long chat, open a new one with a short summary of what's settled; the iterative prompting guide shows the state card that makes this safe.
Why does context drift in long chats?
Context drifts in long chats as early instructions compete with later text, so the model misses or contradicts details. Models don't forget on purpose, and they aren't broken; the early rules just carry less weight among thousands of later words.
The fix isn't a longer prompt, and it won't help to shout. It's a shorter, current one: restate the goal, list the decisions so far, paste only the material still in play, and start a new thread. Splitting multi-step work into stages, such as research, drafting and review, keeps each stage's context small, which is the idea behind prompt chaining.
Context engineering before and after
The same request, asked two ways. Read the second one slowly. Each line does a job.
Here are all our company docs (pasted, 40 pages). Answer the customer's question: can I get a refund after 30 days?
Answer the customer question using only the policy text between the tags. If the policy doesn't cover it, say "not covered" and stop. <policy> Refunds: full refund within 30 days of purchase. After 30 days, store credit only, within 90 days. </policy> <question>Can I get a refund after 30 days?</question>
Why it works
The after version includes just the clause that matters, labels it, and gives a rule for gaps. Forty pages of noise are gone.
Context engineering examples
Audit what you're about to paste
It turns "how much should I paste?" into a sort-and-justify task.
I'm about to send you a prompt with this context. Help me cut it down without losing what matters. My task: {{task}} The context I plan to include: {{context}} Sort every item into three lists: Keep (the answer needs it), Trim (keep only the relevant part, and say which part), and Cut (doesn't affect the answer). Give a one-line reason for each. Then write the final trimmed context, with each source wrapped in its own tag. Flag anything missing that you'd need and I haven't included.
How to use
- Copy it with the button above.
- Fill the blanks in {{double braces}} with your own details.
- Paste it into ChatGPT, Claude or Gemini and send it.
- Then follow up: ask for one change at a time.
Before you run “Audit what you're about to paste” for the first time, the lesson on how to use AI prompts step by step walks through copying, filling and sending it.
Carry a long chat into a clean thread
A fixed set of headings forces the summary to keep state, not just tell the story.
Summarise our conversation so I can start a fresh chat without losing anything important. Use exactly these headings:
Goal: one sentence.
Decisions made: bullets, each with the reason.
Still open: bullets.
Facts and numbers to keep: bullets, copied exactly.
Draft so far: only if one exists, pasted in full.
Keep it under {{words}} words. Don't add anything we didn't say. If two earlier messages conflict, list both and mark the conflict.
If this is a new chat with nothing to summarise yet, say so in one line and stop.How to use
- Copy it with the button above.
- Fill the blanks in {{double braces}} with your own details.
- Send “Carry a long chat into a clean thread” in the same chat as your draft or earlier answer, not a new chat.
- Then check that only what you asked for changed.
When is context engineering worth the effort?
Context engineering is worth the effort in 4 cases: anything that runs more than once, documents or tools, long projects and agents. That's where wrong or bloated context causes real failures, and they're hard to spot.
A one-off question that needs no outside material doesn't need it; a clear sentence is enough. Developers wiring this into an app will find the code side in coding prompt engineering, and anyone still fuzzy on the basic unit can read the definition of an AI prompt first. More context isn't better context: unrelated text can make answers worse, not safer.
Context engineering FAQ
Still stuck? Build it in Prompt Studio. It'll score each part as you go.
What is an example of context engineering in a chat app?
An example of context engineering in a chat app is pasting only the two relevant contract clauses, labelled, instead of the whole 40-page file. The 40 pages are an illustration, not a statistic: the point is that the model reads what you give it, so give it what the question needs.
What does a context engineer do?
A context engineer designs what an AI system reads on each turn: instructions, retrieved documents, memory and tool results. The label is loose and mostly found in teams building agents or assistants.
Does more context always give better answers?
No, more context doesn't always give better answers; too much buries the point and too little causes guesses. Aim for the smallest set that makes the right answer likely.
Is context engineering only for developers?
No, context engineering isn't only for developers; choosing what to paste into a chat is the same skill. You're doing it every time you decide what to include and what to leave out.