Documentation Done Right
Core Workflow
Phase 1: Discovery
- •
Scan for existing documentation
codeLook 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
- •Check for:
- •
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:
codeFound 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:
- • All public APIs documented
- • Installation/setup instructions tested
- • Code examples are copy-paste runnable
- • No references to non-existent files/functions
- • Environment variables documented
- • Error scenarios covered
- • llms.txt exists and is current (if appropriate for project)
- • Consistent formatting throughout
- • No TODO placeholders left
- • User has reviewed significant changes