Context Engineering — The Skill That Replaced Prompt Engineering
## what it does
What is Context Engineering?
Context engineering is the practice of curating the full set of tokens a model sees at inference time — not just the prompt, but system instructions, retrieved documents, tool definitions, conversation history, and project structure. Anthropic’s effective context engineering post frames it as the natural progression of prompt engineering: less about finding the right words, more about “what configuration of context is most likely to generate the desired behavior.”
While prompt engineering focuses on how you ask, context engineering focuses on what the AI knows when it answers. Persistence across sessions is agent memory, not a bigger prompt.
Why Prompt Engineering Isn’t Enough
Clever prompting tricks — “act as a senior developer,” “think step by step” — still help, but they’re table stakes now. The differentiator is context, because of a hard constraint: context rot. As token count grows, a model’s ability to recall and use information from the window degrades. Attention is a finite budget. Every token you add costs some of it.
The goal, per Anthropic: find the smallest possible set of high-signal tokens that maximizes the chance of the outcome you want. Bigger context windows don’t remove this problem — they postpone it.
| Prompt Engineering | Context Engineering |
|---|---|
| Clever instructions | Comprehensive information design |
| One-shot prompts | Persistent project context |
| Generic tips | Stack-specific conventions |
| Manual each time | Automated context loading |
The Context Stack
Every AI interaction has layers of context. Mastering each layer is context engineering:
┌─────────────────────────────┐
│ 1. System Prompt │ ← Who the AI is, constraints
├─────────────────────────────┤
│ 2. Project Context │ ← .cursor/rules, CLAUDE.md, AGENTS.md
├─────────────────────────────┤
│ 3. Retrieved Knowledge │ ← RAG, documentation, examples
├─────────────────────────────┤
│ 4. Tool Definitions │ ← MCP servers, function schemas
├─────────────────────────────┤
│ 5. Conversation History │ ← Previous messages, corrections
├─────────────────────────────┤
│ 6. User Message │ ← The actual request
└─────────────────────────────┘
Most people only optimize layer 6. Context engineers optimize all six.
Practical Context Engineering
Layer 1: System Prompts
Define role, constraints, and output format at the right altitude — specific enough to guide behavior, flexible enough that the model can apply judgment. Brittle if-else logic and vague vibes both fail.
→ See System Prompts Guide
Layer 2: Project Context Files
Create persistent instruction files that load automatically:
.cursor/rules/*.mdc— For Cursor → Cursor Rules GuideCLAUDE.md— For Claude Code → CLAUDE.md TemplatesAGENTS.md— Plain markdown, supported by Cursor and most agent harnesses.github/copilot-instructions.md— For GitHub Copilot
Layer 3: Knowledge Retrieval
Two strategies, often hybrid:
- Up-front retrieval — embed and fetch relevant docs before inference. Fast, but can go stale.
- Just-in-time retrieval — the agent keeps lightweight references (file paths, queries, links) and pulls data at runtime with tools. Claude Code works this way:
CLAUDE.mdloads up front, then glob and grep fetch files on demand.
Just-in-time mirrors how humans work — we don’t memorize the corpus, we keep indexes and look things up.
Layer 4: Tool Configuration
Tools define the contract between the agent and its environment. Keep the set minimal and unambiguous — if a human can’t say which tool applies in a situation, the model can’t either. Tool results should be token-efficient.
→ See MCP Servers Explained
Layer 5: Conversation Design
Structure multi-turn interactions for best results:
- Start with context dump, then ask questions
- Correct misunderstandings immediately
- Summarize progress at checkpoints
Long-Horizon Tasks
When a task outgrows the context window — multi-hour migrations, research projects — three techniques from Anthropic’s playbook:
- Compaction — summarize the conversation near the limit, restart with the summary. Tune for recall first, then trim.
- Structured note-taking — the agent writes notes to files outside the window (a
NOTES.md, a to-do list) and reads them back later. This is agentic memory in its simplest form. - Sub-agent architectures — specialized sub-agents work in clean context windows and return condensed summaries (often 1,000–2,000 tokens) to the lead agent.
Best Practices
1. Show, Don’t Tell
Instead of describing your code style, show examples. Examples are the pictures worth a thousand words — curate a small set of canonical ones instead of a laundry list of edge cases:
# In your .cursor/rules or CLAUDE.md:
## Component Example (FOLLOW THIS PATTERN)
export const UserCard = ({ user }: Props) => {
if (!user) return null
return <Card className="p-4">{user.name}</Card>
}
2. Be Explicit About Versions
AI models default to training-data-era patterns. Pin your versions:
## CRITICAL: Stack Versions
- Next.js 15.1 (App Router, NO Pages Router)
- React 19 (use() hook, NOT useEffect for data)
- TypeScript 5.6 (satisfies operator preferred)
3. Define What NOT to Do
Negative constraints are often more useful than positive ones:
## NEVER
- Use `any` type
- Add explanatory comments on obvious code
- Import from barrel files
- Use default exports
4. Include Error Handling Patterns
Show the AI how YOUR project handles errors:
## Error Handling
Always use Result types, never throw:
const result = await trySafe(() => fetchUser(id))
if (result.error) return { error: result.error.message }
Measuring Context Quality
Good context engineering shows up in measurable ways:
| Signal | Poor Context | Good Context |
|---|---|---|
| First-attempt accuracy | Low, erratic | Consistently high |
| Manual corrections needed | Many per task | Few per task |
| Style consistency | Random | Matches your codebase |
| Import correctness | Often wrong | Correct paths |
| Test quality | Generic/missing | Matches your patterns |
Measure against your own evals, not vibes. Define success criteria before you tune.
Related Resources
- Cursor Rules Guide — Project context for Cursor
- System Prompts Guide — Layer 1 optimization
- Vibe Coding Guide — Context engineering in practice
- MCP Servers Explained — Tool context via MCP
Applied Context Engineering by Role
- AI for Work — Context engineering for office professionals
- AI for Business — Strategic AI context design
- AI for Education — Context engineering for educators
## embed this badge
