description: Create documentation about a topic in the codebase
Create reference documentation using subagent for research, preserving main context.
Run git rev-parse --show-toplevel to locate the repository root.
Read <git-root>/.bonfire/config.json if it exists.
Docs location: Read docsLocation from config. Default to .bonfire/docs/ if not set.
The topic to document is: $ARGUMENTS
If no topic provided, ask the user what they want documented.
Use the Task tool to invoke the codebase-explorer subagent for research.
Provide a research directive:
Research the codebase to document: [TOPIC]
Find:
1. **Architecture**: How this system/feature is structured, key components
2. **Key Files**: Important files and their roles
3. **Flow**: How data/control flows through the system
4. **Patterns**: Design patterns and conventions used
5. **Gotchas**: Important details, edge cases, things to watch out for
Return structured findings with file paths and brief descriptions.
Wait for the subagent to return findings before proceeding.
The subagent runs in isolated context (haiku model, fast), preserving main context for writing.
Naming convention: <topic>.md (kebab-case)
Examples:
inbound-agent-architecture.mdsampling-strategies.mdauthentication-flow.mdWrite the documentation to <git-root>/<docsLocation>/<topic>.md
Structure the documentation using the research findings:
# [TOPIC]
## Overview
[What this is and why it exists - synthesized from research]
## Architecture
[How it's structured - from research findings]
mermaid flowchart TD
A[Component A] --> B[Component B]
B --> C[Component C]
## Key Files
| File | Purpose |
|------|---------|
| `path/to/file.ts` | [From research findings] |
| `path/to/other.ts` | [From research findings] |
## How It Works
[Step-by-step flow and behavior - from research]
## Usage Examples
[Code examples, CLI commands, etc.]
## Gotchas
- [From research findings]
- [Common mistakes or edge cases]
## Related
- [Link to related doc](other-doc.md)
- [Code reference]: `path/to/file.ts`
Add a reference to the doc in <git-root>/.bonfire/index.md under Key Resources or Notes.
Summarize what was documented and ask if the user wants: