Prompt engineering vs context engineering
Prompt engineering crafts the instructions; context engineering builds the systems that decide what information fills the model's window at runtime.
In plain terms
A prompt engineer writes a great briefing document. A context engineer builds the mailroom that decides which files even land on the desk: which documents get retrieved, how much history is kept, which tool results are included, what gets summarized away. As apps grow, the mailroom matters more than the briefing.
Why it matters
In real systems the prompt template is 5% of the tokens; retrieved documents, conversation history and tool outputs are the other 95%. Quality problems increasingly come from wrong/missing/stale context, not wrong instruction wording - so the discipline expanded and got a new name.
How it works
Context engineering decisions: what to retrieve (-> RAG), how much history to keep vs summarize (-> memory), which tool outputs to keep in the window vs store elsewhere, what order things appear in (-> caching, lost-in-the-middle), and per-request token budgets for each component.
When you use it
The moment your app has dynamic inputs - retrieval, multi-turn memory, tools. Pure prompt wording stops explaining your failures around then.
Common mistakes
- Endlessly re-wording the prompt when the real problem is the retriever fetched the wrong document.
- No token budget per component, so history slowly starves out the retrieved facts.
- Treating the two as rivals - you need both; they operate at different layers.
Best practices
- When output is wrong, first print the FULL assembled context and ask 'could a human answer correctly from this?' - that one habit localizes most bugs.
- Give each context component (system, docs, history, tools) an explicit token budget.
Try it yourself
Take any RAG or chat app (yours or a tutorial's) and log the complete assembled prompt for 5 requests. Count what fraction is instructions vs dynamic context. That ratio explains where your bugs will live.
Resources
- Anthropic - Effective context engineering for AI agents How practitioners think about the window as a resource.