Context Engineering
Master the discipline of designing what goes into your LLM context window -- and why it determines everything about output quality and consistency.
Why take this course?
Context engineering is the most leveraged skill in production AI. This course teaches you to treat the context window as a design surface, not a container: system prompt architecture, conversation history management, retrieval formatting, tool result trimming, and the write/select/compress/isolate framework that keeps agents coherent at scale.
Prerequisites
This course builds on concepts from the following courses. It is recommended to complete them first:
Course Modules
Understand what actually lives inside a context window and why treating it as a passive container causes production failures.
Learning Goals
- Identify the four layers of a production context window.
- Explain why context accumulation causes inconsistency, not model failure.
- Apply the recipe mental model to context design decisions.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Same Question, Different Answer
Nina's production assistant has been live for three weeks. The metrics look fine on the surface -- response times accept…
Anatomy of a Context Window
The context window is everything the model reads before generating a response. Not just the last message -- **everything…
The Context Window Is a Recipe
Here's the mental model that changes how Nina thinks about her assistant:
**The context window is a recipe. The model i…
Design clean, conflict-free system prompts using the four-component framework and audit for prompt drift.
Learning Goals
- Identify the four components of an effective system prompt.
- Detect and resolve conflicting instructions.
- Apply the lean prompt checklist to reduce system prompt token cost.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
The Only Context You Fully Control
Nina starts her context engineering overhaul where every experienced builder eventually lands: the system prompt.
Conve…
Anatomy of an Effective System Prompt
After studying Claude's published system prompts and a dozen production examples, Nina identifies four components that e…
Conflicting Instructions and Prompt Drift
There's a failure mode Nina names prompt drift -- and it happens to almost every production system.
Month 1: Syst…
Manage multi-turn context with the Lost in the Middle research, rolling compaction, and structural anchoring.
Learning Goals
- Explain the U-curve performance pattern from the Lost in the Middle paper.
- Design a hybrid history management strategy for long conversations.
- Apply structural anchoring to place critical content in high-performance zones.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Context Rot: How Long Conversations Go Wrong
Nina's system prompt is clean now. Her model is consistent on fresh conversations. But after 8-10 turns? It still drifts…
Lost in the Middle
In 2024, Stanford researchers published a finding that changed how serious engineers think about context order: **"Lost…
Rolling Windows: Truncation vs Summarisation
When context grows too large, there are two strategies for managing history:
Rolling window truncation — Drop the o…
Engineer RAG and tool results as deliberate context decisions -- format, rank, trim, and select for signal over completeness.
Learning Goals
- Explain why retrieval format affects model accuracy.
- Apply re-ranking and structured injection to improve RAG performance.
- Trim verbose tool results to their decision-relevant fields.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Retrieval Is Context Engineering
Nina has been thinking of RAG as a data fetching problem: embed the query, find similar chunks, return them. She's abo…
Chunk Size, Ranking, and Format
Nina redesigns her retrieval pipeline with context engineering in mind. She has three levers:
Chunk size: Smaller c…
Tool Results Are Context Too
Nina's assistant uses several tools: a search API, a user account lookup, and a calendar API for scheduling follow-ups.…
Apply the write/select/compress/isolate framework, token budget allocation, and Claude's compaction strategy to ship a production context architecture.
Learning Goals
- Apply all four context strategies (write, select, compress, isolate) to a production scenario.
- Design a token budget with explicit allocations per context slot.
- Know when to isolate a subtask into a subagent vs keep it in the main context.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Four Context Strategies: Write, Select, Compress, Isolate
Nina has been engineering her context window piece by piece -- system prompt, history, retrieval, tool results. It's tim…
Compaction: Rolling Summarisation for Long Agent Runs
Claude's architecture team published their approach to one of the hardest problems in long-running agents: how do you ke…
Token Budget Allocation
With the four strategies as a framework, Nina can now think about context engineering as budget allocation. She has…