Context Engineering
Context engineering is the discipline of designing the complete information environment an LLM operates within. Prompts are a subset — context includes system instructions, tool results, conversation history, retrieved documents, scratchpads, and memory artifacts.
Core Framework: Write / Select / Compress / Isolate
| Phase | Question | Key Technique |
|---|---|---|
| Write | What context needs to exist? | Scratchpads, external memory, todo files, structured artifacts |
| Select | What context enters the window? | Just-in-time loading, hybrid retrieval, progressive file discovery |
| Compress | How do we fit more signal? | Compaction, preserve decisions, discard redundant output |
| Isolate | How do we prevent contamination? | Sub-agents with bounded returns, clean contexts, sandboxed state |
Instruction Design (Quick Reference)
Role + Objective + Latitude — the minimum viable instruction:
You're a senior engineer reviewing this PR. # Role
Find bugs, security issues, and code smells. # Objective
Be direct. If it's fine, say so briefly. # Latitude
The Test: "Would I give these instructions to a senior engineer?" If you'd be embarrassed to hand a colleague a 700-line runbook, don't give it to the LLM.
Three-instruction agent bootstrap (~20% benchmark lift):
- Persistence — keep trying, don't give up after first failure
- Tool-calling — use tools to gather information before answering
- Planning — make a plan before acting, revise when blocked
When to Load References
| Signal | Reference |
|---|---|
| Writing prompts, CLAUDE.md, AGENTS.md, system instructions | references/instruction-design.md |
| Designing memory, retrieval, token budgets, caching | references/context-lifecycle.md |
| Debugging degraded agent performance, context quality | references/context-anti-patterns.md |
| Choosing specificity level, autonomy boundaries | references/altitude-calibration.md |
| In-code annotations for agents (@deprecated, @agent-pitfall, @migration) | references/agent-annotations.md |
Output Contract
When invoked for context review or design:
- Diagnosis — what's wrong with current context (or "clean" if nothing)
- Context Delta — specific additions/removals/restructuring
- Instruction Delta — prompt rewrites with before/after
- First-Pass Reliability Risks — what might fail on first attempt
- Eval Assertions — suggested test cases for the context change
Absorbed Skills
llm-communication→references/instruction-design.md
