Add new chapter
Context Engineering
Context is not “the more, the better,” but “controllable, verifiable, and reusable.” The goal is to achieve stable output with the minimum context.
Three-layer context model
Static context
Rules, constraints, architectural standards (stable and unchanging)
- Project conventions (lint/constraints)
- Interface contract (OpenAPI)
- Security boundaries and permission model
Workspace context
Files and code snippets strongly related to the current task
- Related file paths
- Minimal necessary fragment (diff/function)
- Reproduction steps and logs
Dynamic context
States and memory that change over time (must be controllable)
- Retrieval results (RAG)
- Recent decisions and reasons
- Temporary conclusions and hypotheses to be verified
Practical checklist (recommended to run by default)
- First give AI: goal + current situation + constraints + output format
- Explicitly group "reference materials": rules/code/logs/data
- Limit context: pass only the 3–8 most relevant files (or key snippets)
- Require uncertain parts to be marked [needs confirmation], and avoid making things up
- Leave a trace in each iteration: changes + evidence (tests/logs/screenshots)