// Write AI-readable documentation following concise-over-comprehensive principle, hierarchical CLAUDE.md/AGENTS.md inheritance (100-200 line rule), structured formats (tables over prose), parallel validation, and session knowledge capture. Use when writing documentation, updating docs, or optimizing existing docs.
| name | AI Documentation Standards |
| description | Write AI-readable documentation following concise-over-comprehensive principle, hierarchical CLAUDE.md/AGENTS.md inheritance (100-200 line rule), structured formats (tables over prose), parallel validation, and session knowledge capture. Use when writing documentation, updating docs, or optimizing existing docs. |
| allowed-tools | Read, Write, Edit, Grep, Glob |
Purpose: Create documentation optimized for AI code agents in large monorepos and complex systems.
Key Insight: AI agents need concise, structured, scannable information with clear context boundaries - not comprehensive tutorials. Documentation should be a MAP to the codebase, not a REPLACEMENT for reading code.
AI agents can read code. Documentation = MAP to codebase, not replacement. Provide structure and location references (file:line), not exhaustive explanations.
Tables, bullets, code snippets >>> Paragraphs. AI agents parse structured content faster and more accurately.
Always include file:line_number for implementation details. AI agents need to know WHERE to look, then they read the code.
Create clear "entry points" for different detail levels:
Use consistent terminology. Include searchable keywords, related components. AI agents use semantic search.
Most CLAUDE.md files should be 100-200 lines. Exceptions: Complex production systems (300-400 lines max).
WHY: Claude recursively loads CLAUDE.md from root → current directory. Everything becomes agent context, so verbosity = wasted tokens.
Principle: Child CLAUDE.md files should ONLY contain information unique to their level. Never duplicate parent content.
| Level | Lines | Focus | What to Include | What to Exclude |
|---|---|---|---|---|
Global (~/.claude/CLAUDE.md) | 100-120 | Decision framework, workflow modes | Thinking budget, core principles, parallel execution, git safety | Tool-specific commands, project patterns, testing details |
Project (e.g., project/CLAUDE.md) | 150-180 | Project standards, tool configs | Linting commands, testing structure, code style | Core principles (in global), subsystem details |
Subsystem (e.g., subsystem/CLAUDE.md) | 120-150 | Architecture overview, design patterns | System architecture, data flow, major components | Testing patterns (in project), code style (in project) |
Framework (e.g., imports/CLAUDE.md) | 100-120 | Framework patterns, conventions | Three-phase pattern, base classes, directory structure | Subscription handling (in parent), testing (in project) |
| Simple Tool | 200-250 | Purpose, architecture | Tool-specific logic, configuration, gotchas | Code quality (in project), testing (in project) |
| Complex Tool | 300-400 | Architecture, business logic | Critical business logic, patterns, gotchas | Code standards, testing strategy, base patterns |
Never duplicate across hierarchy levels:
Bad: Testing standards repeated in global, project, and tool CLAUDE.md (3x duplication)
Good: Define once in global, reference in project ("See global CLAUDE.md for coverage requirements"), reference in tool ("See project CLAUDE.md for structure")
Result: 50% reduction in duplication
For full examples: See reference.md
QUICKREF.md (deep-dive): Full code examples, detailed patterns, testing strategies with mocks, performance optimization, debugging strategies, architecture deep dives
CLAUDE.md (quick reference): Critical business logic (table format), architecture overview (bullets), common gotchas (condensed with file:line), key constants, "See QUICKREF.md for details"
For full templates: See reference.md
Type 1: OVERVIEW.md (100-200 lines)
Type 2: BUSINESS_RULES.md (300-800 lines)
Type 3: ARCHITECTURE.md (200-400 lines)
Type 4: API_REFERENCE.md (200-600 lines)
Type 5: TROUBLESHOOTING.md (150-300 lines)
Purpose: Help AI agents find relevant docs quickly in large monorepos
When to Create:
Structure: Organized sections (Quick Start, Business Logic, Architecture, Implementation, Troubleshooting) with file paths + line counts, plus task-specific navigation guides
For full template: See reference.md
Purpose: Specialized documentation for AI coding agents (alternative to CLAUDE.md)
When to Use: Detect parent format - maintain consistency (CLAUDE.md or AGENTS.md)
Location: Project root
Structure:
# AGENTS.md
## Quick Context
- Tech stack, architecture, entry point
## Documentation Structure
- Start: OVERVIEW.md, Rules: BUSINESS_RULES.md, API: API_REFERENCE.md
## For Documentation Updates
- Review strategy: 1 reviewer per N components
- Validation priority, line counts, session knowledge extraction
## For Code Changes
- Testing, linting, standards references
## For Reviews
- Parallel execution, grouping, focus areas
## Critical Gotchas
[Project-specific]
Key Difference from CLAUDE.md: Focused on agent workflows vs general project context
Purpose: Extract and preserve insights learned during work sessions
Categories:
Scoping:
project_local: Specific project/tool only → $WORK_DIR/main docparent_scope: Parent directory (framework/subsystem) → parent docrepo_scope: Entire repository → repo docs or skillsIntegration:
Smart Placement:
if scope == "project_local":
location = "$WORK_DIR/CLAUDE.md or AGENTS.md"
elif scope == "parent_scope":
location = find_parent_doc($WORK_DIR)
elif scope == "repo_scope":
location = "$REPO_ROOT/docs/PATTERNS.md or skills/"
Complexity Metrics:
components = modules + standalone_files
doc_lines = sum(count_lines(md_files))
rules = count_rule_rows("BUSINESS_RULES.md")
score = (components * 100) + (doc_lines / 10) + (rules * 50)
Reviewer Count:
6000: 6 reviewers
Grouping:
Example:
# 15 components, 4 reviewers
Group 1: processors/ (7 files) + main doc sections
Group 2: cache/ + api/ + main doc sections
Group 3: docs/ (OVERVIEW, BUSINESS_RULES, ARCHITECTURE)
Group 4: Hierarchy integrity (all main docs)
Placement Algorithm:
Decision Tree:
if scope == "project_local":
if not exists("$WORK_DIR/docs/"):
create_docs_structure($WORK_DIR)
if topic in ["gotchas", "overview"]:
location = "$WORK_DIR/main doc"
elif topic == "business_rules":
location = "$WORK_DIR/docs/BUSINESS_RULES.md"
elif topic == "architecture":
location = "$WORK_DIR/docs/ARCHITECTURE.md"
elif topic == "api":
location = "$WORK_DIR/docs/API_REFERENCE.md"
elif scope == "parent_scope":
parent = find_parent_with_docs($WORK_DIR)
location = f"{parent}/docs/{topic}.md"
elif scope == "repo_scope":
root = find_repo_root($WORK_DIR)
if exists(f"{root}/docs/"):
location = f"{root}/docs/PATTERNS.md"
else:
location = f"{root}/.claude/skills/{category}/"
Proper Organization:
$WORK_DIR/docs/
├── llms.txt
├── OVERVIEW.md
├── API_REFERENCE.md
├── ARCHITECTURE.md
├── BUSINESS_RULES.md
├── HOW_TO.md
├── TROUBLESHOOTING.md
└── <sub-component>/
├── COMPONENT_OVERVIEW.md
└── COMPONENT_DETAILS.md
For full examples with before/after: See reference.md
1. Extract-Consolidate-Reference (ECR)
2. Split Large Monoliths (SLM)
3. Table-ify Prose (T2T)
4. Add llms.txt Index
5. Condense File Structure Trees
6. Bullet Points Over Paragraphs
For detailed examples: See reference.md
1. Don't Write Tutorials
2. Don't Explain Obvious Code
3. Don't Mix Abstraction Levels
4. Don't Create Deep Directory Nesting
5. Don't Use Relative Paths Without Context
../processors/base.pyprocessors/base_processor.py or absolute path6. Don't Duplicate Content Across Hierarchy
Before committing documentation changes:
# [Tool Name] Import
**Purpose**: [One sentence describing what this import does]
**Key Patterns**:
- Extends framework base classes (see `framework/CLAUDE.md`)
- [Tool-specific pattern 1]
- [Tool-specific pattern 2]
**Configuration**:
- Config location: `/path/to/config.json` → `[tool_name]` section
- Required keys: [list required config keys]
**Critical Logic**:
[Only if tool has unique business logic - DELETE section if not applicable]
**Common Gotchas**:
[Only if tool has known edge cases - DELETE section if not applicable]
**Testing**:
- Unit tests: `tests/test_[tool_name]/unit_tests/`
- Integration tests: `tests/test_[tool_name]/integration_tests/`
- See project CLAUDE.md for testing standards
**References**:
- Framework: `framework/CLAUDE.md`
- Testing standards: Project CLAUDE.md
Structure:
Total: 300-400 lines max
For full example structure: See reference.md
Can you scan the documentation in 30 seconds and find critical information? If not, it's too verbose.
Minimize agent context, maximize information utility, maintain hierarchical clarity.
Remember: Less is more. Every line consumes agent context. Make every line count.
For comprehensive templates and examples: See reference.md