Documentation Done Right
Core Workflow
Phase 1: Discovery
Scan for existing documentation
Look for: README.md, docs/, documentation/, llms.txt, llms-full.txt,
CONTRIBUTING.md, API.md, openapi.yaml, *.md files, JSDoc/docstrings
Identify the documentation framework (if any)
- Check for:
mint.json (Mintlify), mkdocs.yml (MkDocs), docusaurus.config.js, .vitepress/
- See references/frameworks.md for framework details
Understand the codebase
- Entry points, main modules, API routes
- Key abstractions and patterns
- Dependencies and integrations
Ask clarifying questions if unclear about:
- Target audience (developers, end-users, both?)
- Scope (full docs, specific feature, API only?)
- Existing documentation standards or templates
- Whether to create new docs or update existing
Phase 2: Audit (if docs exist)
Compare documentation against actual code:
Check for outdated content
- Function signatures that changed
- Removed features still documented
- New features not documented
- Changed configuration options
- Updated dependencies
Check for missing documentation
- Undocumented public APIs
- Missing setup/installation steps
- Undocumented environment variables
- Missing error handling docs
- No examples for complex features
Check for inaccuracies
- Run documented commands to verify they work
- Compare API examples against actual endpoints
- Verify file paths and code references exist
Report findings before making changes:
Found issues:
- docs/api.md: POST /users endpoint removed in v2.0
- README.md: Installation command uses deprecated flag
- Missing: No docs for new /webhooks endpoints
Phase 3: Write/Update Documentation
Style Guidelines
- Be concise - Developers skim; get to the point
- Show, don't tell - Examples over explanations
- Use consistent formatting - Match existing style
- Include working examples - Test code snippets
- Document the "why" - Not just the "what"
Structure for Different Doc Types
README.md (project root)
# Project Name
One-line description.
## Quick Start
Fastest path to running the project.
## Installation
Step-by-step setup.
## Usage
Common use cases with examples.
## Configuration
Environment variables, options.
## API (brief)
Link to full API docs if extensive.
## Contributing
How to contribute.
## License
API Documentation - See references/api-docs-guide.md
- Document every endpoint with: method, path, description
- Request: headers, params, body with types and constraints
- Response: status codes, body schema, examples
- Errors: all possible error codes and meanings
llms.txt / llms-full.txt - See references/llms-txt-spec.md
llms.txt: Concise overview (~2000-4000 tokens)
llms-full.txt: Comprehensive documentation
- Keep updated when codebase changes
Phase 4: Verify
After writing/updating:
- Read through for clarity and flow
- Test all code examples - They must work
- Verify all links - No broken references
- Check file paths - All referenced files exist
- Ask user to review if significant changes made
When to Ask the User
Ask before proceeding when:
- Scope is unclear: "Should I document just the public API or internal modules too?"
- Multiple valid approaches: "Should I create a single README or a docs/ folder structure?"
- Missing context: "I see environment variables but no .env.example - what are the required vars?"
- Significant decisions: "The existing docs use Sphinx but MkDocs might be better for this. Preference?"
- Uncertain about accuracy: "The code shows 3 required params but docs say 2 - which is correct?"
Common Tasks
"Document this codebase"
- Run discovery phase
- Identify what exists vs what's needed
- Ask about scope and audience
- Create documentation structure
- Write docs, starting with README and llms.txt
- Add API docs if applicable
"Update docs for ../other-repo"
- Read the external repo's existing docs
- Scan codebase for changes since last doc update
- Identify discrepancies
- Update docs to match current implementation
- Verify accuracy
"Find outdated docs"
- Run full audit phase
- Compare docs against code systematically
- Report all discrepancies with specific locations
- Offer to fix each issue
"Create/update llms.txt"
- Read existing llms.txt if present
- Scan codebase for key information
- Write concise llms.txt (overview, architecture, key files)
- Write llms-full.txt if project is complex
- See references/llms-txt-spec.md for format
"Write API documentation"
- Find all API routes/endpoints
- For each endpoint, document request and response
- Include authentication requirements
- Add working curl/code examples
- Document all error responses
- See references/api-docs-guide.md for patterns
Quality Checklist
Before marking documentation complete:
1---2name: documentation-done-right3description: Comprehensive guide for writing excellent technical documentation. Use when: (1) Creating docs for a new or existing codebase ("document this project", "create docs") (2) Updating documentation ("update the docs", "update docs for ../other-repo") (3) Auditing docs for accuracy ("verify docs", "check if docs are outdated", "find missing docs") (4) Creating or updating llms.txt/llms-full.txt files (5) Writing API documentation (endpoints, requests, responses) (6) Any documentation-related task including READMEs, guides, and technical references Triggers: "document", "documentation", "docs", "README", "llms.txt", "API docs", "outdated docs"4---56# Documentation Done Right78## Core Workflow910### Phase 1: Discovery11121. **Scan for existing documentation**13 ```14 Look for: README.md, docs/, documentation/, llms.txt, llms-full.txt,15 CONTRIBUTING.md, API.md, openapi.yaml, *.md files, JSDoc/docstrings16 ```17182. **Identify the documentation framework** (if any)19 - Check for: `mint.json` (Mintlify), `mkdocs.yml` (MkDocs), `docusaurus.config.js`, `.vitepress/`20 - See [references/frameworks.md](references/frameworks.md) for framework details21223. **Understand the codebase**23 - Entry points, main modules, API routes24 - Key abstractions and patterns25 - Dependencies and integrations26274. **Ask clarifying questions if unclear about:**28 - Target audience (developers, end-users, both?)29 - Scope (full docs, specific feature, API only?)30 - Existing documentation standards or templates31 - Whether to create new docs or update existing3233### Phase 2: Audit (if docs exist)3435Compare documentation against actual code:36371. **Check for outdated content**38 - Function signatures that changed39 - Removed features still documented40 - New features not documented41 - Changed configuration options42 - Updated dependencies43442. **Check for missing documentation**45 - Undocumented public APIs46 - Missing setup/installation steps47 - Undocumented environment variables48 - Missing error handling docs49 - No examples for complex features50513. **Check for inaccuracies**52 - Run documented commands to verify they work53 - Compare API examples against actual endpoints54 - Verify file paths and code references exist55564. **Report findings** before making changes:57 ```58 Found issues:59 - docs/api.md: POST /users endpoint removed in v2.060 - README.md: Installation command uses deprecated flag61 - Missing: No docs for new /webhooks endpoints62 ```6364### Phase 3: Write/Update Documentation6566#### Style Guidelines6768- **Be concise** - Developers skim; get to the point69- **Show, don't tell** - Examples over explanations70- **Use consistent formatting** - Match existing style71- **Include working examples** - Test code snippets72- **Document the "why"** - Not just the "what"7374#### Structure for Different Doc Types7576**README.md** (project root)77```markdown78# Project Name7980One-line description.8182## Quick Start83Fastest path to running the project.8485## Installation86Step-by-step setup.8788## Usage89Common use cases with examples.9091## Configuration92Environment variables, options.9394## API (brief)95Link to full API docs if extensive.9697## Contributing98How to contribute.99100## License101```102103**API Documentation** - See [references/api-docs-guide.md](references/api-docs-guide.md)104- Document every endpoint with: method, path, description105- Request: headers, params, body with types and constraints106- Response: status codes, body schema, examples107- Errors: all possible error codes and meanings108109**llms.txt / llms-full.txt** - See [references/llms-txt-spec.md](references/llms-txt-spec.md)110- `llms.txt`: Concise overview (~2000-4000 tokens)111- `llms-full.txt`: Comprehensive documentation112- Keep updated when codebase changes113114### Phase 4: Verify115116After writing/updating:1171181. **Read through** for clarity and flow1192. **Test all code examples** - They must work1203. **Verify all links** - No broken references1214. **Check file paths** - All referenced files exist1225. **Ask user to review** if significant changes made123124## When to Ask the User125126Ask before proceeding when:127128- **Scope is unclear**: "Should I document just the public API or internal modules too?"129- **Multiple valid approaches**: "Should I create a single README or a docs/ folder structure?"130- **Missing context**: "I see environment variables but no .env.example - what are the required vars?"131- **Significant decisions**: "The existing docs use Sphinx but MkDocs might be better for this. Preference?"132- **Uncertain about accuracy**: "The code shows 3 required params but docs say 2 - which is correct?"133134## Common Tasks135136### "Document this codebase"1371. Run discovery phase1382. Identify what exists vs what's needed1393. Ask about scope and audience1404. Create documentation structure1415. Write docs, starting with README and llms.txt1426. Add API docs if applicable143144### "Update docs for ../other-repo"1451. Read the external repo's existing docs1462. Scan codebase for changes since last doc update1473. Identify discrepancies1484. Update docs to match current implementation1495. Verify accuracy150151### "Find outdated docs"1521. Run full audit phase1532. Compare docs against code systematically1543. Report all discrepancies with specific locations1554. Offer to fix each issue156157### "Create/update llms.txt"1581. Read existing llms.txt if present1592. Scan codebase for key information1603. Write concise llms.txt (overview, architecture, key files)1614. Write llms-full.txt if project is complex1625. See [references/llms-txt-spec.md](references/llms-txt-spec.md) for format163164### "Write API documentation"1651. Find all API routes/endpoints1662. For each endpoint, document request and response1673. Include authentication requirements1684. Add working curl/code examples1695. Document all error responses1706. See [references/api-docs-guide.md](references/api-docs-guide.md) for patterns171172## Quality Checklist173174Before marking documentation complete:175176- [ ] All public APIs documented177- [ ] Installation/setup instructions tested178- [ ] Code examples are copy-paste runnable179- [ ] No references to non-existent files/functions180- [ ] Environment variables documented181- [ ] Error scenarios covered182- [ ] llms.txt exists and is current (if appropriate for project)183- [ ] Consistent formatting throughout184- [ ] No TODO placeholders left185- [ ] User has reviewed significant changes