Writing Documentation
Overview
Expert technical documentation skill for creating clear, accurate, user-friendly documentation. Handles lightweight documentation tasks directly and delegates comprehensive tasks to the writing-documentation agent.
When to Use This Skill
Use writing-documentation when you need to create:
- API documentation from code (OpenAPI, endpoint references, authentication docs)
- User guides and tutorials (getting started, feature walkthroughs)
- Architecture documentation (system design, ADRs, component diagrams)
- Operational docs (runbooks, deployment guides, troubleshooting)
- Project documentation (comprehensive READMEs, CONTRIBUTING guides)
Handoff Rules
To updating-readme skill
For maintaining existing READMEs (section updates, dependency changes, minor edits), use updating-readme instead. This skill creates; updating-readme maintains.
To writing-documentation agent
Delegate to the writing-documentation agent via the Task tool when ANY of these apply:
- Output will be multiple files
- User guide will exceed 500 words
- Requires architecture documentation or ADRs
- API documentation requires analyzing more than 3 source files
- Creating documentation from scratch for an undocumented project
- Task requires deep codebase analysis
How to delegate:
Use the Task tool with agent writing-documentation. Example:
Task: writing-documentation
Prompt: Create comprehensive API documentation for the authentication module including all endpoints, request/response schemas, and error codes.
Decision Matrix
| Scenario |
Handle Here |
Delegate to Agent |
| Single README creation |
✓ |
|
| API docs for 1-3 endpoints |
✓ |
|
| Short user guide (<500 words) |
✓ |
|
| Multi-file documentation site |
|
✓ |
| Full API reference (10+ endpoints) |
|
✓ |
| Architecture docs with ADRs |
|
✓ |
| Comprehensive project docs |
|
✓ |
Quick Reference
| Doc Type |
Workflow |
Template |
| API Reference |
workflows/api-docs.md |
templates/api-reference.md |
| User Guide |
workflows/user-guide.md |
templates/user-guide.md |
| Architecture |
workflows/architecture.md |
templates/adr.md |
| Troubleshooting |
workflows/troubleshooting.md |
— |
| Runbook |
— |
templates/runbook.md |
| README |
— |
templates/readme-comprehensive.md |
Process
When asked to create documentation:
- Scope Assessment: Determine if this should be delegated to the agent (see Decision Matrix above)
- If delegating: Use Task tool with writing-documentation agent
- If handling here:
- Analyze the code/system to understand what needs documenting
- Read the appropriate workflow file:
- API docs → Read
workflows/api-docs.md
- User guide → Read
workflows/user-guide.md
- Architecture → Read
workflows/architecture.md
- Troubleshooting → Read
workflows/troubleshooting.md
- Read the matching template:
- API docs → Read
templates/api-reference.md
- README → Read
templates/readme-comprehensive.md
- ADR → Read
templates/adr.md
- Runbook → Read
templates/runbook.md
- User guide → Read
templates/user-guide.md
- Follow the workflow steps
- Run validation loop
- Deliver documentation
Core Principles
Audience Awareness
Always identify the target audience before writing:
- End Users: Simple language, task-oriented, minimal jargon
- Developers: Technical details, code examples, API specifics
- Administrators: Configuration, deployment, maintenance
- Contributors: Architecture, conventions, processes
Documentation Standards
Structure
- Clear hierarchy with consistent heading levels
- Table of contents for documents > 500 words
- Cross-references between related sections
- Progressive disclosure (basic → advanced)
Content
- Lead with the most important information
- Use active voice and direct instructions
- Include practical examples for every concept
- Provide both quick-start and comprehensive paths
Code Examples
- Validate all code examples for syntax correctness
- Include expected output where applicable
- Show error handling, not just happy path
- Use realistic, not trivial, examples
Format Guidelines
Markdown Best Practices
- Use fenced code blocks with language hints
- Tables for structured comparisons
- Consistent formatting throughout
API Documentation Standards
- HTTP method and path clearly visible
- All parameters documented (path, query, body, headers)
- Request and response examples
- Error responses with codes and messages
- Authentication requirements
Validation Loop (Required)
After generating any documentation, run validation until clean:
Run documentation validation:
python .claude/skills/writing-documentation/scripts/validate_docs.py <output_file>
Run code block syntax validation:
python .claude/skills/writing-documentation/scripts/check_code_blocks.py <output_file>
If ERRORs found in either:
- Fix all ERROR items (placeholders, empty code blocks, syntax errors)
- Re-run both validations
If WARNINGs found:
- Address straightforward warnings (missing language hints)
- Re-run validations
Repeat until both pass or only acceptable warnings remain.
Never deliver documentation with unresolved ERRORs.
Quality Checklist
Before delivering documentation, verify:
Integration with updating-readme
After creating a README:
- Future section updates → updating-readme skill
- Future dependency additions → updating-readme skill
- Future config changes → updating-readme skill
- Complete rewrites → back to this skill or agent
Examples
See examples/ for complete output samples:
examples/api-example.md — User Management API reference
examples/guide-example.md — CLI tool user guide
1---2name: writing-documentation3description: Creates technical documentation including READMEs, API references, user guides, architecture docs, ADRs, and runbooks. Use for requests to create, write, generate, or draft documentation. Trigger phrases include "document this", "write docs", "create readme", "API reference", "user guide", "architecture docs", "ADR", "runbook". For updating existing READMEs, use updating-readme instead.4---56# Writing Documentation78## Overview910Expert technical documentation skill for creating clear, accurate, user-friendly documentation. Handles lightweight documentation tasks directly and delegates comprehensive tasks to the writing-documentation agent.1112## When to Use This Skill1314Use writing-documentation when you need to create:15- **API documentation** from code (OpenAPI, endpoint references, authentication docs)16- **User guides** and tutorials (getting started, feature walkthroughs)17- **Architecture documentation** (system design, ADRs, component diagrams)18- **Operational docs** (runbooks, deployment guides, troubleshooting)19- **Project documentation** (comprehensive READMEs, CONTRIBUTING guides)2021## Handoff Rules2223### To updating-readme skill24For maintaining existing READMEs (section updates, dependency changes, minor edits), use updating-readme instead. This skill creates; updating-readme maintains.2526### To writing-documentation agent27Delegate to the writing-documentation agent via the Task tool when ANY of these apply:28- Output will be multiple files29- User guide will exceed 500 words30- Requires architecture documentation or ADRs31- API documentation requires analyzing more than 3 source files32- Creating documentation from scratch for an undocumented project33- Task requires deep codebase analysis3435**How to delegate:**36Use the Task tool with agent `writing-documentation`. Example:37```38Task: writing-documentation39Prompt: Create comprehensive API documentation for the authentication module including all endpoints, request/response schemas, and error codes.40```4142### Decision Matrix4344| Scenario | Handle Here | Delegate to Agent |45|----------|-------------|-------------------|46| Single README creation | ✓ | |47| API docs for 1-3 endpoints | ✓ | |48| Short user guide (<500 words) | ✓ | |49| Multi-file documentation site | | ✓ |50| Full API reference (10+ endpoints) | | ✓ |51| Architecture docs with ADRs | | ✓ |52| Comprehensive project docs | | ✓ |5354## Quick Reference5556| Doc Type | Workflow | Template |57|----------|----------|----------|58| API Reference | `workflows/api-docs.md` | `templates/api-reference.md` |59| User Guide | `workflows/user-guide.md` | `templates/user-guide.md` |60| Architecture | `workflows/architecture.md` | `templates/adr.md` |61| Troubleshooting | `workflows/troubleshooting.md` | — |62| Runbook | — | `templates/runbook.md` |63| README | — | `templates/readme-comprehensive.md` |6465## Process6667When asked to create documentation:68691. **Scope Assessment**: Determine if this should be delegated to the agent (see Decision Matrix above)702. **If delegating**: Use Task tool with writing-documentation agent713. **If handling here**:72 - Analyze the code/system to understand what needs documenting73 - **Read the appropriate workflow file:**74 - API docs → Read `workflows/api-docs.md`75 - User guide → Read `workflows/user-guide.md`76 - Architecture → Read `workflows/architecture.md`77 - Troubleshooting → Read `workflows/troubleshooting.md`78 - **Read the matching template:**79 - API docs → Read `templates/api-reference.md`80 - README → Read `templates/readme-comprehensive.md`81 - ADR → Read `templates/adr.md`82 - Runbook → Read `templates/runbook.md`83 - User guide → Read `templates/user-guide.md`84 - Follow the workflow steps85 - Run validation loop86 - Deliver documentation8788## Core Principles8990### Audience Awareness91Always identify the target audience before writing:92- **End Users**: Simple language, task-oriented, minimal jargon93- **Developers**: Technical details, code examples, API specifics94- **Administrators**: Configuration, deployment, maintenance95- **Contributors**: Architecture, conventions, processes9697### Documentation Standards9899**Structure**100- Clear hierarchy with consistent heading levels101- Table of contents for documents > 500 words102- Cross-references between related sections103- Progressive disclosure (basic → advanced)104105**Content**106- Lead with the most important information107- Use active voice and direct instructions108- Include practical examples for every concept109- Provide both quick-start and comprehensive paths110111**Code Examples**112- Validate all code examples for syntax correctness113- Include expected output where applicable114- Show error handling, not just happy path115- Use realistic, not trivial, examples116117### Format Guidelines118119**Markdown Best Practices**120- Use fenced code blocks with language hints121- Tables for structured comparisons122- Consistent formatting throughout123124**API Documentation Standards**125- HTTP method and path clearly visible126- All parameters documented (path, query, body, headers)127- Request and response examples128- Error responses with codes and messages129- Authentication requirements130131## Validation Loop (Required)132133After generating any documentation, run validation until clean:1341351. **Run documentation validation**:136 ```bash137 python .claude/skills/writing-documentation/scripts/validate_docs.py <output_file>138 ```1391402. **Run code block syntax validation**:141 ```bash142 python .claude/skills/writing-documentation/scripts/check_code_blocks.py <output_file>143 ```1441453. **If ERRORs found in either**:146 - Fix all ERROR items (placeholders, empty code blocks, syntax errors)147 - Re-run both validations1481494. **If WARNINGs found**:150 - Address straightforward warnings (missing language hints)151 - Re-run validations1521535. **Repeat** until both pass or only acceptable warnings remain.1541556. **Never deliver documentation with unresolved ERRORs.**156157## Quality Checklist158159Before delivering documentation, verify:160- [ ] Target audience is clear161- [ ] All code examples are syntactically correct162- [ ] No placeholder text remains163- [ ] Cross-references are valid164- [ ] Prerequisites are complete165- [ ] Examples are realistic and useful166- [ ] Error cases are documented167- [ ] Document is self-contained (or links to dependencies)168- [ ] Validation script passes169170## Integration with updating-readme171172After creating a README:173- Future section updates → updating-readme skill174- Future dependency additions → updating-readme skill175- Future config changes → updating-readme skill176- Complete rewrites → back to this skill or agent177178## Examples179180See `examples/` for complete output samples:181- `examples/api-example.md` — User Management API reference182- `examples/guide-example.md` — CLI tool user guide