Track 10 · Specialisation
Prompt & Context Engineering
Decide exactly what a model sees: clear prompts, the right examples, retrieved knowledge, memory and tools, packed into a limited context window. Then optimise and evaluate it like code.
- Last updated
- Total effort
- 390 h · ≈ 39 weeks
Overview
Prompt engineering was about wording: how to phrase an instruction so the model does what you want. Context engineering is the bigger job of deciding everything that goes into the model's context window on each call: the system prompt, examples, retrieved documents, conversation history, memory, tool definitions and tool results. The window is finite and attention degrades as it fills, so every token has to earn its place. This track teaches you to write prompts precisely, to understand how and why long contexts fail, to assemble and compress context on purpose, and to treat prompts as code: versioned, tested, and sometimes optimised automatically.
Why it matters heading into 2027
In June 2025 Shopify's Tobi Lütke and Andrej Karpathy argued that context engineering describes the real skill better than prompt engineering. Within months LangChain, Simon Willison and Anthropic had written it up, and Anthropic's September 2025 guide made it a core practice for building agents. As agents run longer and call more tools, the hard problem is no longer one clever prompt; it is managing a context that changes every step without letting it rot. Research such as Chroma's Context Rot report and Lost in the Middle shows that more context is not automatically better. This is now a core skill for anyone building agents, and the agentic-AI skill cluster is the fastest-growing in job postings.
- The agentic-AI skill cluster grew about 280% in US job postings between 2024 and 2025, while plain chatbot skills declined. — Lightcast for the Stanford AI Index 2026
- Anthropic describes context engineering as the natural progression of prompt engineering for building agents. — Anthropic Engineering, Sep 2025
Prerequisites
- Have built at least one small app that calls an LLM API (AI Engineering Beginner stage).
- Know what tokens and a context window are, and roughly how a Transformer attends over its input.
- Basic Python for scripting experiments and evals.
Learning path
How the stages build on each other, and where this track hands off to others.
flowchart TB
P["Prereqs: one LLM app · tokens · Python"] --> B
subgraph B["1 · Beginner — prompts that work"]
direction LR
B1["clear instructions"] --> B2["few-shot examples"] --> B3["structure · XML tags"]
end
subgraph I["2 · Intermediate — context, not just prompts"]
direction LR
I1["retrieval vs memory vs tools"] --> I2["context budget"] --> I3["failure modes"]
end
subgraph A["3 · Advanced — long-running context"]
direction LR
A1["compaction · notes"] --> A2["sub-agent isolation"] --> A3["cache-aware layout"]
end
subgraph E["4 · Expert — optimise & measure"]
direction LR
E1["DSPy · GEPA"] --> E2["prompt evals in CI"] --> E3["context-rot experiments"]
end
B --> I --> A --> E
A -.-> HAR["Harness Engineering"]
I -.-> AI["AI Engineering"]
E -.-> SEC["AI Security & Safety"]
Stages
Tick items as you go — progress is saved in this browser only. Times are focused hours (reading + building); the week estimates follow the study time you pick above.
01Beginner50 h · ≈ 5 weeksWrite prompts that are clear, specific and testable. Learn the techniques that reliably help, and build the habit of checking every prompt against examples.
Key concepts
Build these
Ready for the next stage when…
02Intermediate80 h · ≈ 8 weeksMove from writing prompts to assembling context. Learn what to put in the window, what to leave out, and how long contexts fail.
Key concepts
Build these
Ready for the next stage when…
03Advanced120 h · ≈ 12 weeksManage context across long, multi-step agent runs: compaction, structured notes, sub-agents with their own clean windows, and layouts that keep prompt caches warm.
Key concepts
Build these
Ready for the next stage when…
04Expert140 h · ≈ 14 weeksTreat prompts and context policies as programs to optimise and measure. Use automatic prompt optimisation, run controlled long-context experiments, and publish what you learn.
Key concepts
Build these
Ready for the next stage when…
Field guide
The ideas behind the checklist, with diagrams and the math where it helps.
From prompt to context
A prompt is one string. A context is everything the model sees on this call. In a modern agent, the part you wrote by hand is often a small fraction of the window; the rest is history, retrieved data and tool output that changes every step.
flowchart TB
subgraph STABLE["Stable prefix (cache-friendly)"]
direction LR
SYS["system prompt<br/>role · rules · style"] --> TOOLS["tool definitions"] --> EX["few-shot examples"]
end
subgraph DYN["Dynamic part (changes every step)"]
direction LR
MEM["memory / notes<br/>(loaded on demand)"] --> RET["retrieved documents"] --> HIST["conversation + tool results<br/>(compacted)"] --> Q["current request"]
end
STABLE --> DYN --> W["context window"] --> M["model"] --> A["answer or tool call"]
A -- "tool result" --> HIST
Order matters for two reasons. Keeping the stable parts first lets the serving engine reuse its KV cache across calls (cheaper and faster). Putting the current request last, close to where the model starts generating, avoids it being lost in the middle.
A context budget
Treat the window like memory in a small device. If the window holds tokens and you need room for the answer:
Fitting is not the goal, though. Quality usually drops well before the limit, so set your own budget for each component (for example “retrieved docs ≤ 8k tokens, history compacted above 30k”) and log the actual numbers. A useful signal is the share of the window that is relevant to the current step:
You can’t measure the numerator exactly, but asking the question changes your design: fewer tools, shorter tool results, and retrieval on demand instead of pasting everything in.
Prompting techniques that still matter
- Be specific about the output. Give a schema, an example, and what to do when the answer is unknown.
- Use structure. Wrap documents, examples and instructions in clear tags so the model can tell them apart.
- Show, don’t just tell. Two or three varied examples often beat a paragraph of rules.
- Let it think when it helps. Chain-of-thought helps non-reasoning models on multi-step problems; reasoning models already do this internally, so focus on clear goals and constraints instead.
- Test, don’t guess. Every technique helps on some tasks and hurts on others. Your test set decides.
Why long contexts fail
| Failure | What happens | Typical fix |
|---|---|---|
| Poisoning | a hallucination or error enters context and gets repeated | validate tool results; let the agent re-check facts |
| Distraction | long history makes the model repeat past actions | compaction; fresh sub-agent windows |
| Confusion | irrelevant tools or documents get used | fewer tools; better retrieval; filter results |
| Clash | contradictory information in context | remove outdated facts; mark sources and dates |
| Rot | accuracy falls as length grows, even on easy tasks | keep context short; just-in-time retrieval |
Managing context over a long run
Three tools cover most cases:
- Compaction. When history grows past a threshold, summarise it, keeping decisions, unresolved issues and exact identifiers (file paths, IDs). Drop raw tool output first.
- Notes. Let the agent write progress to a file or memory store (
NOTES.md, a TODO list) and read it back. This survives compaction and even new sessions. - Sub-agents. Send a focused sub-task to a fresh window. The sub-agent may read 50k tokens; the parent receives 500.
Optimising prompts automatically
Once you have a reliable eval, you can let software search for better prompts. DSPy expresses a pipeline as typed modules and uses optimisers (including GEPA) to choose instructions and examples. The risk is the same as in ML: overfitting to your dev set. Keep a held-out set, compare across several runs, and re-check when you switch models.
How this track connects
- AI Eng.RAG, tool use and evals are the building blocks you assemble into context.
- Harness Eng.Compaction, notes and sub-agents are implemented in the harness; context engineering decides the policy.
- AI SecurityEverything you put in context can carry instructions. Separating trusted and untrusted content is a security boundary.
- Deep LearningAttention, positional encodings and the KV cache explain why long contexts degrade and why cache-friendly layouts are cheaper.
- Inference & GPUPrefix caching and KV-cache reuse in serving engines are what make stable prompt prefixes fast and cheap.
References
Original sources first: arXiv, official docs, university courses and lab blogs. Every link was checked on 7 Nov 2026.
Foundational & seminal papers(10)
- Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Wei et al. · 2022 · arxiv.org
The foundational reasoning prompt.
- Self-Consistency Improves Chain of Thought Reasoning in Language Models
Wang et al. · 2022 · arxiv.org
Sample several reasoning paths and take a majority vote.
- Large Language Models Are Human-Level Prompt Engineers (APE)
Zhou et al. · 2022 · arxiv.org
Letting a model search for better instructions.
- Large Language Models as Optimizers (OPRO)
Yang et al. · 2023 · arxiv.org
Using an LLM as the optimiser for prompts.
- Lost in the Middle: How Language Models Use Long Contexts
Liu et al. · 2023 · arxiv.org
Position matters: information in the middle is used less well.
- DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
Khattab et al. · 2023 · arxiv.org
Write LLM pipelines as programs and let an optimiser tune the prompts.
- MemGPT: Towards LLMs as Operating Systems
Packer et al. · 2023 · arxiv.org
Paging information in and out of a limited context, like virtual memory.
- The Prompt Report: A Systematic Survey of Prompt Engineering Techniques
Schulhoff et al. · 2024 · arxiv.org
A taxonomy of prompting techniques and terminology.
- GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
Agrawal et al. · 2025 · arxiv.org
Prompt optimisation by reflection and evolution.
- Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models
Zhang et al. · 2025 · arxiv.org
Contexts that grow and curate themselves as playbooks.
Courses & videos(1)
- DeepLearning.AI short courses
DeepLearning.AI · deeplearning.ai
Short, free courses on prompting, RAG and agents.
Books(1)
- Prompt Engineering (whitepaper)
Lee Boonstra, Google · 2025 · kaggle.com
A practical 68-page guide to prompting techniques and settings.
Articles, blogs & official docs(13)
- Effective context engineering for AI agents
Anthropic · 2025 · anthropic.com
Compaction, note-taking, sub-agents and just-in-time context — start here.
- Context engineering (post on X)
Tobi Lütke · 2025 · x.com
The post that popularised the term.
- +1 for context engineering (post on X)
Andrej Karpathy · 2025 · x.com
A widely quoted definition of the craft.
- Context engineering
Simon Willison · 2025 · simonwillison.net
Why the new term fits better than prompt engineering.
- The rise of context engineering
LangChain · 2025 · langchain.com
Context engineering as a systems problem for agents.
- How Long Contexts Fail
Drew Breunig · 2025 · dbreunig.com
Names the failure modes: poisoning, distraction, confusion, clash.
- Context Rot: How Increasing Input Tokens Impacts LLM Performance
Chroma (Hong, Troynikov & Huber) · 2025 · trychroma.com
Experiments showing quality falls as input grows.
- Context Engineering for AI Agents: Lessons from Building Manus
Yichao 'Peak' Ji · 2025 · manus.im
KV-cache-aware layout, masking tools, and using the file system as memory.
- Prompt engineering overview
Anthropic · platform.claude.com
Official guidance for Claude models.
- Prompt engineering guide
OpenAI · developers.openai.com
Official guidance for OpenAI models.
- GPT-4.1 Prompting Guide
OpenAI · 2025 · developers.openai.com
Prompting literal-minded, agentic models.
- GPT-5 prompting guide
OpenAI · 2025 · developers.openai.com
Controlling reasoning effort and agentic eagerness.
- DSPy documentation
Stanford NLP · dspy.ai
The framework for programming (not prompting) language models.