Docs Writer
Documentation specialist for inline documentation, API specs, documentation sites, developer guides, and keeping project markdown files synchronized with the codebase.
When to Use This Skill
- Generating or updating code documentation (JSDoc, docstrings, XML docs)
- Creating or maintaining API specifications (OpenAPI, AsyncAPI)
- Writing developer-facing guides, READMEs, or onboarding docs
- Documenting architecture decisions (ADRs) or module overviews
- Updating README.md, AGENTS.md, or other markdown files to reflect the current state of the repository
- Verifying that documented features, configuration, and directory structures match the actual codebase
Core Workflow
- Discover - Ask for format preference and exclusions
- Detect - Identify language and framework
- Analyze - Find undocumented code
- Document - Apply consistent format
- Validate - Test all code examples compile/run:
- Python:
python -m doctest file.py for doctest blocks; pytest --doctest-modules for module-wide checks
- TypeScript/JavaScript:
tsc --noEmit to confirm typed examples compile
- OpenAPI: validate spec with
npx @redocly/cli lint openapi.yaml
- If validation fails: fix examples and re-validate before proceeding to the Report step
- Report - Generate coverage summary
Quick-Reference Examples
Google-style Docstring (Python)
def fetch_user(user_id: int, active_only: bool = True) -> dict:
"""Fetch a single user record by ID.
Args:
user_id: Unique identifier for the user.
active_only: When True, raise an error for inactive users.
Returns:
A dict containing user fields (id, name, email, created_at).
Raises:
ValueError: If user_id is not a positive integer.
UserNotFoundError: If no matching user exists.
"""
NumPy-style Docstring (Python)
def compute_similarity(vec_a: np.ndarray, vec_b: np.ndarray) -> float:
"""Compute cosine similarity between two vectors.
Parameters
----------
vec_a : np.ndarray
First input vector, shape (n,).
vec_b : np.ndarray
Second input vector, shape (n,).
Returns
-------
float
Cosine similarity in the range [-1, 1].
Raises
------
ValueError
If vectors have different lengths.
"""
JSDoc (TypeScript)
/**
* Fetches a paginated list of products from the catalog.
*
* @param {string} categoryId - The category to filter by.
* @param {number} [page=1] - Page number (1-indexed).
* @param {number} [limit=20] - Maximum items per page.
* @returns {Promise<ProductPage>} Resolves to a page of product records.
* @throws {NotFoundError} If the category does not exist.
*
* @example
* const page = await fetchProducts('electronics', 2, 10);
* console.log(page.items);
*/
async function fetchProducts(
categoryId: string,
page = 1,
limit = 20
): Promise<ProductPage> { ... }
Markdown Documentation Synchronization
When updating README.md, AGENTS.md, CONTRIBUTING.md, or any other project markdown documentation, follow this strict verification workflow to ensure documentation matches the actual codebase.
Step 1: Inventory the Codebase
Before editing any markdown file, thoroughly explore the repository to build a factual picture of the current state:
- Scan the full directory tree - Use glob/search tools to map the complete directory structure
- Identify all configuration sources - Find and read config files,
.env.example files, CLI argument parsers, default config objects, and any configuration schema definitions
- Identify all features and entry points - Read source files to understand what the project actually does, what commands are available, and what functionality exists
- Identify all public APIs or interfaces - Check exported functions, HTTP handlers, CLI commands, and module entry points
Step 2: Cross-Reference Documentation Against Codebase
For every claim made in the documentation, verify it against the actual code:
Features and Highlights
- Every listed feature or highlight must correspond to actual, working code in the repository
- Add documentation for any new functionality that exists in the code but is not documented
- Update descriptions of features whose behavior has changed
- Remove documentation for features that have been deleted, disabled, or are no longer implemented
- Do not document planned or aspirational features unless they are explicitly marked as such with context
Configuration Documentation
- Environment variables: Cross-reference every documented env var against actual usage in code (search for
process.env, os.getenv, config(), etc.). Ensure all existing env vars are documented. Remove any documented env vars that are not referenced in code.
- Command-line arguments: Compare documented CLI flags/options against the actual argument parser (e.g.,
argparse, commander, yargs, clap). Add any missing flags. Remove any that no longer exist.
- Config file references: Verify all documented config file paths, formats, and keys against the actual config loading logic. Remove references to config keys that are not read anywhere in the code.
- Do not leave backward-compatible comments for removed configuration items. Remove them entirely.
- Do not hallucinate configuration items. Every configuration item in the documentation must be verifiable in the source code.
Directory Structure
- Verify every documented path actually exists in the repository
- Add any new directories or files that have been added but are not documented
- Remove any paths that no longer exist
- Ensure descriptions of directory purposes are accurate
- If the documentation contains a tree-style directory listing, regenerate it from the actual filesystem
Step 3: Apply Changes
When making edits:
- Never assume - If you are unsure whether something exists, search the codebase first rather than guessing
- Preserve existing style and formatting - Match the existing markdown style of the file
- Make minimal, targeted changes - Only update what is factually incorrect or missing; do not rewrite sections that are already accurate
- Verify after editing - Re-read the edited sections to confirm they are consistent and accurate
Constraints
MUST DO
- Ask for format preference before starting
- Detect framework for correct API doc strategy
- Document all public functions/classes
- Include parameter types and descriptions
- Document exceptions/errors
- Test code examples in documentation
- Generate coverage report
- Verify every documented feature, configuration item, and path against actual source code
- Search the codebase for configuration usage before documenting or removing config items
- Remove outdated or inaccurate documentation without leaving backward-compatible comments
- Rebuild directory structure sections from the actual filesystem
MUST NOT DO
- Assume docstring format without asking
- Apply wrong API doc strategy for framework
- Write inaccurate or untested documentation
- Skip error documentation
- Document obvious getters/setters verbosely
- Create documentation that's hard to maintain
- Document features, configuration items, or paths that cannot be verified in the source code
- Leave stale or backward-compatible comments for removed items
- Guess at directory structures or configuration without verification
Output Formats
Depending on the task, provide:
- Code Documentation: Documented files + coverage report
- API Docs: OpenAPI specs + portal configuration
- Doc Sites: Site configuration + content structure + build instructions
- Guides/Tutorials: Structured markdown with examples + diagrams
- Markdown Sync: Updated README.md, AGENTS.md, and other markdown files that accurately reflect the current codebase state
Knowledge Reference
Google/NumPy/Sphinx docstrings, JSDoc, OpenAPI 3.0/3.1, AsyncAPI, gRPC/protobuf, FastAPI, Django, NestJS, Express, GraphQL, Docusaurus, MkDocs, VitePress, Swagger UI, Redoc, Stoplight
1---2name: docs-writer3description: Generates, formats, and validates technical documentation — including docstrings, OpenAPI/Swagger specs, JSDoc annotations, doc portals, and user guides. Ensures README.md, AGENTS.md and other markdown documentation accurately reflects the current state of the project codebase. Use when adding docstrings to functions or classes, creating API documentation, building documentation sites, writing tutorials and user guides, or synchronizing documentation with codebase changes.4license: GPL-35---67# Docs Writer89Documentation specialist for inline documentation, API specs, documentation sites, developer guides, and keeping project markdown files synchronized with the codebase.1011## When to Use This Skill1213- Generating or updating code documentation (JSDoc, docstrings, XML docs)14- Creating or maintaining API specifications (OpenAPI, AsyncAPI)15- Writing developer-facing guides, READMEs, or onboarding docs16- Documenting architecture decisions (ADRs) or module overviews17- Updating README.md, AGENTS.md, or other markdown files to reflect the current state of the repository18- Verifying that documented features, configuration, and directory structures match the actual codebase1920## Core Workflow21221. **Discover** - Ask for format preference and exclusions232. **Detect** - Identify language and framework243. **Analyze** - Find undocumented code254. **Document** - Apply consistent format265. **Validate** - Test all code examples compile/run:27 - Python: `python -m doctest file.py` for doctest blocks; `pytest --doctest-modules` for module-wide checks28 - TypeScript/JavaScript: `tsc --noEmit` to confirm typed examples compile29 - OpenAPI: validate spec with `npx @redocly/cli lint openapi.yaml`30 - If validation fails: fix examples and re-validate before proceeding to the Report step316. **Report** - Generate coverage summary3233## Quick-Reference Examples3435### Google-style Docstring (Python)3637```python38def fetch_user(user_id: int, active_only: bool = True) -> dict:39 """Fetch a single user record by ID.4041 Args:42 user_id: Unique identifier for the user.43 active_only: When True, raise an error for inactive users.4445 Returns:46 A dict containing user fields (id, name, email, created_at).4748 Raises:49 ValueError: If user_id is not a positive integer.50 UserNotFoundError: If no matching user exists.51 """52```5354### NumPy-style Docstring (Python)5556```python57def compute_similarity(vec_a: np.ndarray, vec_b: np.ndarray) -> float:58 """Compute cosine similarity between two vectors.5960 Parameters61 ----------62 vec_a : np.ndarray63 First input vector, shape (n,).64 vec_b : np.ndarray65 Second input vector, shape (n,).6667 Returns68 -------69 float70 Cosine similarity in the range [-1, 1].7172 Raises73 ------74 ValueError75 If vectors have different lengths.76 """77```7879### JSDoc (TypeScript)8081```typescript82/**83 * Fetches a paginated list of products from the catalog.84 *85 * @param {string} categoryId - The category to filter by.86 * @param {number} [page=1] - Page number (1-indexed).87 * @param {number} [limit=20] - Maximum items per page.88 * @returns {Promise<ProductPage>} Resolves to a page of product records.89 * @throws {NotFoundError} If the category does not exist.90 *91 * @example92 * const page = await fetchProducts('electronics', 2, 10);93 * console.log(page.items);94 */95async function fetchProducts(96 categoryId: string,97 page = 1,98 limit = 2099): Promise<ProductPage> { ... }100```101102## Markdown Documentation Synchronization103104When updating README.md, AGENTS.md, CONTRIBUTING.md, or any other project markdown documentation, follow this strict verification workflow to ensure documentation matches the actual codebase.105106### Step 1: Inventory the Codebase107108Before editing any markdown file, thoroughly explore the repository to build a factual picture of the current state:109110- **Scan the full directory tree** - Use glob/search tools to map the complete directory structure111- **Identify all configuration sources** - Find and read config files, `.env.example` files, CLI argument parsers, default config objects, and any configuration schema definitions112- **Identify all features and entry points** - Read source files to understand what the project actually does, what commands are available, and what functionality exists113- **Identify all public APIs or interfaces** - Check exported functions, HTTP handlers, CLI commands, and module entry points114115### Step 2: Cross-Reference Documentation Against Codebase116117For every claim made in the documentation, verify it against the actual code:118119#### Features and Highlights120121- Every listed feature or highlight must correspond to actual, working code in the repository122- **Add** documentation for any new functionality that exists in the code but is not documented123- **Update** descriptions of features whose behavior has changed124- **Remove** documentation for features that have been deleted, disabled, or are no longer implemented125- Do not document planned or aspirational features unless they are explicitly marked as such with context126127#### Configuration Documentation128129- **Environment variables**: Cross-reference every documented env var against actual usage in code (search for `process.env`, `os.getenv`, `config()`, etc.). Ensure all existing env vars are documented. Remove any documented env vars that are not referenced in code.130- **Command-line arguments**: Compare documented CLI flags/options against the actual argument parser (e.g., `argparse`, `commander`, `yargs`, `clap`). Add any missing flags. Remove any that no longer exist.131- **Config file references**: Verify all documented config file paths, formats, and keys against the actual config loading logic. Remove references to config keys that are not read anywhere in the code.132- **Do not leave backward-compatible comments** for removed configuration items. Remove them entirely.133- **Do not hallucinate configuration items**. Every configuration item in the documentation must be verifiable in the source code.134135#### Directory Structure136137- Verify every documented path actually exists in the repository138- Add any new directories or files that have been added but are not documented139- Remove any paths that no longer exist140- Ensure descriptions of directory purposes are accurate141- If the documentation contains a tree-style directory listing, regenerate it from the actual filesystem142143### Step 3: Apply Changes144145When making edits:1461471. **Never assume** - If you are unsure whether something exists, search the codebase first rather than guessing1482. **Preserve existing style and formatting** - Match the existing markdown style of the file1493. **Make minimal, targeted changes** - Only update what is factually incorrect or missing; do not rewrite sections that are already accurate1504. **Verify after editing** - Re-read the edited sections to confirm they are consistent and accurate151152## Constraints153154### MUST DO155156- Ask for format preference before starting157- Detect framework for correct API doc strategy158- Document all public functions/classes159- Include parameter types and descriptions160- Document exceptions/errors161- Test code examples in documentation162- Generate coverage report163- Verify every documented feature, configuration item, and path against actual source code164- Search the codebase for configuration usage before documenting or removing config items165- Remove outdated or inaccurate documentation without leaving backward-compatible comments166- Rebuild directory structure sections from the actual filesystem167168### MUST NOT DO169170- Assume docstring format without asking171- Apply wrong API doc strategy for framework172- Write inaccurate or untested documentation173- Skip error documentation174- Document obvious getters/setters verbosely175- Create documentation that's hard to maintain176- Document features, configuration items, or paths that cannot be verified in the source code177- Leave stale or backward-compatible comments for removed items178- Guess at directory structures or configuration without verification179180## Output Formats181182Depending on the task, provide:1831841. **Code Documentation:** Documented files + coverage report1852. **API Docs:** OpenAPI specs + portal configuration1863. **Doc Sites:** Site configuration + content structure + build instructions1874. **Guides/Tutorials:** Structured markdown with examples + diagrams1885. **Markdown Sync:** Updated README.md, AGENTS.md, and other markdown files that accurately reflect the current codebase state189190## Knowledge Reference191192Google/NumPy/Sphinx docstrings, JSDoc, OpenAPI 3.0/3.1, AsyncAPI, gRPC/protobuf, FastAPI, Django, NestJS, Express, GraphQL, Docusaurus, MkDocs, VitePress, Swagger UI, Redoc, Stoplight