What is the difference between context engineering and prompt engineering?
Prompt engineering is the craft of wording a single instruction well; context engineering is the craft of controlling the entire payload the model reads around that instruction — the system prompt, the conversation history, every retrieved file, all the tool definitions, and every line of command output. The first is a sentence. The second is everything the model sees when it processes that sentence. For a one-shot chat the two nearly collapse into each other. For an autonomous coding agent that loops across dozens of turns, they could not be more different, and the gap is where most of your bill and most of your bad answers come from. I spend my days building tooling that shrinks what coding agents read, so I have a strong opinion here, and I'll state it up front: prompt engineering is a solved-enough problem for coding work, and context engineering is the one that still leaves money and accuracy on the table. If you want the full discipline, I wrote a deeper piece on context engineering for AI coding agents; this article is narrower — it's about why you should stop fiddling with phrasing and start managing the payload.Why does prompt engineering matter less for coding agents?
Prompt engineering matters less for coding agents because the instruction is rarely the thing that fails — the surrounding context is. When you ask "fix the auth bug", the model usually understands you perfectly. What determines whether it succeeds is whether the three relevant functions made it into the context window and whether they were drowned out by 4,000 lines of unrelated code the agent read "to be safe". There's a second reason, and it's the unglamorous one: modern models are good at instruction-following. The marginal return on rephrasing "please be concise" for the fifth time rounds to zero. Meanwhile the agent just opened a 600-line file to use two functions, re-sent your entireCLAUDE.md for the eighth turn in a row, and loaded nine MCP tool schemas it will never call. None of that is a prompt problem. All of it is a context problem.
That doesn't mean prompts are worthless. A sharp system prompt and clear task framing still help. But once you've written a decent instruction, you hit diminishing returns fast — and every hour past that point spent polishing wording is an hour not spent on the lever that actually moves cost and quality.
Why is context the real cost and accuracy lever?
Context is the real lever because cost scales with how many tokens you push through the model, and accuracy degrades when those tokens are mostly noise. Both effects are about volume and shape, not about how clever your instruction reads. Cost scales with the payload, not the phrasing. On Claude Sonnet 4.6, a million input tokens runs $3; on Claude Opus 4.8, $5 in / $25 out per MTok; GPT-5.5 sits at $5 in / $30 out (Anthropic pricing, 2026; OpenAI pricing, 2026). A multi-step agent session re-sends its growing transcript every turn, so the input side dominates the bill. Trimming what the agent reads is the most direct cost reduction available — far more than any prompt tweak. I broke the mechanics down in how to reduce AI coding agent token usage. Accuracy degrades in a stuffed window. Liu et al. ("Lost in the Middle", 2023 — arxiv.org/abs/2307.03172) showed retrieval accuracy drops sharply for facts placed in the middle of a long context. So an over-stuffed window doesn't just cost more — it actively hides the information the model needs. A perfectly worded prompt can't rescue a payload where the relevant function sits buried at position 40,000 of 90,000 tokens. The agent builds the payload, you usually don't. This is the part people miss. In a chat, you control the input. In an agentic session, the agent decides what to read, which tools to call, and what stays in the transcript — and its defaults lean toward over-reading, because opening a whole file feels safer than opening nothing. Prompt engineering can't reach those decisions. Context engineering is precisely the act of shaping them. If the term "agent decides what to read" is new to you, my piece on agentic coding covers how that loop works.How do they compare, side by side?
Here is the contrast in one table:| Dimension | Prompt engineering | Context engineering |
|---|---|---|
| Scope | One instruction | The whole payload, every turn |
| What it changes | Wording | Which files, tools, history are present |
| Cost impact | Marginal | Direct — scales with token volume |
| Accuracy impact | Helps once, then flat | Removes noise that hides signal |
| Who's in control | You (a chat); the agent (a session) | You, if you shape the agent's defaults |
| Ceiling | Hit quickly | The main remaining lever |
How do you do context engineering today?
You do context engineering by controlling four things the agent would otherwise inflate on its own. None of these require a model upgrade or a clever prompt:- Retrieve, don't dump. Instead of letting the agent read whole files to find a symbol, use semantic code search to surface only the relevant spans. This is the single biggest win in most codebases — see semantic search vs grep if you want the comparison.
- Filter tool output. Build logs, test runners, and
gitcommands emit thousands of tokens of which maybe twenty matter. Output filtering keeps the signal and drops the rest before it ever lands in the transcript. - Read structure before bodies. Skeleton compression hands the model the shape of a file — signatures, classes, exports — instead of every line. The agent reads the body only when it actually needs it, a form of context compression.
- Load tools lazily. Every MCP server you connect injects its tool schemas into the window, every turn, whether you call them or not. Lazy MCP loading defers that cost until a tool is actually invoked. (Worth auditing your setup — the best MCP servers for Claude Code is a reasonable starting list.)
What goes wrong (anti-patterns)?
The failure modes are predictable once you've watched enough sessions:- Polishing the prompt while ignoring the payload. The classic. You spend an afternoon perfecting your system prompt, the agent still reads a 600-line file for two functions, and you wonder why the bill didn't move. You optimized the cheap lever and left the expensive one untouched.
- Treating a bigger context window as a feature. A 1M-token window is permission to be lazy, not a reason to stuff it. Bigger windows make the "lost in the middle" problem worse, not better, and you pay for every token whether the model reads it carefully or not.
- Assuming caching saves you by default. Prompt caching helps — cache reads run roughly 10% of the input price — but only for the prefix that stays byte-identical across turns. Append-and-grow transcripts and reshuffled context break the cache constantly. Caching rewards a stable, well-engineered context; it can't rescue a chaotic one.
- Connecting every MCP server "just in case". Each one taxes every turn. If you're not calling it, it's pure overhead. Audit ruthlessly.
- Confusing fewer tokens with worse answers. The instinct that "more context = safer" is wrong above the relevance threshold. Removing noise raises the signal-to-noise ratio; you usually get better answers and a smaller bill at the same time.
See also:
- Context engineering for AI coding agents — the full discipline
- How to reduce AI coding agent token usage — the six practical levers
- Reduce Claude Code token usage — applied to one agent
- LLM token cost calculator — put a number on your own context
Ranked #1 on the Token-Harness Optimizer Leaderboard.
Tokenade ranks #1 in the Token-Harness Optimizer Leaderboard — an end-to-end benchmark of agent token optimizers measured on real coding sessions. Set it up once, it works on every prompt. Works with Claude Code, Cursor, Codex, Copilot & more.