Two-Phase Generation β
Claudux uses a structured two-phase approach to ensure accurate, comprehensive documentation generation.
Why Two Phases? β
Problem: Single-pass generation often produces:
- Inconsistent navigation structure
- Missing cross-references between pages
- Outdated content mixed with new content
- Broken internal links
Solution: Plan first, then execute systematically.
Phase 1: Analysis & Planning β
π Configuration Loading β
Reads all relevant configuration files:
# Project configuration
claudux.json # Project settings
CLAUDE.md # Coding patterns and conventions
# Template configuration
lib/templates/{type}/config.json # Project-type specific structure
# Documentation preferences
claudux.md # Site structure preferences (if exists)
π Codebase Analysis β
Scans source code to understand:
Architecture patterns:
- Entry points and main modules
- Import/export relationships
- Framework usage (React, Express, FastAPI, etc.)
- Testing approaches
Code organization:
- Directory structure and naming conventions
- Configuration file patterns
- Build and deployment setup
- Documentation style (if exists)
Example analysis output:
π Project Analysis Results:
β’ Type: Next.js application
β’ Entry points: pages/, app/, components/
β’ API routes: pages/api/, app/api/
β’ Testing: Jest + React Testing Library
β’ Deployment: Vercel configuration detected
π Documentation Audit β
Reviews existing documentation:
Content analysis:
- Cross-references docs against current code
- Identifies outdated sections (confidence scores)
- Finds missing documentation gaps
- Detects broken internal links
Structure analysis:
- Evaluates current navigation hierarchy
- Identifies redundant or obsolete pages
- Plans optimal information architecture
πΊοΈ Execution Planning β
Creates a detailed plan before making changes:
New files to create:
β¨ NEW FILES:
- docs/guide/deployment.md (Vercel deployment guide)
- docs/api/authentication.md (New auth endpoints)
- docs/examples/hooks.md (React hooks examples)
Files to update:
π UPDATES:
- docs/guide/installation.md (Update Node version requirement)
- docs/api/routes.md (Add 3 new API endpoints)
Files to remove:
ποΈ OBSOLETE (95% confidence):
- docs/legacy/old-api.md (References deleted endpoints)
βοΈ VitePress Configuration Generation β
Generates optimized VitePress config:
Auto-detected elements:
- Project name and description from
package.json
- Repository links from git remote
- Logo/icon detection
- Social links (GitHub, npm)
Navigation structure:
- Sidebar hierarchy matching planned docs
- Cross-section consistency
- Mobile-optimized navigation
- Breadcrumb integration
Phase 2: Execution β
π Content Generation β
Executes the plan systematically:
Creation process:
- Generate new documentation files
- Update existing content with current information
- Remove obsolete files (high confidence only)
- Update VitePress configuration
Quality controls:
- Every code example from actual source
- All internal links verified before creation
- Consistent terminology across pages
- No placeholder or hypothetical content
π Link Validation β
Final validation pass:
π Validating documentation links...
β
Internal links: 47/47 valid
β
Anchor links: 23/23 valid
β
Asset references: 12/12 valid
β οΈ External links: 2 timeouts (non-critical)
Auto-fix capability: If validation finds missing pages, claudux can automatically create minimal placeholder content and retry validation.
Benefits of Two-Phase Approach β
π― Accuracy β
- Consistent structure: All pages follow planned hierarchy
- Complete coverage: Nothing gets missed in analysis phase
- Current content: Everything reflects actual code state
π Performance β
- Efficient AI usage: Single comprehensive analysis vs multiple queries
- Reduced regeneration: Only updates what actually changed
- Faster iterations: Plan guides focused updates
π οΈ Reliability β
- Predictable output: Plan phase catches issues before generation
- Link integrity: All links validated before file creation
- Error recovery: Failed generations don't leave partial artifacts
Monitoring Phase Progress β
During generation, claudux shows real-time progress:
π Phase 1: Analyzing project structure...
β
Configuration loaded
β
Codebase scanned (247 files)
β
Documentation audit complete
β
Execution plan created
π Phase 2: Generating documentation...
β¨ Created docs/guide/deployment.md
π Updated docs/api/routes.md
π Validating links... β
47/47 valid
β
Documentation generation complete!
Customizing the Process β
Focused Directives β
Guide the planning phase with specific instructions:
claudux update -m "Focus on API documentation and add more code examples"
The directive influences both phases:
- Phase 1: Analysis prioritizes API-related code
- Phase 2: Generation emphasizes API docs and examples
Template Customization β
Modify project-type templates in lib/templates/{type}/config.json
to change:
- Default documentation structure
- Sidebar organization preferences
- Required vs optional sections
- Code example priorities
This ensures the planning phase uses your preferred patterns for similar projects.