manage-agents-md
Build and maintain high-quality AGENTS.md files that maximize AI coding agent efficiency.
Core Principle
AI coding agents are stateless. AGENTS.md goes into every conversation - and in this setup it is not alone: every ~/.claude/rules/*.md file is always-loaded too and shares the same context budget. It must onboard the agent to your codebase efficiently without bloating the context window.
Critical insight: AI agents may ignore AGENTS.md contents if deemed irrelevant. Overstuffed files with non-universal instructions get ignored entirely.
Three Pillars of a Good AGENTS.md
Every AGENTS.md should answer three questions concisely:
- WHAT - Tech stack, project structure, key directories
- WHY - Project purpose, what each part does
- HOW - Essential commands, verification steps, workflows
Hard Constraints
| Constraint | Limit | Rationale | |------------|-------|-----------| | Total lines | < 300 (ideal: < 100) | Context window is shared with system prompt, conversation, tools | | Instructions | < 100 | Frontier models reliably follow ~150-200 instructions; system prompt uses ~50 | | Applicability | 100% universal | Non-universal instructions cause entire file to be ignored |
What NOT to include: the exclusion list lives in references/checklist.md
("What NOT to Include" + "Common Anti-Patterns") — style guidelines belong in
linters, task-specific instructions in commands, code in file:line pointers.
Progressive Disclosure Pattern
Keep AGENTS.md lean by pointing to detailed docs in agent_docs/ — layout,
index format, and the pointers-over-copies rule are in
references/progressive-disclosure.md.
Template
Full and minimal AGENTS.md structures live in references/template.md.
Creating a New AGENTS.md
- Analyze the project - Identify stack, structure, key workflows
- Start minimal - Begin with <50 lines covering essentials
- Create agent_docs/ - Move detailed documentation there (per
references/progressive-disclosure.md) - Add pointers - Reference agent_docs from AGENTS.md
- Validate - Run checklist from
references/checklist.md
Auditing an Existing AGENTS.md
- Count lines - Flag if >300 lines
- Check universality - Every instruction should apply to every task
- Find embedded code - Replace with file:line pointers
- Identify style rules - Move to linter config
- Extract conditionals - Move to agent_docs/
- Validate - Run checklist from
references/checklist.md
Promoting Project Memories
Migrate durable, public, repo-relevant facts from the project auto-memory
into AGENTS.md, prune the rest, and delete what was promoted. Rubric and
flow (classification, mandatory user confirmation before deletion, budget
rules) live in references/promote-memories.md.
Integrations
- Formatting/linting: configure pre-commit hooks instead of writing style instructions into AGENTS.md.
- Specific workflows: put task-specific instructions in a project commands directory, not AGENTS.md.
Reference Files
references/template.md- Complete AGENTS.md template with examplesreferences/checklist.md- Validation checklist, exclusion list, anti-patternsreferences/progressive-disclosure.md- Guide for organizing agent_docs/references/promote-memories.md- Memory→AGENTS.md promotion rubric and flow