Side-by-Side Comparison
| Prompt Engineering | Context Engineering | |
|---|---|---|
| Unit of work | One prompt or system prompt | The full context at every step of a task |
| Main question | How do I phrase the instruction? | What should the model see right now, and what should it not see? |
| Typical scope | Chat, one-shot generation | Agents, multi-turn assistants, RAG systems |
| Key techniques | Frameworks like CO-STAR, RISEN, Few-Shot, Chain-of-Thought | Retrieval, tool design, history compaction, memory notes, sub-agents |
| Main failure mode | Ambiguous or incomplete instructions | Too much, stale or irrelevant context ("context rot") |
| Who uses it | Everyone who writes prompts | Teams building LLM applications and agents |
Where the Term Came From
In mid-2025 Andrej Karpathy publicly backed "context engineering" over "prompt engineering", arguing that people associate prompts with short task descriptions, while real LLM applications depend on carefully filling the context window. In September 2025 Anthropic published Effective context engineering for AI agents, describing it as curating and maintaining the optimal set of tokens during inference.
Core Context Engineering Techniques
- System prompts at the right altitude: specific enough to guide behaviour, general enough not to become brittle if-then rules.
- Tool design: few, clearly scoped tools with unambiguous descriptions, so the model knows when to use which.
- Just-in-time retrieval: keep references (file paths, IDs, links) in context and load the content only when needed, instead of stuffing everything in upfront.
- Compaction: when a long task nears the context limit, summarise the history and continue from the summary.
- Structured note-taking: let the agent write notes or to-do files outside the context window and read them back later.
- Sub-agents: hand focused sub-tasks to agents with clean contexts that return short summaries.
How Prompt Frameworks Fit In
Context engineering does not make prompt frameworks obsolete. They are the building blocks of the instructions inside the context:
- CO-STAR or RISEN for writing a clear, compact system prompt.
- Role Prompting for a one-line identity that sets the agent's expertise.
- ReAct for the reason, act, observe loop that tool-using agents follow.
- Prompt Chaining and Least-to-Most for splitting work into focused steps with small contexts.
- Reflexion for turning failures into short, persistent lessons instead of long transcripts.
- Few-Shot with a small set of diverse, canonical examples rather than a long list of edge cases.
Practical Checklist
- Can every sentence in the system prompt be traced to a behaviour you need?
- Does each tool have a clear, non-overlapping purpose?
- Is retrieved content loaded only when the current step needs it?
- Do long tasks have a compaction or note-taking strategy?
- Are reusable instructions saved as templates, so every run starts from the same tested context?
Frequently Asked Questions
What is context engineering?
Context engineering is the practice of deciding everything that goes into a model's context window at each step: system prompt, tool definitions, retrieved documents, conversation history, memory and examples. Anthropic describes it as curating and maintaining the optimal set of tokens during inference. It matters most for agents that run over many turns.
Is context engineering replacing prompt engineering?
No, it contains it. Writing clear instructions (prompt engineering) is still the core of any system prompt. Context engineering adds the surrounding decisions: what to retrieve, what history to keep or summarise, which tools to expose and how to keep the context small enough to stay reliable.
Who coined the term context engineering?
The term spread in mid-2025, notably after Andrej Karpathy endorsed 'context engineering' over 'prompt engineering' for industrial LLM apps, describing it as the art and science of filling the context window with just the right information. Anthropic published a detailed engineering guide on it in September 2025.
What is context rot?
Context rot is the observation that a model's ability to recall and use information declines as the context window fills up. It is why more context is not automatically better, and why techniques like just-in-time retrieval, compaction and sub-agents exist.
Which prompt frameworks are most relevant to context engineering?
Agent and workflow techniques: ReAct for tool use, Prompt Chaining for splitting work across focused calls, Reflexion for persistent lessons, and Role Prompting for concise system prompts. Structured frameworks like CO-STAR or RISEN remain useful for writing the system prompt itself.