Reference Document Creator
Create or update reference documents that provide AI agents with comprehensive knowledge of a tool, technology, library, framework, or API. The resulting document enables an AI agent to work effectively with the subject without prior knowledge.
Step 1: Parse the Request
Determine the mode and subject from the arguments:
- Create mode (default): Generate a new reference document
- Update mode: If
--update <path> is specified or the user asks to update an existing document, read the existing document in full first, then research only the new topic areas and integrate them into the existing structure. Where old and new content contradict, new content takes precedence; remove outdated information. Preserve the overall structure unless the user requests restructuring.
Determine the subject source:
- Public tool/library/framework: Subject is identified by name (e.g., "Zod", "React Router v7", "Playwright"). Perform web research.
- Local codebase/tool: Subject is a local directory or file path. Explore the codebase.
- Both: Some subjects benefit from combining web research with local codebase analysis.
If the subject or scope is ambiguous, ask the user to clarify:
- What specific aspects to cover (full API, specific module, common patterns)
- Target language if the tool supports multiple (e.g., BAML supports TypeScript and Python)
- Intended audience context (what types of projects will use this reference)
Step 2: Research the Subject
Conduct thorough research to build comprehensive understanding.
For Public Tools/Libraries
- Search for official documentation: API references, getting started guides, configuration docs
- Search for guides and tutorials: Practical usage patterns, common recipes, best practices
- Search for changelogs and migration guides: Recent breaking changes or important version-specific behavior
- Fetch key documentation pages: Read official docs pages in full with the active client's browsing capability to extract precise API details, function signatures, configuration options, and examples
- Search for common pitfalls: Known gotchas, common mistakes, debugging tips
For Local Codebases
- Explore the project structure: Search files and list directories to understand organization
- Read key files: Entry points, configuration files, READMEs, type definitions, public API surfaces
- Identify the public API: Exported functions, classes, types, CLI commands, configuration options
- Find usage examples: Tests, examples directories, README snippets
- Check for existing documentation: Internal docs, JSDoc comments, docstrings
When combining both sources, local code takes precedence where web documentation contradicts the actual implementation.
Step 3: Organize and Draft the Reference
Document Structure Template
# [Subject Name] Reference Guide for AI Agents
<Overview>
[1-3 sentence description of what the tool does and its primary use case.]
[Key workflow or mental model in one sentence.]
</Overview>
## Installation / Setup
[Commands, dependencies, prerequisites]
## Core Concepts
[Key mental models and terminology the agent must understand]
## API Reference / Key APIs
[Function signatures, parameters, return types]
[Organized by logical groupings]
## Configuration
[Config files, environment variables, options]
## Common Patterns
[Practical recipes for frequent tasks]
## Commands / CLI
[If applicable: command syntax, flags, examples]
## Troubleshooting / Gotchas
[Common pitfalls and their solutions]
Adapt this structure to the subject — not all sections apply to every tool, and the structure should follow the natural workflow of using it.
Writing Standards
Format:
- Use bulleted lists over prose, one concept per bullet
- Imperative form for instructions ("Run
npm install", not "You should run npm install")
- Include code blocks for all commands, API calls, and configuration examples
- Use tables for reference data (options, flags, type mappings)
- Use Mermaid diagrams for architectural concepts or workflows when clearer than text
- Use XML tags (
<Overview>, <critical>, <example>) for structural clarity where appropriate
Content:
- Optimize for AI agent consumption: high information density, minimal tokens, no redundancy between sections
- Include precise API signatures with types, and concrete code examples rather than abstract descriptions
- Specify versions when version-specific behavior exists
- Include the "why" only when it prevents common misuse
- Omit information any LLM would already know
- Focus on actionable knowledge: what to do, how to do it, what to avoid
Code examples:
- Keep examples minimal but complete (runnable when possible)
- Show the most common usage first, then variations
- Include expected output or return values when non-obvious
- Annotate with inline comments for non-obvious behavior
Step 4: Validate the Document
Before saving, verify:
Step 5: Save the Document
For new documents:
- Save to
agent-docs/ directory in the project root
- Filename:
<subject-name>-reference.md (kebab-case), or <subject-name>-reference-<language>.md for language-specific variants
- If the subject warrants multiple files, create a subdirectory:
agent-docs/<subject-name>/
For updates, edit the existing file in place.
After saving, report the file path and a brief summary of what the document covers.
1---2name: create-reference3description: Create or update an AI-optimized reference document for a tool, library, framework, or API via thorough research.4---56# Reference Document Creator78Create or update reference documents that provide AI agents with comprehensive knowledge of a tool, technology, library, framework, or API. The resulting document enables an AI agent to work effectively with the subject without prior knowledge.910<subject>11Use the subject and options supplied in the user's invocation.12</subject>1314## Step 1: Parse the Request1516Determine the mode and subject from the arguments:1718- **Create mode** (default): Generate a new reference document19- **Update mode**: If `--update <path>` is specified or the user asks to update an existing document, read the existing document in full first, then research only the new topic areas and integrate them into the existing structure. Where old and new content contradict, new content takes precedence; remove outdated information. Preserve the overall structure unless the user requests restructuring.2021Determine the subject source:2223- **Public tool/library/framework**: Subject is identified by name (e.g., "Zod", "React Router v7", "Playwright"). Perform web research.24- **Local codebase/tool**: Subject is a local directory or file path. Explore the codebase.25- **Both**: Some subjects benefit from combining web research with local codebase analysis.2627If the subject or scope is ambiguous, ask the user to clarify:2829- What specific aspects to cover (full API, specific module, common patterns)30- Target language if the tool supports multiple (e.g., BAML supports TypeScript and Python)31- Intended audience context (what types of projects will use this reference)3233## Step 2: Research the Subject3435Conduct thorough research to build comprehensive understanding.3637### For Public Tools/Libraries38391. **Search for official documentation**: API references, getting started guides, configuration docs402. **Search for guides and tutorials**: Practical usage patterns, common recipes, best practices413. **Search for changelogs and migration guides**: Recent breaking changes or important version-specific behavior424. **Fetch key documentation pages**: Read official docs pages in full with the active client's browsing capability to extract precise API details, function signatures, configuration options, and examples435. **Search for common pitfalls**: Known gotchas, common mistakes, debugging tips4445### For Local Codebases46471. **Explore the project structure**: Search files and list directories to understand organization482. **Read key files**: Entry points, configuration files, READMEs, type definitions, public API surfaces493. **Identify the public API**: Exported functions, classes, types, CLI commands, configuration options504. **Find usage examples**: Tests, examples directories, README snippets515. **Check for existing documentation**: Internal docs, JSDoc comments, docstrings5253When combining both sources, local code takes precedence where web documentation contradicts the actual implementation.5455## Step 3: Organize and Draft the Reference5657### Document Structure Template5859```markdown60# [Subject Name] Reference Guide for AI Agents6162<Overview>63[1-3 sentence description of what the tool does and its primary use case.]64[Key workflow or mental model in one sentence.]65</Overview>6667## Installation / Setup6869[Commands, dependencies, prerequisites]7071## Core Concepts7273[Key mental models and terminology the agent must understand]7475## API Reference / Key APIs7677[Function signatures, parameters, return types]78[Organized by logical groupings]7980## Configuration8182[Config files, environment variables, options]8384## Common Patterns8586[Practical recipes for frequent tasks]8788## Commands / CLI8990[If applicable: command syntax, flags, examples]9192## Troubleshooting / Gotchas9394[Common pitfalls and their solutions]95```9697Adapt this structure to the subject — not all sections apply to every tool, and the structure should follow the natural workflow of using it.9899### Writing Standards100101Format:102103- Use bulleted lists over prose, one concept per bullet104- Imperative form for instructions ("Run `npm install`", not "You should run `npm install`")105- Include code blocks for all commands, API calls, and configuration examples106- Use tables for reference data (options, flags, type mappings)107- Use Mermaid diagrams for architectural concepts or workflows when clearer than text108- Use XML tags (`<Overview>`, `<critical>`, `<example>`) for structural clarity where appropriate109110Content:111112- Optimize for AI agent consumption: high information density, minimal tokens, no redundancy between sections113- Include precise API signatures with types, and concrete code examples rather than abstract descriptions114- Specify versions when version-specific behavior exists115- Include the "why" only when it prevents common misuse116- Omit information any LLM would already know117- Focus on actionable knowledge: what to do, how to do it, what to avoid118119Code examples:120121- Keep examples minimal but complete (runnable when possible)122- Show the most common usage first, then variations123- Include expected output or return values when non-obvious124- Annotate with inline comments for non-obvious behavior125126## Step 4: Validate the Document127128Before saving, verify:129130- [ ] Covers installation/setup, core concepts, all major API surfaces with signatures, and common real-world patterns131- [ ] Code examples exist for each major feature and use correct syntax for the documented version132- [ ] Document enables an agent to start using the tool without any other resources133134## Step 5: Save the Document135136For new documents:137138- Save to `agent-docs/` directory in the project root139- Filename: `<subject-name>-reference.md` (kebab-case), or `<subject-name>-reference-<language>.md` for language-specific variants140- If the subject warrants multiple files, create a subdirectory: `agent-docs/<subject-name>/`141142For updates, edit the existing file in place.143144After saving, report the file path and a brief summary of what the document covers.