| name | document |
| description | Generate or update documentation for an existing codebase. Use when the user needs a README, API reference, module-level docs, or inline code comments written or refreshed based on the actual code. |
Document
Generate accurate, useful documentation for existing code.
Steps
-
Identify the scope — Ask the user what to document if not specified:
- Whole project (README + overview)
- A specific module or file (API docs, inline comments)
- A public API (function signatures, parameters, return values, examples)
- CLI usage (commands, flags, examples)
-
Read the code — Before writing anything, read the relevant source files. Do not invent behavior — document what the code actually does.
-
Generate the documentation:
For README:
- Project name and one-line description
- What problem it solves and who it's for
- Installation steps (tested against the actual project)
- Quick start example (runnable)
- Key features
- Configuration options (if any)
- Contributing guide (brief)
- License
For API/module docs:
- Purpose of the module
- Each exported function/class: parameters, return type, behavior, edge cases
- Usage examples for non-trivial functions
- Error conditions
For inline comments:
- Add comments only where logic is non-obvious
- Explain why, not what (the code already shows what)
- Do not comment every line
-
Present the output — Show the generated docs. Ask for review before writing to files.
-
Write to files — After confirmation, write the documentation to the appropriate location.
Rules
- Never describe what the code should do — only what it does do.
- Keep examples minimal and runnable.
- Do not pad with filler text. Every sentence should be useful.