# Context Engineering Best Practices
Research findings on building self-improving AI assistant systems with persistent knowledge bases, from [[Anthropic]]'s engineering guidance.
## Principle
Treat context as a finite resource. The goal is finding "the smallest set of high-signal tokens that maximize the likelihood of your desired outcome."
## Persistent Knowledge Structure
### Memory Outside Context Windows
Implement external storage for information that persists beyond individual inference cycles:
- **Structured note-taking**: Agents regularly write notes to external storage, then pull relevant information back into context when needed
- **File-based systems**: Store information hierarchically with meaningful naming conventions and timestamps that provide discovery signals
- **Progressive disclosure**: Let agents incrementally discover relevant context through exploration rather than loading everything upfront
### Context Curation Strategies
**Compaction**: Summarize context windows approaching their limits, preserving architectural decisions and critical details while discarding redundant outputs.
**Sub-agent architectures**: Delegate focused tasks to specialized agents with clean context windows. Each returns condensed summaries to the coordinating agent.
### Information Organization
Structure system prompts into distinct sections using XML tagging or Markdown headers. This delineation helps models navigate available context.
## Tool Design for Efficient Retrieval
Tools should be:
- Self-contained and unambiguous in their purpose
- Token-efficient in their outputs
- Minimal in number—bloated toolsets create decision confusion
Use "just-in-time" context strategies: maintain lightweight identifiers (file paths, queries, links) and dynamically load data via tools.
## Avoiding Common Pitfalls
Don't hardcode complex brittle logic seeking exact behavior—this creates fragility. Provide heuristics to guide behavior rather than exhaustive rule lists.
## Application to /evolve
These principles inform how Claude's knowledge base should work:
1. Knowledge files are external storage that survives context resets
2. INDEX.md provides discovery signals for just-in-time loading
3. Domain/topic organization enables progressive disclosure
4. Heuristics (not exhaustive rules) guide behavior
## Source
[Effective Context Engineering for AI Agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents) - Anthropic Engineering Blog