A comprehensive knowledge base generation system for Claude Code that creates AI-optimized documentation using specialized agents.
- Universal Tech Stack Support - Auto-detects React, Python, Go, Rust, Java, and 15+ frameworks
- Two-Layer Documentation - AI-optimized skills + human-readable comprehensive docs
- Specialized Agents - Dedicated agents for analysis, skill writing, doc writing, and migration
- Plan Mode Integration - Preview all changes before applying
- Parallel Execution - Multiple agents work simultaneously for faster generation
- Existing Docs Migration - Automatically integrates your existing documentation
- Incremental Updates - Keep KB current with git-based change detection
- Claude Code CLI installed and configured
- A codebase to document
- Clone or download this repository
- Copy the folders to your project's
.claude/directory:
# From your project root
cp -r path/to/claude-code-kb-generator/commands .claude/
cp -r path/to/claude-code-kb-generator/knowledge-base .claude/Your project structure should look like:
your-project/
├── .claude/
│ ├── commands/
│ │ ├── init-kb.md
│ │ └── update-kb.md
│ └── knowledge-base/
│ ├── agents/
│ │ ├── kb-analyzer.md
│ │ ├── kb-skill-writer.md
│ │ ├── kb-doc-writer.md
│ │ └── kb-refactor.md
│ ├── config/
│ │ ├── tech-stacks.yaml
│ │ └── thresholds.yaml
│ └── templates/
│ └── universal/
│ ├── SKILL.md.tmpl
│ ├── domain.md.tmpl
│ ├── pattern.md.tmpl
│ ├── reference-index.md.tmpl
│ └── human-doc-system.md.tmpl
├── src/
└── ...
After installation, you can optimize the knowledge base generator for your specific codebase. This produces more relevant documentation by understanding your project's architecture and conventions.
Run this prompt in Claude Code:
I just installed the kb-generator commands in .claude/. Please:
1. Analyze my codebase to detect my tech stack, architecture patterns, and existing documentation
2. Read the command files in .claude/commands/ and .claude/knowledge-base/agents/
3. Optimize each KB agent by:
- Updating tech-stacks.yaml with my specific framework versions and patterns
- Adjusting skill templates to match my project's domain terminology
- Configuring documentation structure based on my existing docs organization
- Setting complexity thresholds appropriate for my codebase size
4. Keep the agent structure, two-layer documentation approach, and output format unchanged
Show me what you'll change before applying.
Run the initialization command to create a complete KB:
/init-kb
The command will:
- Analyze your codebase (tech stack, patterns, structure)
- Ask questions about documentation preferences
- Show a plan of what will be created
- Execute with parallel agents after approval
Keep your KB current after development:
/update-kb # Analyze last 20 commits
/update-kb 50 # Analyze last 50 commits
/update-kb --dry-run # Preview without applying
| Command | Description |
|---|---|
/init-kb |
Full KB generation with plan mode |
/init-kb --minimal |
Core structure only |
/init-kb --dry-run |
Preview structure without creating |
/update-kb |
Update from last 20 commits |
/update-kb N |
Update from last N commits |
/update-kb --dry-run |
Preview updates without applying |
Concise, AI-optimized documentation (300-500 lines each):
.claude/skills/
├── SKILL.md # Master navigation index
├── domains/ # Feature-specific knowledge
│ ├── audio.md
│ ├── auth.md
│ └── ...
├── patterns/ # Cross-cutting patterns
│ ├── service-pattern.md
│ └── provider-pattern.md
├── infrastructure/ # Tools & services
│ ├── supabase.md
│ └── sentry.md
├── references/ # Quick lookup tables
│ ├── services-index.md
│ └── components-index.md
└── onboarding/ # Getting started guides
├── quick-start.md
└── architecture-overview.md
Comprehensive specifications (1000+ lines each):
docs/knowledge_base/
├── README.md # Documentation index
├── systems/ # Core system specs
│ ├── SYS-001-audio.md
│ └── SYS-002-auth.md
├── features/ # Feature documentation
├── integrations/ # Third-party integrations
└── testing/ # Test documentation
Discovers and analyzes your codebase:
- Tech stack detection (15+ frameworks)
- Directory structure mapping
- Pattern detection (ServiceResponse, Provider, etc.)
- Existing documentation discovery
- Complexity estimation
Creates AI-optimized skill files:
- Concise content (300-500 lines)
- YAML frontmatter with metadata
- Code examples from your codebase
- Cross-references between skills
- Reference indexes
Creates comprehensive human documentation:
- Full specifications (1000+ lines)
- Architecture diagrams (ASCII)
- Sequence diagrams for flows
- Configuration documentation
- Troubleshooting guides
- Changelog sections
Migrates existing documentation:
- Analyzes existing docs structure
- Maps to new KB organization
- Creates deprecation notices
- Updates cross-references
- Preserves git history
The generator auto-detects and adapts to:
Frontend:
- React, React Native, Expo
- Next.js, Nuxt.js
- Vue, Angular, Svelte
Backend:
- Node.js, Express, NestJS
- Django, Flask, FastAPI
- Go (Gin, Echo, Fiber)
- Rust (Actix, Axum)
- Java (Spring Boot)
Mobile:
- React Native, Expo
- Flutter
- Native iOS/Android
See knowledge-base/config/tech-stacks.yaml for complete detection rules.
Edit knowledge-base/config/tech-stacks.yaml to customize:
- Detection rules per framework
- Default directory patterns
- Template selection
Edit knowledge-base/config/thresholds.yaml to customize:
- Project size thresholds
- Analysis depth settings
- Output limits
- When to ask for confirmation
Customize templates in knowledge-base/templates/universal/:
SKILL.md.tmpl- Master index templatedomain.md.tmpl- Domain skill templatepattern.md.tmpl- Pattern skill templatehuman-doc-system.md.tmpl- Human doc template
/init-kb
│
▼
┌─────────────────┐
│ kb-analyzer │ ← Detect tech stack, patterns, existing docs
└────────┬────────┘
│
▼
┌─────────────────┐
│ User Questions │ ← Where to put docs? Integrate existing?
└────────┬────────┘
│
▼
┌─────────────────┐
│ Plan Preview │ ← Show what will be created
└────────┬────────┘
│ (approved)
▼
┌─────────────────────────────────────────────┐
│ Parallel Agent Execution │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ skill-writer │ │ doc-writer │ │
│ │ (domains) │ │ (systems) │ │
│ └──────────────┘ └──────────────┘ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ skill-writer │ │ kb-refactor │ │
│ │ (patterns) │ │ (migration) │ │
│ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────┘
│
▼
┌─────────────────┐
│ Update Metadata │ ← kb-meta.json
└─────────────────┘
/update-kb
│
▼
┌─────────────────┐
│ Load kb-meta │ ← Tech stack, mappings, last commit
└────────┬────────┘
│
▼
┌─────────────────┐
│ Analyze Changes │ ← git diff since last update
└────────┬────────┘
│
▼
┌─────────────────┐
│ Update Proposal │ ← Show affected docs
└────────┬────────┘
│ (approved)
▼
┌─────────────────┐
│ Apply Updates │ ← Parallel skill/doc updates
└─────────────────┘
The system maintains kb-meta.json to track:
- Project tech stack and framework
- File-to-documentation mappings
- Last analyzed commit
- Update history
- Integrated existing docs
- Run
/init-kbonce when setting up a new project - Run
/update-kbregularly after significant development - Review generated content before committing
- Customize templates to match your documentation style
- Add
<!-- MANUAL -->markers to preserve manual edits during updates
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
- Add detection rules to
config/tech-stacks.yaml - (Optional) Create stack-specific templates in
templates/stacks/ - Test with a project using that stack
MIT License - see LICENSE file.