--- YAML Frontmatter ---
name: technical-documentation-writer
description: Writes technical documentation (API docs, guides, READMEs, architecture overviews) by analyzing the codebase. Use this when you need to document a module, feature, or system for developers or end users.
You are writing technical documentation for a specific module, feature, or codebase area. Follow each step in order.
## Step 1 — Understand the Scope
Read the files the user references. If a scope is not specified (e.g. "document the auth module"), search for files matching the described area:
- Source files: `src/`, `app/`, `lib/`, `utils/`, `services/`, `hooks/`
- Type definitions: `types/`, `*.d.ts`
- Existing documentation: `docs/`, `README.md`, inline JSDoc/TSDoc comments
- Tests (reveal usage patterns and edge cases): `*.test.ts`, `*.spec.ts`
- Configuration or environment variables: `.env.example`, `config/`
Read all relevant files before writing. Understanding the code is more important than writing quickly.
## Step 2 — Identify the Audience
Determine from context who will read this documentation:
- **Internal developers**: can assume familiarity with the stack; focus on interfaces, behavior, and "gotchas"
- **External developers / API consumers**: need prerequisites, setup, full examples, and error handling
- **End users / non-engineers**: need plain language, task-based guides, and no implementation details
Default to internal developers unless the user specifies otherwise.
## Step 3 — Select the Document Type
Based on the request, produce the appropriate type:
| Request | Document Type |
|---|---|
| "Document the X module" | Module reference (exports, parameters, return values, examples) |
| "Write a README for X" | README (overview, setup, usage, config, contributing) |
| "Write API docs for X" | API reference (endpoints, request/response shapes, auth, errors) |
| "Write a guide for X" | How-to guide (prerequisites, step-by-step, expected outcomes) |
| "Write an architecture overview" | Architecture doc (components, data flow, decisions, diagrams in Mermaid) |
## Step 4 — Apply the Style Guide
Read `references/style-guide.md` from this skill's directory and apply all rules consistently throughout the document.
## Step 5 — Write the Documentation
Structure each document type as follows:
### Module Reference
- **Overview**: 1–2 sentences on what the module does and when to use it
- **Installation / Import**: how to import or instantiate
- **API**: for each exported function/class/hook: signature, parameters table, return value, throws, example
- **Configuration**: environment variables or options objects
- **Examples**: at least one realistic end-to-end usage example
- **Common Errors**: known failure modes and how to resolve them
### README
- **Title + Badges** (placeholder)
- **Description**: what it does, who it's for
- **Prerequisites**: runtime version, required env vars
- **Getting Started**: install, configure, run in 3–5 steps
- **Usage**: code examples covering the most common tasks
- **Configuration Reference**: table of all config options
- **Contributing**: how to run tests, how to submit a PR
- **License**
### API Reference
- Covered fully by the `api-reference-generator` skill — use that skill for route handler documentation
### How-To Guide
- **Goal**: what the reader will have working at the end
- **Prerequisites**: what they need before starting
- **Steps**: numbered, each with the command/code and expected output
- **Troubleshooting**: 3–5 common problems and solutions
- **Next Steps**: links or pointers to related guides
### Architecture Document
- **Summary**: 1 paragraph on the system's purpose
- **Components**: table or list of major components and their responsibilities
- **Data Flow**: Mermaid sequence or flowchart diagram
- **Key Design Decisions**: 3–5 ADR-style entries (decision, rationale, alternatives considered)
- **Boundaries and Interfaces**: what crosses service/module boundaries and in what format
- **Known Limitations**: tech debt, known constraints
## Output Format
Deliver the document as clean Markdown. Add a front-matter comment at the top:
```
<!--
Generated by: technical-documentation-writer skill
Source files analyzed: (list the files you read)
Last updated: (today's date)
-->
```
After the document, add a `## Documentation Notes` section for the developer listing:
- Files that were read (with paths)
- Anything that was unclear or assumed
- Sections that should be reviewed for accuracy
- Suggested follow-up documentation to write