CONTEXT.md
Context engineering system
Control which instructions, examples, tools, retrieved facts, messages, and summaries reach the model; record their authority, provenance, freshness, token cost, and intended decision.
Fillable structure
Replace prompts with project evidence.
Remove any field that does not apply. A smaller maintained file is more useful than generic documentation that agents and reviewers cannot trust.
- 01
Context inventory
Identify every source of runtime tokens and the specific decision or behavior it supports.
Always loaded: List system instructions, repository policy, schemas, and stable constraints
Retrieved: List knowledge stores, search, tools, ranking, and freshness requirements
Runtime: List user input, session history, tool output, scratch state, and summaries
- 02
Selection and budget
Prioritize relevant and authoritative context under realistic limits.
Budget: Allocate tokens or size limits by instruction, history, retrieval, tools, and output
Ranking: Define relevance, authority, recency, diversity, and conflict rules
Compaction: Describe summarization, truncation, checkpointing, and information that must survive
- 03
Provenance and conflict
Make it possible to inspect why information was present and which source wins.
Provenance: Attach source, owner, timestamp, version, and retrieval reason
Authority order: Define precedence for user intent, project policy, retrieved evidence, and model inference
Sensitive context: State redaction, isolation, retention, and export restrictions
- 04
Evaluation
Measure whether the context system helps rather than assuming more is better.
Quality: Test retrieval precision, groundedness, conflict resolution, and task success
Efficiency: Measure tokens, latency, cache effectiveness, and repeated retrieval
Failure cases: Test stale facts, prompt injection, distraction, compaction loss, and missing context
Related field guides
Next template
MEMORY.md · Agent memory system