Prompt & context engineering
Treat the context window as an engineered input, not a wish.
The most leveraged daily skill: shaping what goes into the model. Prompting is the surface; context engineering — deciding what information, tools and structure enter the window — is the real discipline. Teams will bring you their broken prompts, so own this cold.
Key ideas
- 1
Context engineering > prompt wording: the biggest wins come from giving the model the right information, examples and tools — not clever phrasing.
- 2
Use structure: clear roles (system vs user), explicit instructions, delimiters, and ask for structured output (JSON / tool calls) when you'll parse the result.
- 3
Few-shot examples beat adjectives. Show 2–5 representative examples instead of describing what you want.
- 4
Mind the window: models degrade with very long context ('lost in the middle') — put the most important instructions at the start and end, and prune irrelevant tokens.
- 5
Decompose hard tasks into steps/chains; let the model 'think' before answering for reasoning tasks; cache stable prefixes to cut cost and latency.
What actually moves quality
- Right information in context (retrieved facts, schemas, examples) — usually the #1 lever.
- Clear task framing: role, goal, constraints, output format, and what to do when unsure.
- Few-shot examples that match the real distribution of inputs.
- Output contracts: structured output / tool calling so downstream code is reliable.
Engineering practices
- Version prompts like code; never tweak a production prompt without an eval (see the Evaluation chapter).
- Prompt caching for stable system prompts / long shared context to cut cost & latency.
- Decomposition & chaining for complex tasks; reserve 'reasoning' for problems that need it.
- Defend against prompt injection when prompts include untrusted/retrieved text (see AI Security).
Watch
Do the work
0/4 · 0%Test yourself
What usually gives the biggest quality improvement?
27 chapters · progress saves automatically