Documentation Skill
Goal
Generate accurate, useful documentation for public APIs, modules, and the project README. Documentation describes WHY and WHAT (not HOW — the code shows how). All examples must be working code.
Steps
Identify what needs documentation
- Public functions, methods, and classes (not private internals)
- API endpoints (generate from OpenAPI spec or create if missing)
- Complex business logic with non-obvious behavior
- README sections that are outdated or missing
Write function/method docstrings
TypeScript (JSDoc):
/**
* Creates a new user account and sends a verification email.
*
* @param dto - User creation data (email, name, password)
* @returns The created user without sensitive fields
* @throws {EmailAlreadyExistsError} If email is already registered
* @throws {WeakPasswordError} If password doesn't meet requirements
*
* @example
* const user = await createUser({
* email: 'alice@example.com',
* name: 'Alice',
* password: 'SecureP@ss123'
* });
* // Returns: { id: 'uuid', email: 'alice@example.com', name: 'Alice' }
*/
async function createUser(dto: CreateUserDto): Promise<UserDto>
PHP (PHPDoc):
/**
* Creates a new user account and sends a verification email.
*
* @param CreateUserData $data User creation data
* @return UserResource The created user resource
* @throws EmailAlreadyExistsException If email is already registered
*
* @example
* $user = $this->createUser->handle(new CreateUserData(
* email: 'alice@example.com',
* name: 'Alice',
* ));
*/
public function handle(CreateUserData $data): UserResource
Python (Google Style / Sphinx):
def create_user(dto: CreateUserDto) -> UserDto:
"""Creates a new user account and sends a verification email.
Args:
dto (CreateUserDto): User creation data (email, name, password).
Returns:
UserDto: The created user without sensitive fields.
Raises:
ValueError: If email is already registered.
Example:
>>> user = create_user(CreateUserDto(email="alice@example.com", ...))
>>> print(user.id)
"""
...
Verify examples are working
- Every code example in documentation must actually work
- Run the example code to verify it doesn't throw or produce wrong output
- If the example would require a running server/DB: note the prerequisite clearly
Update README_FULL.md
- README sections to check:
- Getting Started: install + first run commands
- Available commands: from AGENTS.md Section 2 (keep in sync)
- Architecture overview: high-level description + link to C4 diagrams
- Contributing: how to run tests, branch naming, PR process
- Environment variables: list all required env vars with descriptions
- README must reflect the CURRENT state of the project, not aspirations
Generate API documentation
If OpenAPI spec exists at docs/api/openapi.yaml:
# Scalar API docs (modern UI)
npx @scalar/cli serve docs/api/openapi.yaml
# Redoc (alternative)
npx @redocly/cli preview-docs docs/api/openapi.yaml
Generate module documentation (if tooling configured)
# TypeDoc for TypeScript
npx typedoc src/ --out docs/typedoc/
# JSDoc for JavaScript
npx jsdoc src/ -r -d docs/jsdoc/
# Laravel Scribe for PHP APIs
php artisan scribe:generate
# MkDocs (Python)
uv run mkdocs build
Check for outdated documentation
- Scan for function signatures in docs that don't match current code
- Check for documented parameters that no longer exist
- Check for examples that import from paths that have moved
Constraints
- Only document PUBLIC API surface (not private implementation details)
- NEVER document what the code obviously does — document WHY it works that way
- All code examples must be verified working
- Do not create documentation files unless explicitly requested — update existing ones
Output Format
Updated docstrings in modified files + updated README sections. Report: "[N] functions documented, README sections updated: [list]."
1---2name: documentation-63description: Generate docstrings, JSDoc, API docs, and README updates that reflect current code4---5
6# Documentation Skill
7
8## Goal
9Generate accurate, useful documentation for public APIs, modules, and the project README. Documentation describes WHY and WHAT (not HOW — the code shows how). All examples must be working code.
10
11## Steps
12
131. **Identify what needs documentation**
14 - Public functions, methods, and classes (not private internals)
15 - API endpoints (generate from OpenAPI spec or create if missing)
16 - Complex business logic with non-obvious behavior
17 - README sections that are outdated or missing
18
192. **Write function/method docstrings**
20
21 **TypeScript (JSDoc):**
22 ```typescript
23 /**
24 * Creates a new user account and sends a verification email.
25 *
26 * @param dto - User creation data (email, name, password)
27 * @returns The created user without sensitive fields
28 * @throws {EmailAlreadyExistsError} If email is already registered
29 * @throws {WeakPasswordError} If password doesn't meet requirements
30 *
31 * @example
32 * const user = await createUser({
33 * email: 'alice@example.com',
34 * name: 'Alice',
35 * password: 'SecureP@ss123'
36 * });
37 * // Returns: { id: 'uuid', email: 'alice@example.com', name: 'Alice' }
38 */
39 async function createUser(dto: CreateUserDto): Promise<UserDto>
40 ```
41
42 **PHP (PHPDoc):**
43 ```php
44 /**
45 * Creates a new user account and sends a verification email.
46 *
47 * @param CreateUserData $data User creation data
48 * @return UserResource The created user resource
49 * @throws EmailAlreadyExistsException If email is already registered
50 *
51 * @example
52 * $user = $this->createUser->handle(new CreateUserData(
53 * email: 'alice@example.com',
54 * name: 'Alice',
55 * ));
56 */
57 public function handle(CreateUserData $data): UserResource
58 ```
59
60 **Python (Google Style / Sphinx):**
61 ```python
62 def create_user(dto: CreateUserDto) -> UserDto:
63 """Creates a new user account and sends a verification email.
64
65 Args:
66 dto (CreateUserDto): User creation data (email, name, password).
67
68 Returns:
69 UserDto: The created user without sensitive fields.
70
71 Raises:
72 ValueError: If email is already registered.
73
74 Example:
75 >>> user = create_user(CreateUserDto(email="alice@example.com", ...))
76 >>> print(user.id)
77 """
78 ...
79 ```
80
813. **Verify examples are working**
82 - Every code example in documentation must actually work
83 - Run the example code to verify it doesn't throw or produce wrong output
84 - If the example would require a running server/DB: note the prerequisite clearly
85
864. **Update README_FULL.md**
87 - README sections to check:
88 - **Getting Started**: install + first run commands
89 - **Available commands**: from AGENTS.md Section 2 (keep in sync)
90 - **Architecture overview**: high-level description + link to C4 diagrams
91 - **Contributing**: how to run tests, branch naming, PR process
92 - **Environment variables**: list all required env vars with descriptions
93 - README must reflect the CURRENT state of the project, not aspirations
94
955. **Generate API documentation**
96 If OpenAPI spec exists at `docs/api/openapi.yaml`:
97 ```bash
98 # Scalar API docs (modern UI)
99 npx @scalar/cli serve docs/api/openapi.yaml
100
101 # Redoc (alternative)
102 npx @redocly/cli preview-docs docs/api/openapi.yaml
103 ```
104
1056. **Generate module documentation** (if tooling configured)
106 ```bash
107 # TypeDoc for TypeScript
108 npx typedoc src/ --out docs/typedoc/
109
110 # JSDoc for JavaScript
111 npx jsdoc src/ -r -d docs/jsdoc/
112
113 # Laravel Scribe for PHP APIs
114 php artisan scribe:generate
115
116 # MkDocs (Python)
117 uv run mkdocs build
118 ```
119
1207. **Check for outdated documentation**
121 - Scan for function signatures in docs that don't match current code
122 - Check for documented parameters that no longer exist
123 - Check for examples that import from paths that have moved
124
125## Constraints
126- Only document PUBLIC API surface (not private implementation details)
127- NEVER document what the code obviously does — document WHY it works that way
128- All code examples must be verified working
129- Do not create documentation files unless explicitly requested — update existing ones
130
131## Output Format
132Updated docstrings in modified files + updated README sections. Report: "[N] functions documented, README sections updated: [list]."