AI Context
Release Evidence: Canonical Route Migration
Section titled “Release Evidence: Canonical Route Migration”A 59-second grounded release evidence walkthrough documenting the migration of this guide to the canonical ai-context route, merged into origin/main (commit 6f2bcb7, merge 0968c74 via PR #55).
MP4 video · Story manifest · English captions
Release Audit Summary: Commit
6f2bcb7is merged intoorigin/main(PR #55). All 130 site pages build cleanly with 0 diagnostic issues (npx astro check: PASS). All three language routes (/guides/ai-context/,/en/guides/ai-context/,/hr/guides/ai-context/) share verified canonical and hreflang links. Edge production deployment remains a separate verification step.
A comprehensive template for getting started with context engineering: the discipline of preparing context for AI coding assistants so they have the information necessary to get the job done end to end.
Context engineering provides AI coding assistants with documentation, examples, rules, and validation criteria, rather than just a task prompt.
🚀 Quick Start
Section titled “🚀 Quick Start”# 1. Work in the project or repository you will actually maintaincd your-project
# 2. Create the always-loaded project contract# Edit AGENTS.md with project-specific rules and navigation
# 3. Add examples (highly recommended)# Place relevant code examples in the examples/ folder
# 4. Create your initial feature request# Edit INITIAL.md with your feature requirements
# 5. Write a plan before implementation# Record the scope, files, dependencies, and acceptance checks
# 6. Implement and verify the plan# Use your coding agent's normal planning and execution workflowWhat is Context Engineering?
Section titled “What is Context Engineering?”Context Engineering goes beyond traditional prompt engineering:
Prompt Engineering vs Context Engineering
Section titled “Prompt Engineering vs Context Engineering”Prompt Engineering:
- Focuses on clever wording and specific phrasing
- Limited to how you phrase a task
- Like giving someone a sticky note
Context Engineering:
- A complete system for providing comprehensive context
- Includes documentation, examples, rules, patterns, and validation
- Like writing a full screenplay with all the details
Why Context Engineering Matters
Section titled “Why Context Engineering Matters”- Reduces AI Failures: Most agent failures aren’t model failures - they’re context failures
- Ensures Consistency: AI follows your project patterns and conventions
- Enables Complex Features: AI can handle multi-step implementations with proper context
- Self-Correcting: Validation loops allow AI to fix its own mistakes
Template Structure
Section titled “Template Structure”your-project/├── .agent/│ ├── skills/ # Reusable agent procedures│ └── commands/ # Optional harness-specific commands├── PRPs/│ ├── templates/│ │ └── prp_base.md # Base template for PRPs│ └── EXAMPLE_multi_agent_prp.md # Example of a complete PRP├── examples/ # Your code examples (critical!)├── AGENTS.md # Project rules and navigation├── INITIAL.md # Template for feature requests├── INITIAL_EXAMPLE.md # Example feature request└── README.md # This fileThis template does not cover retrieval-augmented generation (RAG) or tool integration in detail.
Step-by-Step Guide
Section titled “Step-by-Step Guide”1. Set Up Project Rules (AGENTS.md)
Section titled “1. Set Up Project Rules (AGENTS.md)”AGENTS.md is the project-level operating contract for coding agents. It is
vendor-neutral: the same file can guide Hermes, Codex, Zot, or another agent
without making the repository depend on one model provider or editor.
Keep it short enough to load on every task. Include:
- Project identity and boundaries: what the repository owns, what it does not own, and which architecture documents are authoritative.
- Repository map: the important directories, binaries, services, and source-of-truth files.
- Working rules: inspect before editing, preserve unrelated work, use
review branches, and never push directly to
main. - Validation gates: the exact formatter, tests, builds, linters, and local link or metadata checks required before claiming success.
- Platform constraints: supported operating systems, toolchain differences, and host-specific rules that an agent must not infer.
- Documentation routing: where architecture decisions, operations, plans, and reusable procedures belong.
Put long explanations in focused documentation and reusable procedures in
.agent/skills/. Use nested AGENTS.md files only when a subtree needs
stricter or more specific rules. The root file should route the agent to those
sources, not duplicate them.
A useful minimal starting point is:
# Project Rules
## Identity- What this repository owns- Canonical architecture and decision documents
## Workflow- Read the relevant files before editing- Work on a review branch; never push directly to `main`- Preserve unrelated changes and secrets
## Validation- Exact commands for formatting, tests, builds, and documentation checks
## Routing- Architecture: `docs/wiki/`- Plans and handoffs: `docs/plans/` and `docs/`- Reusable agent procedures: `.agent/skills/`Treat AGENTS.md as a routing layer and safety boundary, not as a personal
diary or a second copy of the whole project manual.
2. Create Your Initial Feature Request
Section titled “2. Create Your Initial Feature Request”Edit INITIAL.md to describe what you want to build:
## FEATURE:[Describe what you want to build - be specific about functionality and requirements]
## EXAMPLES:[List any example files in the examples/ folder and explain how they should be used]
## DOCUMENTATION:[Include links to relevant documentation, APIs, or MCP server resources]
## OTHER CONSIDERATIONS:[Mention any gotchas, specific requirements, or things AI assistants commonly miss]See INITIAL_EXAMPLE.md for a complete example.
3. Turn the request into a plan
Section titled “3. Turn the request into a plan”You can use a PRP (Product Requirements Prompt), a task brief, or an ordinary implementation plan. The format matters less than the contents:
- Complete context and documentation
- Implementation steps with validation
- Error handling patterns
- Test requirements
They are similar to PRDs (Product Requirements Documents) but are crafted more specifically to instruct an AI coding assistant.
Use the planning mechanism provided by your coding agent, or write the plan as a reviewed Markdown file:
# Example only: keep the plan in the repository's normal plans directorycp INITIAL.md plans/feature-name.mdIf your harness supports reusable commands, keep their instructions under
.agent/commands/ or package them as a skill. Do not put provider-specific
assumptions into AGENTS.md.
The planning step should:
- Read your feature request
- Research the codebase for patterns
- Search for relevant documentation
- Name the files to change and the checks that will prove the work complete
4. Implement and verify the plan
Section titled “4. Implement and verify the plan”The implementation phase then follows the reviewed plan, records deviations, and runs the stated checks. A plan is useful only when it ends with evidence: tests, builds, rendered output, or another concrete acceptance result.
The coding agent will:
- Read all context from the plan
- Create a detailed implementation plan
- Execute each step with validation
- Run tests and fix any issues
- Ensure all success criteria are met
Writing Effective INITIAL.md Files
Section titled “Writing Effective INITIAL.md Files”Key Sections Explained
Section titled “Key Sections Explained”FEATURE: Be specific and comprehensive
- ❌ “Build a web scraper”
- ✅ “Build an async web scraper using BeautifulSoup that extracts product data from e-commerce sites, handles rate limiting, and stores results in PostgreSQL”
EXAMPLES: Use the examples/ folder
- Place relevant code patterns in
examples/ - Reference specific files and patterns to follow
- Explain what aspects should be mimicked
DOCUMENTATION: Include all relevant resources
- API documentation URLs
- Library guides
- MCP server documentation
- Database schemas
OTHER CONSIDERATIONS: Capture important details
- Authentication requirements
- Rate limits or quotas
- Common pitfalls
- Performance requirements
The Plan-to-Verification Workflow
Section titled “The Plan-to-Verification Workflow”Research and planning
Section titled “Research and planning”A good planning pass follows this process:
-
Research Phase
- Analyzes your codebase for patterns
- Searches for similar implementations
- Identifies conventions to follow
-
Documentation Gathering
- Fetches relevant API docs
- Includes library documentation
- Adds gotchas and quirks
-
Blueprint Creation
- Creates step-by-step implementation plan
- Includes validation gates
- Adds test requirements
-
Quality Check
- Scores confidence level (1-10)
- Ensures all context is included
Implementation and verification
Section titled “Implementation and verification”- Load context: Read the plan, relevant source, and local rules
- Implement: Change the smallest correct set of files
- Validate: Run the exact tests, builds, and documentation gates
- Review: Inspect the diff for scope, security, and stale references
- Iterate: Fix failures rather than weakening the checks
- Complete: Report evidence and remaining uncertainty
See PRPs/EXAMPLE_multi_agent_prp.md for a complete example of what gets generated.
Using Examples Effectively
Section titled “Using Examples Effectively”The examples/ folder is critical for success. AI coding assistants perform much better when they can see patterns to follow.
What to Include in Examples
Section titled “What to Include in Examples”-
Code Structure Patterns
- How you organize modules
- Import conventions
- Class/function patterns
-
Testing Patterns
- Test file structure
- Mocking approaches
- Assertion styles
-
Integration Patterns
- API client implementations
- Database connections
- Authentication flows
-
CLI Patterns
- Argument parsing
- Output formatting
- Error handling
Example Structure
Section titled “Example Structure”examples/├── README.md # Explains what each example demonstrates├── cli.py # CLI implementation pattern├── agent/ # Agent architecture patterns│ ├── agent.py # Agent creation pattern│ ├── tools.py # Tool implementation pattern│ └── providers.py # Multi-provider pattern└── tests/ # Testing patterns ├── test_agent.py # Unit test patterns └── conftest.py # Pytest configurationBest Practices
Section titled “Best Practices”1. Be Explicit in INITIAL.md
Section titled “1. Be Explicit in INITIAL.md”- Don’t assume the AI knows your preferences
- Include specific requirements and constraints
- Reference examples liberally
2. Provide Comprehensive Examples
Section titled “2. Provide Comprehensive Examples”- More examples = better implementations
- Show both what to do AND what not to do
- Include error handling patterns
3. Use Validation Gates
Section titled “3. Use Validation Gates”- PRPs include test commands that must pass
- AI will iterate until all validations succeed
- This helps catch problems before you consider the implementation complete
4. Include Documentation
Section titled “4. Include Documentation”- Include official API docs
- Add MCP server resources
- Reference specific documentation sections
5. Maintain AGENTS.md
Section titled “5. Maintain AGENTS.md”- Add your conventions
- Include project-specific rules
- Define validation and review gates
- Link to detailed documentation instead of duplicating it