Target: $ARGUMENTS
Parse $ARGUMENTS as follows:
- Empty → ask what to document and what type (API reference / architecture / README / runbook / ADR)
- File path(s) or glob → document those files; infer the best doc type from content
api <path>→ API reference for that patharch→ architecture overview for the whole projectreadme <path>→ module README for that directoryrunbook <topic>→ operational runbook for that topicadr <title>→ architecture decision record with that title
Read all relevant source files before writing anything. Documentation that misrepresents the code is worse than no documentation.
Ask (or infer from context) which of these is needed:
- API reference — functions, classes, endpoints with params/returns/errors
- Architecture overview — how the system fits together
- Module / package README — purpose, usage, examples
- Runbook / operational guide — how to run, deploy, debug
- Decision record (ADR) — why something was built the way it was
Produce only what was asked for. Don't generate all types speculatively.
For each public function / method / endpoint:
### functionName(param1: Type, param2: Type) → ReturnType
One-sentence description of what it does (not how).
**Parameters**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| param1 | string | yes | ... |
| param2 | number | no | Default: 0. ... |
**Returns**
Description of return value and shape.
**Throws / Errors**
- `ErrorType` — when this happens
- HTTP 404 — resource not found
**Example**
```lang
// minimal working example
Notes Edge cases, gotchas, deprecation notices.
Rules:
- Document behavior, not implementation.
- Examples must be minimal and actually work.
- Don't document private/internal functions unless asked.
- If a parameter's purpose isn't obvious from name + type, explain it.
---
## Architecture Overview
Structure:
1. **Purpose** — what problem does this system solve, for whom
2. **Components** — list each major component, one-line role, what it owns
3. **Data flow** — how a request / event moves through the system (use ASCII diagram if helpful)
4. **Key dependencies** — external services, databases, queues — and what fails if they're down
5. **Constraints & trade-offs** — decisions that affect future development (e.g. "single-region by design", "no background jobs — polling only")
6. **What's not here** — explicitly call out scope boundaries
---
## Module README
Structure:
```markdown
# Module Name
One-sentence description.
## What it does
2–4 sentences. No marketing language.
## When to use it (and when not to)
## Installation / Setup
Minimal steps. Real commands.
## Usage
Minimal working example first. More complex examples after.
## Configuration
Table of env vars / config options.
## API
[link to or inline API reference]
## Known limitations
- Write for the reader who is new to this code but experienced in the domain.
- Concrete over abstract. Show examples before explaining principles.
- Don't explain what the language or framework does — explain what this code does.
- If the code is unclear and you're uncertain what it does, say so rather than guessing.
- Use present tense: "Returns the user object" not "Will return" or "Returns a user object that represents".
- Match the terminology used in the codebase and domain, don't introduce synonyms.
- Avoid: "simply", "just", "easy", "straightforward", "obviously".