Context as code treats persistent instructions and other agent context sources as maintainable software artifacts. It applies engineering controls to system instructions, retrieval configurations, state schemas, memory policies, and tool definitions so changes can be reviewed, tested, promoted, and traced. section 9.3.7
Operationalize context changes with four practices:
- Version-control context assets in Git to preserve an auditable history and enable review through pull requests. section 9.3.7
- Make shared context components modular and reusable rather than duplicating policies or identities. section 9.3.7
- Separate context definitions from application binaries and validate configurations across development, staging, and production. section 9.3.7
- Run evaluation suites in CI/CD to check prompt templates and retrieval configurations before merging or deployment. section 9.3.7
For agent instructions, place shared repository rules in version-controlled files, keep tool-specific adaptations separate, and reserve private preferences or tokens for untracked local configuration. Use nested instruction files for subprojects, clarify whether they extend or override root guidance, and prune stale directives during review. section 2.4.2
Listing 9.1 Example directory structure for context-as-code artifacts
context/
prompts/
retrievers/
policies/
tools/
schemas/
memory/
evals/
environments/
dev/
test/
prod/
A sample repository layout groups context assets by function and separates environment-specific configurations. section 9.3.7
