Generate documentation from code including API docs, README sections, and CLAUDE.md files. Use when documenting APIs, creating setup guides, or updating project documentation.
Generate various types of documentation from code analysis.
$0: Documentation type - api, readme, claude, setup, all (required)$1: Output path (optional - defaults to appropriate location)api)Generate API endpoint documentation from code.
FastAPI Projects:
# FastAPI has built-in OpenAPI generation
curl http://localhost:8000/openapi.json > docs/openapi.json
# Or extract from code
grep -rn "@router\.\|@app\." --include="*.py" app/routes/
Template:
# API Documentation
## Base URL
`http://localhost:8000/v1`
## Authentication
All endpoints require JWT token in Authorization header:
`Authorization: Bearer <token>`
## Endpoints
### [Resource Name]
#### GET /resource
**Description:** Get list of resources
**Auth Required:** Yes
**Roles:** admin, staff
**Query Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| limit | int | No | Max items (default: 100) |
| offset | int | No | Skip items (default: 0) |
**Response:**
```json
{
"items": [],
"total": 0
}
**Next.js API Routes:**
```bash
# Find all API routes
find app/api -name "route.ts" -o -name "route.js"
readme)Generate or update README.md sections.
Template:
# Project Name
## Overview
[Auto-generated from package.json/pyproject.toml description]
## Tech Stack
- **Framework:** [Detected framework]
- **Database:** [Detected database]
- **Testing:** [Detected test framework]
## Prerequisites
- Node.js >= 18 / Python >= 3.12
- [Database] installed and running
- Environment variables configured
## Quick Start
### Installation
```bash
[Package manager] install
[Start command]
[Test command]
[Auto-generated directory tree]
See .env.example for required variables.
See docs/api.md for API reference.
[Standard contributing guidelines]
[License from package.json/pyproject.toml]
### 3. CLAUDE.md Documentation (`claude`)
Generate context file for Claude Code.
**Template:**
```markdown
# [Project Name]
## Project Overview
[Brief description of the project]
## Tech Stack
- **Language:** [Python/TypeScript]
- **Framework:** [FastAPI/Next.js/etc]
- **Database:** [MongoDB/PostgreSQL]
- **Package Manager:** [npm/pnpm/uv]
## Development Commands
### Start Development Server
```bash
[Start command]
[Test command]
[Lint command]
[Build command]
[Directory tree of important folders]
[config file] - [Description][main entry] - [Description]Required variables (see .env.example):
VAR_NAME - [Description][path][path][path][Key patterns used in the codebase]
### 4. Setup Guide (`setup`)
Generate detailed setup instructions.
**Template:**
```markdown
# Setup Guide
## Prerequisites
### Required Software
- [ ] [Runtime] version X.X+
- [ ] [Database] version X.X+
- [ ] [Package manager]
### Verify Installation
```bash
[version check commands]
git clone [repo-url]
cd [project-name]
[install command]
cp .env.example .env.local
# Edit .env.local with your settings
[database setup commands]
[migration command]
[seed command]
[start command]
Open http://localhost:[port] in your browser.
Symptom: [Description] Solution: [Fix]
Symptom: [Description] Solution: [Fix]
## Generation Process
### 1. Analyze Project
```bash
# Detect project type
if [ -f "pyproject.toml" ]; then
PROJECT_TYPE="python"
elif [ -f "package.json" ]; then
PROJECT_TYPE="node"
fi
# Extract metadata
# Python: pyproject.toml
# Node: package.json
# Find key files
ls -la
find . -name "*.md" -maxdepth 2
From package.json:
From pyproject.toml:
From code:
Write documentation to appropriate location:
docs/api.mdREADME.mdCLAUDE.mddocs/setup.mdDocumentation Generation: [project-name]
Type: [api/readme/claude/setup/all]
Analyzing project...
Project type: [type]
Framework: [framework]
Database: [database]
Extracting information...
Routes found: X
Models found: Y
Config files: Z
Generating documentation...
Writing: [output-path]
Documentation generated successfully!
Files created:
- [file1]
- [file2]