Documentation
Generate and update documentation from code, OpenAPI/schemas, and project context. Keep docs in sync with implementation.
When to Use
- User wants a README, API docs, or inline docs
- User asks to document a module, function, or API
- User wants docs updated after code changes
- New project needs initial documentation
Workflow
- Identify target: What needs documenting? (repo, module, API, CLI)
- Gather sources: Code, types, OpenAPI/schema, existing docs
- Choose format: README, JSDoc/TSDoc, API reference, user guide
- Draft: Structure first, then fill from code/context
- Verify: Links, code blocks, commands actually run
Documentation Types
| Type |
When |
Output |
| README |
Project or package overview |
README.md with install, usage, API summary |
| API reference |
Functions, endpoints, types |
JSDoc, or docs/api.md, or OpenAPI-derived |
| User guide |
How to use a feature or product |
Step-by-step, examples, troubleshooting |
| Inline docs |
Functions, classes, exports |
JSDoc/TSDoc, docstrings |
| Changelog |
Release history |
CHANGELOG.md format |
README Structure
# Project Name
[One-line description]
## Install
\`\`\`bash
npm install <package>
\`\`\`
## Quick Start
[Minimal example to get running]
## Usage
[Main use cases with examples]
## API
[Summary or link to full API docs]
## Config
[Options, env vars, config file]
## Contributing / License
[Brief or link]
Infer content from: package.json (name, description, scripts), main entry, existing tests.
API Documentation
For code APIs (exports, functions):
- Use JSDoc/TSDoc:
@param, @returns, @example
- One sentence summary, then params, return, throws, example
- Keep examples runnable and short
For HTTP/REST APIs:
- If OpenAPI/Swagger exists, derive sections from it
- Include: endpoint, method, params, body schema, response, example
- Group by resource or tag
For CLI:
- Document command, options, subcommands
- One example per common use case
- Exit codes or errors if non-obvious
Inline Docs (JSDoc/TSDoc)
/**
* Fetches user by ID. Returns null if not found.
*
* @param id - User UUID
* @param options - Optional fetch settings
* @returns User or null
* @throws {NetworkError} When request fails
*
* @example
* const user = await getUser("abc-123");
*/
export async function getUser(id: string, options?: FetchOptions): Promise<User | null> {
Extract types from signature; don't repeat them in prose. Focus on intent, edge cases, and examples.
Keeping Docs in Sync
- After refactors: update README examples, API section, and affected JSDoc
- When adding params or return types: update JSDoc and any API.md
- When changing CLI flags: update CLI docs and README usage
Check: Do code blocks run? Do linked files exist? Are version numbers current?
Tone and Style
- Present tense ("Returns the user" not "Will return")
- Second person for user-facing ("You can pass..." or "Pass a path to...")
- Short sentences; bullets for lists
- Code examples over long prose
Anti-Patterns
- ❌ README that only says "See code"
- ❌ API docs that duplicate the type signature with no explanation
- ❌ Outdated examples that don't run
- ❌ Missing install or run instructions for a package
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: documentation-23description: Generate or update documentation from code, APIs, and context. Use when documenting code, writing README, API docs, or keeping docs in sync with implementation. Use when this capability is needed.4---56# Documentation78Generate and update documentation from code, OpenAPI/schemas, and project context. Keep docs in sync with implementation.910## When to Use1112- User wants a README, API docs, or inline docs13- User asks to document a module, function, or API14- User wants docs updated after code changes15- New project needs initial documentation1617## Workflow18191. **Identify target**: What needs documenting? (repo, module, API, CLI)202. **Gather sources**: Code, types, OpenAPI/schema, existing docs213. **Choose format**: README, JSDoc/TSDoc, API reference, user guide224. **Draft**: Structure first, then fill from code/context235. **Verify**: Links, code blocks, commands actually run2425## Documentation Types2627| Type | When | Output |28| ----------------- | ------------------------------- | ------------------------------------------ |29| **README** | Project or package overview | README.md with install, usage, API summary |30| **API reference** | Functions, endpoints, types | JSDoc, or docs/api.md, or OpenAPI-derived |31| **User guide** | How to use a feature or product | Step-by-step, examples, troubleshooting |32| **Inline docs** | Functions, classes, exports | JSDoc/TSDoc, docstrings |33| **Changelog** | Release history | CHANGELOG.md format |3435## README Structure3637```markdown38# Project Name3940[One-line description]4142## Install4344\`\`\`bash45npm install <package>46\`\`\`4748## Quick Start4950[Minimal example to get running]5152## Usage5354[Main use cases with examples]5556## API5758[Summary or link to full API docs]5960## Config6162[Options, env vars, config file]6364## Contributing / License6566[Brief or link]67```6869Infer content from: `package.json` (name, description, scripts), main entry, existing tests.7071## API Documentation7273For **code APIs** (exports, functions):74- Use JSDoc/TSDoc: `@param`, `@returns`, `@example`75- One sentence summary, then params, return, throws, example76- Keep examples runnable and short7778For **HTTP/REST APIs**:79- If OpenAPI/Swagger exists, derive sections from it80- Include: endpoint, method, params, body schema, response, example81- Group by resource or tag8283For **CLI**:84- Document command, options, subcommands85- One example per common use case86- Exit codes or errors if non-obvious8788## Inline Docs (JSDoc/TSDoc)8990```typescript91/**92 * Fetches user by ID. Returns null if not found.93 *94 * @param id - User UUID95 * @param options - Optional fetch settings96 * @returns User or null97 * @throws {NetworkError} When request fails98 *99 * @example100 * const user = await getUser("abc-123");101 */102export async function getUser(id: string, options?: FetchOptions): Promise<User | null> {103```104105Extract types from signature; don't repeat them in prose. Focus on intent, edge cases, and examples.106107## Keeping Docs in Sync108109- After refactors: update README examples, API section, and affected JSDoc110- When adding params or return types: update JSDoc and any API.md111- When changing CLI flags: update CLI docs and README usage112113Check: Do code blocks run? Do linked files exist? Are version numbers current?114115## Tone and Style116117- Present tense ("Returns the user" not "Will return")118- Second person for user-facing ("You can pass..." or "Pass a path to...")119- Short sentences; bullets for lists120- Code examples over long prose121122## Anti-Patterns123124- ❌ README that only says "See code"125- ❌ API docs that duplicate the type signature with no explanation126- ❌ Outdated examples that don't run127- ❌ Missing install or run instructions for a package128129---130> Converted and distributed by [TomeVault](https://tomevault.io/claim/lvndry) — claim your Tome and manage your conversions.131<!-- tomevault:4.0:skill_md:2026-04-11 -->