// LLM-powered documentation generation for narrative architecture docs, tutorials, and developer guides. Uses AI consultation to create contextual, human-readable documentation from code analysis and spec data.
| name | llm-doc-gen |
| description | LLM-powered documentation generation for narrative architecture docs, tutorials, and developer guides. Uses AI consultation to create contextual, human-readable documentation from code analysis and spec data. |
This skill generates comprehensive, navigable documentation using Large Language Model (LLM) consultation. It creates sharded documentation (organized topic files) by having LLMs read and analyze source code directly, then synthesizing their insights into structured, human-readable guides.
Core Capability: Transform codebases into sharded documentation by orchestrating LLM analysis through workflow-driven steps, managing state for resumability, and producing organized topic files instead of monolithic documents.
Use this skill when:
Key features:
Do NOT use for:
This skill may run operations that take up to 5 minutes. Be patient and wait for completion.
Bash(command="...", timeout=300000)run_in_background=True for test suites, builds, or analysisPolling BashOutput repeatedly creates spam and degrades user experience. Long operations should run in foreground with appropriate timeout, not in background with frequent polling.
# Test suite that might take 5 minutes (timeout in milliseconds)
result = Bash(command="pytest src/", timeout=300000) # Wait up to 5 minutes
# The command will block here until completion - this is correct behavior
# Don't use background + polling
bash_id = Bash(command="pytest", run_in_background=True)
output = BashOutput(bash_id) # Creates spam!
Unlike monolithic documentation files, llm-doc-gen produces organized, navigable documentation sharded by topic:
Example Output Structure:
docs/
โโโ index.md # Main navigation and project overview
โโโ architecture/
โ โโโ overview.md # System architecture and design
โ โโโ components.md # Component descriptions
โ โโโ data-flow.md # Data flow and interactions
โโโ guides/
โ โโโ getting-started.md # Developer onboarding
โ โโโ development.md # Development workflows
โ โโโ deployment.md # Deployment procedures
โโโ reference/
โโโ api.md # API reference
โโโ configuration.md # Configuration options
โโโ troubleshooting.md # Common issues and solutions
Benefits:
State File for Resumability:
The skill maintains a project-doc-state.json file to enable resuming interrupted scans:
{
"version": "1.0",
"project_name": "MyProject",
"last_updated": "2025-11-19T20:00:00Z",
"current_step": "generate-guides",
"completed_steps": ["scan-structure", "analyze-architecture", "generate-architecture-docs"],
"files_analyzed": ["src/main.py", "src/auth.py", "src/db.py"],
"sections_generated": [
"docs/index.md",
"docs/architecture/overview.md",
"docs/architecture/components.md"
],
"workflow_mode": "full_scan"
}
If the scan is interrupted, simply run sdd llm-doc-gen resume ./docs to continue from the last checkpoint.
The llm-doc-gen skill uses a workflow engine that orchestrates LLM analysis through systematic steps:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 1: Initialize โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โข Scan project structure โ
โ โข Create state file (project-doc-state.json) โ
โ โข Detect project type โ
โ โข Plan documentation sections โ
โ โข Check for existing docs/resume โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 2: Analyze Architecture โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โข LLMs read source files directly โ
โ โข Identify components and patterns โ
โ โข Analyze data flow and interactions โ
โ โข Multi-agent consultation (parallel) โ
โ โข Update state: architecture analyzed โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 3: Generate Architecture Docs โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โข Synthesize LLM research findings โ
โ โข Create docs/architecture/overview.md โ
โ โข Create docs/architecture/components.md โ
โ โข Create docs/architecture/data-flow.md โ
โ โข Update state: architecture docs done โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 4: Generate Guides โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โข Analyze developer workflows โ
โ โข Create docs/guides/getting-started.md โ
โ โข Create docs/guides/development.md โ
โ โข Create docs/guides/deployment.md โ
โ โข Update state: guides done โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 5: Generate Reference โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โข Extract API patterns โ
โ โข Create docs/reference/api.md โ
โ โข Create docs/reference/configuration.md โ
โ โข Create docs/reference/troubleshooting.md โ
โ โข Update state: reference done โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 6: Finalize โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โข Generate docs/index.md with navigation โ
โ โข Validate all sections created โ
โ โข Update state: complete โ
โ โข Archive state file โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Resumability:
If interrupted at any step, the workflow can resume from the last completed step using the state file:
# Workflow interrupted after Step 3
sdd llm-doc-gen resume ./docs
# Resumes from Step 4: Generate Guides
Key Workflow Principles:
Stateful Execution
LLMs Read Code Directly
Sharded Output
Multi-Agent Research
CRITICAL: The llm-doc-gen skill automatically integrates analysis insights when available.
Check for analysis data:
codebase.json in the project rootAlways tell the user about insights status:
If codebase.json exists:
โ
Found codebase analysis data (codebase.json)
๐ Using factual metrics to enhance documentation quality
If codebase.json is missing:
โน๏ธ No analysis data found (codebase.json)
๐ก Tip: Run `sdd doc generate` first for better results with factual insights
๐ Continuing with AI reasoning only
When codebase.json exists, the generators automatically:
You don't need to pass special flags or parameters. The integration is automatic.
If insight extraction fails:
Never fail documentation generation due to missing or corrupt analysis data. Graceful degradation is built-in.
When insights are used, expect documentation to include:
For details about the integration architecture, performance, and best practices, see docs/llm-doc-gen/ANALYSIS_INTEGRATION.md.
Before using this skill, verify that LLM tools are available:
# Check which tools are available for llm-doc-gen
sdd test check-tools --skill llm-doc-gen
# For JSON output
sdd test check-tools --skill llm-doc-gen --json
Expected: At least one LLM tool should be detected as available.
IMPORTANT - How This Skill Works:
execute_tool_with_fallback() and execute_tools_parallel()claude_skills.common.ai_tools infrastructureThe skill shells out to installed CLI tools (cursor-agent, gemini, codex) which handle the actual LLM API communication.
If no LLM tools are installed, this skill cannot function. Install at least one of the supported tools before using llm-doc-gen.
# Generate complete sharded documentation
sdd llm-doc-gen scan ./src --project-name MyProject --output-dir ./docs
# Resume interrupted scan
sdd llm-doc-gen resume ./docs
# Generate specific section only
sdd llm-doc-gen section architecture --source ./src --output ./docs/architecture/
# Single-agent mode (faster, less comprehensive)
sdd llm-doc-gen scan ./src --single-agent --tool cursor-agent
After running sdd llm-doc-gen scan, you'll get organized documentation:
docs/
โโโ index.md # Navigation and overview
โโโ architecture/ # System design docs
โ โโโ overview.md
โ โโโ components.md
โ โโโ data-flow.md
โโโ guides/ # Developer guides
โ โโโ getting-started.md
โ โโโ development.md
โ โโโ deployment.md
โโโ reference/ # Reference docs
โโโ api.md
โโโ configuration.md
โโโ troubleshooting.md
Skill(sdd-toolkit:llm-doc-gen) when:Architecture Documentation
Developer Onboarding
Tutorial Creation
Design Documentation
Specification-Based Docs
Skill(sdd-toolkit:llm-doc-gen) when:You need structural accuracy
sdd doc generate for programmatic extractionSimple API documentation
sdd doc generate handles function signatures betterQuick prototyping or spikes
Documentation already exists
Always use the workflow engine
Use multi-agent by default
Let LLMs read code directly
Maintain state file integrity
sdd llm-doc-gen resume to continue interrupted scansReport LLM failures transparently
Never let LLMs write files directly
Never skip the initialization step
Never mix monolithic and sharded output
Never ignore timeout/failure
Never batch without state tracking
When you run sdd llm-doc-gen scan ./src --project-name MyProject, the workflow engine executes these steps:
Actions:
docs/project-doc-state.json fileOutput:
๐ Scanning project structure...
โ
Detected: Python web application (Flask)
๐ Planned sections: architecture, guides, reference
๐พ State file created: docs/project-doc-state.json
Resume Check: If state file exists, you'll be prompted:
Found existing documentation state (last updated 2 hours ago).
Resume from where you left off? [Y/n]
Actions:
Expected Output:
๐ค Consulting 2 AI models for architecture analysis...
Tools: cursor-agent, gemini
โ
cursor-agent completed (28.3s)
โ
gemini completed (24.1s)
๐ Analysis complete:
- 5 core components identified
- 3 data flow patterns documented
- 12 source files analyzed
State Update:
current_step: "generate-architecture-docs", completed_steps: ["initialize", "analyze-architecture"]
Actions:
docs/architecture/overview.mddocs/architecture/components.mddocs/architecture/data-flow.mdExpected Output:
๐ Generating architecture documentation...
โ
Created: docs/architecture/overview.md (2.1 KB)
โ
Created: docs/architecture/components.md (3.4 KB)
โ
Created: docs/architecture/data-flow.md (1.8 KB)
๐พ State updated: 3 architecture docs complete
Actions:
docs/guides/getting-started.mddocs/guides/development.mddocs/guides/deployment.mdExpected Output:
๐ Generating developer guides...
๐ค Analyzing: Setup procedures, development workflows, deployment...
โ
Created: docs/guides/getting-started.md (4.2 KB)
โ
Created: docs/guides/development.md (3.1 KB)
โ
Created: docs/guides/deployment.md (2.5 KB)
๐พ State updated: 3 guide docs complete
Actions:
Expected Output:
๐ Generating reference documentation...
โ
Created: docs/reference/api.md (5.3 KB)
โ
Created: docs/reference/configuration.md (2.8 KB)
โ
Created: docs/reference/troubleshooting.md (1.9 KB)
๐พ State updated: 3 reference docs complete
Actions:
docs/index.md with navigationExpected Output:
โจ Finalizing documentation...
โ
Created: docs/index.md (navigation index)
โ
Validated: All 9 documentation files present
๐ Documentation Complete:
Total sections: 9 files
Total size: 27.1 KB
Time elapsed: 2m 45s
๐ Output directory: ./docs
If the workflow is interrupted at any step, the state file preserves progress:
{
"current_step": "generate-guides",
"completed_steps": ["initialize", "analyze-architecture", "generate-architecture-docs"],
"sections_generated": [
"docs/architecture/overview.md",
"docs/architecture/components.md",
"docs/architecture/data-flow.md"
]
}
To resume:
sdd llm-doc-gen resume ./docs
Resume output:
๐ Resuming documentation generation...
โ
Found state file (last updated 1 hour ago)
๐ Progress: 3/9 sections complete (33%)
โถ๏ธ Resuming from: Step 4 (Generate Guides)
The workflow continues from Step 4, skipping already-completed sections.
The workflow prompts for user input at key decision points:
1. Resume Check (if state file exists)
Found existing documentation state.
Resume from where you left off? [Y/n]
2. Project Type Confirmation (if auto-detection uncertain)
Detected project type: Web Application
Is this correct? [Y/n]
> If no: What type of project is this? [library/cli/api/other]
3. Section Selection (optional)
Generate all sections or specific sections only?
1. All sections (recommended)
2. Architecture only
3. Guides only
4. Reference only
5. Custom selection
Choice [1]:
4. LLM Tool Failure
โ ๏ธ Warning: cursor-agent failed (timeout)
Continue with remaining tools? [Y/n]
Available: gemini
This skill is currently under development. The sections above define the core purpose and workflow. Implementation details, CLI commands, and examples will be added in subsequent phases.
Current Status: Phase 1 - Documentation & Planning (IN PROGRESS)
Remaining Work: