Claude Documentation Generator
A VS Code extension that generates thorough, accurate documentation for your codebase using Claude Code (the claude CLI).
Features
- Multiple Documentation Types: Generate README overviews, API documentation, module docs, inline comments, and architecture overviews
- Flexible Scope: Document a single file, a folder, or your entire workspace
- Intelligent Chunking: Automatically handles large codebases by splitting code into manageable chunks
- Accurate Documentation: Uses carefully crafted prompts to ensure Claude only documents what's actually in the code
- Progress Tracking: Real-time progress notifications during documentation generation
- Configurable: Customize paths, chunk sizes, and excluded directories
Prerequisites
1. Claude Code Max Account
This extension requires a Claude Code Max subscription. Claude Code Max provides:
- Access to Claude's most capable models
- Extended context windows for processing large codebases
- Higher rate limits for batch processing
Sign up at claude.ai if you don't have an account.
2. Claude CLI Installation
The claude CLI (Claude Code) must be installed and authenticated on your system.
Installing Claude Code
macOS/Linux:
# Install via npm (recommended)
npm install -g @anthropic-ai/claude-code
# Or using Homebrew (macOS)
brew install claude-code
Windows:
# Install via npm
npm install -g @anthropic-ai/claude-code
Authenticating Claude Code
After installation, authenticate with your Claude account:
claude login
This will open a browser window for authentication. Follow the prompts to complete the login process.
Verifying Installation
Confirm that Claude Code is properly installed and accessible:
# Check if claude is in your PATH
claude --version
# Test with a simple prompt
echo "Hello, Claude!" | claude --print
You should see the version number and a response from Claude.
Troubleshooting PATH Issues:
If claude --version returns "command not found":
Check npm global path:
npm config get prefix
Add to PATH (add to your ~/.bashrc, ~/.zshrc, or equivalent):
export PATH="$PATH:$(npm config get prefix)/bin"
Restart your terminal or source your shell config:
source ~/.zshrc # or ~/.bashrc
Installation
From VS Code Marketplace (Coming Soon)
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Claude Documentation Generator"
- Click Install
From VSIX File
- Build the extension (see Development section below)
- In VS Code, open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Run "Extensions: Install from VSIX..."
- Select the generated
.vsix file
From Source (Development)
Clone the repository:
git clone https://github.com/your-username/vscode-claude-docs.git
cd vscode-claude-docs
Install dependencies:
npm install
Compile the extension:
npm run compile
Open in VS Code:
code .
Press F5 to launch a new VS Code window with the extension loaded
Usage
Generating Documentation
Open a workspace or folder in VS Code
Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
Type and select "Generate Documentation with Claude"
Choose the scope:
- Current File: Document only the active file
- Selected Folder: Document files in a specific folder
- Entire Workspace: Document all source files in the workspace
Select documentation types (you can select multiple):
- README Overview: Comprehensive project README
- Module Documentation: Detailed module/folder docs
- API Documentation: Public API reference
- Inline Comments: Add JSDoc/docstring comments
- Architecture Overview: High-level system design
Wait for generation to complete (progress shown in notification)
Generated files appear in your workspace:
- README.md in workspace root
- Other docs in
/docs folder
Output Locations
| Documentation Type |
Output Location |
| README Overview |
./README.md |
| Module Documentation |
./docs/{target}-module.md |
| API Documentation |
./docs/{target}-api.md |
| Inline Comments |
./docs/annotated-code.md |
| Architecture Overview |
./docs/ARCHITECTURE.md |
Configuration
Access settings via File > Preferences > Settings, then search for "Claude Docs".
| Setting |
Default |
Description |
claudeDocs.claudePath |
"claude" |
Path to the claude CLI executable |
claudeDocs.maxChunkSize |
50000 |
Maximum characters per chunk when processing large codebases |
claudeDocs.outputDirectory |
"docs" |
Directory for generated documentation files |
claudeDocs.excludePatterns |
["node_modules", ".git", ...] |
Directories/files to exclude from processing |
Example settings.json
{
"claudeDocs.claudePath": "/usr/local/bin/claude",
"claudeDocs.maxChunkSize": 75000,
"claudeDocs.outputDirectory": "documentation",
"claudeDocs.excludePatterns": [
"node_modules",
".git",
"dist",
"build",
"coverage",
"*.test.ts",
"*.spec.ts"
]
}
How It Works
Architecture
┌─────────────────────────────────────────────────────────┐
│ VS Code Extension │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ extension.ts│──▶│ fileUtils.ts│──▶│ claude.ts │ │
│ │ (UI/Flow) │ │ (Traversal) │ │ (CLI Call) │ │
│ └─────────────┘ └─────────────┘ └──────┬──────┘ │
│ │ │ │
│ │ ┌─────────────┐ │ │
│ └────────▶│ prompts.ts │◀───────────┘ │
│ │ (Templates) │ │
│ └─────────────┘ │
│ │
└───────────────────────────┬─────────────────────────────┘
│
│ stdin (prompt + code)
▼
┌───────────────┐
│ claude CLI │
│ (Claude Code) │
└───────┬───────┘
│
│ stdout (documentation)
▼
┌───────────────┐
│ Output Files │
│ (docs/*.md) │
└───────────────┘
Processing Flow
- File Collection: Traverses the selected scope, respecting exclude patterns
- Chunking: Splits large codebases into chunks under the token limit
- Prompt Construction: Builds structured prompts with code content
- Claude Invocation: Sends prompts to Claude CLI via stdin
- Chunk Combination: Merges chunk outputs into cohesive documentation
- File Writing: Writes documentation to appropriate locations
Prompt Design
The extension uses carefully crafted prompts that:
- Instruct Claude to document only what's present in the code
- Prevent invention of APIs or behavior
- Require explicit uncertainty statements when code is unclear
- Produce consistent, production-quality output
Development
Building the Extension
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode for development
npm run watch
# Package as VSIX
npm run package
Project Structure
vscode-claude-docs/
├── src/
│ ├── extension.ts # Main entry point, command registration
│ ├── claude.ts # Claude CLI invocation
│ ├── fileUtils.ts # File traversal and chunking
│ ├── prompts.ts # Prompt templates
│ └── types.ts # TypeScript type definitions
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
└── README.md # This file
Testing Locally
- Open the project in VS Code
- Press F5 to launch the Extension Development Host
- In the new window, open any project folder
- Run "Generate Documentation with Claude" from the Command Palette
Future Improvements
Planned Features
- Incremental Updates: Detect changes and only regenerate affected docs
- Custom Templates: Allow users to define their own prompt templates
- Multiple Output Formats: Support for HTML, PDF, and other formats
- Language-Specific Prompts: Tailored prompts for different programming languages
- Git Integration: Auto-commit generated documentation
- Documentation Preview: Live preview of generated markdown
- Batch Processing: Queue multiple documentation jobs
- Caching: Cache Claude responses for faster regeneration
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Troubleshooting
Common Issues
"Claude CLI is not available"
- Ensure
claude is installed: npm install -g @anthropic-ai/claude-code
- Verify it's in your PATH:
claude --version
- Check the
claudeDocs.claudePath setting
"No source code files found"
- Verify the selected scope contains supported file types
- Check that files aren't in an excluded directory
- Review the
claudeDocs.excludePatterns setting
"Operation timed out"
- Large codebases may take several minutes
- Try reducing scope or increasing
maxChunkSize
- Check your network connection
"Rate limit exceeded"
- The extension includes delays between chunks
- For very large projects, consider processing folders separately
- Upgrade your Claude subscription if needed
Getting Help
License
MIT License - see LICENSE file for details.
Made with Claude