AI-powered developer documentation generator that transforms complex codebases into clear, actionable guides using CodeFlow's semantic analysis and LLM synthesis.
DevGuides is a powerful CLI tool that generates intelligent, context-aware developer documentation by combining CodeFlow's semantic code analysis with LLM-powered synthesis. It transforms complex codebases into clear, actionable guides that help developers understand, navigate, and contribute to any codebase more efficiently.
- π§ Intelligent Analysis: Uses CodeFlow's semantic search to understand code relationships
- π― Natural Language Queries: Ask questions like "Explain user authentication flow"
- π Visual Diagrams: Generates Mermaid call graphs automatically via CodeFlow
- π Multiple Output Formats: Markdown and HTML with customizable templates
- β‘ Fast & Efficient: Powered by CodeFlow's vector store and ChromaDB
- οΏ½ Rich Context: Automatically includes surrounding file content (Β±100 lines) for better understanding
- π― Project-Aware: Reads AGENTS.md or README.md for project-level context
- π‘οΈ Grounded Documentation: Strict instructions prevent LLM hallucinations
- οΏ½π§ Developer-Friendly:- Rich CLI: Beautiful terminal output with spinners and progress bars.
- Jinja2 Templating: Customizable output formats using standard Jinja2 templates.
- Robust Configuration: Type-safe configuration management via Pydantic.
- π‘οΈ Robust Error Handling: Graceful degradation and comprehensive logging
- π Open Source: Full transparency with MIT license and community governance
- ποΈ Platform Agnostic: Works with any editor, terminal, or CI/CD pipeline
- Python 3.10+
- uv package manager (recommended) or pip
- CodeFlow MCP server (MUST be installed first from GitHub)
- OpenAI API key (for LLM generation)
CodeFlow must be installed from GitHub before using DevGuides:
# Install CodeFlow from GitHub (REQUIRED - no PyPI package yet)
git clone https://github.com/mrorigo/code-flow-mcp.git
cd code-flow-mcp
pip install -e .# Install using uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv add devguides
# Or install from source
git clone https://github.com/mrorigo/devguides.git
cd devguides
uv sync
uv pip install -e .# Get help
devguides --help
# Generate documentation for authentication flow
devguides generate "user authentication flow"
# Generate concise documentation
devguides generate "API endpoints" --level concise
# Generate HTML output with custom template
devguides generate "database models" --format html --template default
# Expand more files for richer context (default: 5)
devguides generate "authentication flow" --max-files 10
# Save to specific file
devguides generate "error handling patterns" --output my-guide.mdConcise guide to DevGuides generated by DevGuides can be found in docs/dev_guides.markdown:
DevGuides leverages CodeFlow's comprehensive analysis capabilities:
- π Semantic Code Analysis: CodeFlow's ChromaDB vector search for understanding code relationships
- π€ LLM Integration: AI-powered documentation synthesis with support for OpenAI, Anthropic, and local models
- π MCP Protocol: Model Context Protocol integration with CodeFlow for extensible agent workflows
- π Hierarchical Mapping: Mermaid call graphs generated through CodeFlow's analysis
- π― Natural Language Queries: CodeFlow enables asking "Explain authentication flow" and getting comprehensive docs
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β DevGuides β β CodeFlow β β LLM Service β
β CLI Tool βββββΊβ MCP Server βββββΊβ (OpenAI) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
β βββββββββββββββββββ
βββββββββββββββΊβ ChromaDB β
β Vector Store β
βββββββββββββββββββ
- CLI Interface: Click-based command-line interface with Rich UI
- MCP Client: stdio-based communication with CodeFlow server
- LLM Handler: Async OpenAI integration with retry logic
- Generation Engine: 9-step documentation pipeline
- Template System: Flexible Markdown/HTML template engine
- CodeFlow Integration: Semantic analysis and code relationship mapping
DevGuides uses two configuration files:
codeflow.config.yaml- Configures CodeFlow MCP server (what code to analyze).devguides.yaml- Configures DevGuides itself (how to generate docs)
This tells CodeFlow which directories to analyze and how to store the vector embeddings.
Example (see codeflow.config.yaml in this repo):
# Directories to analyze
watch_directories: ["devguides"]
# Patterns to ignore
ignored_patterns: ["venv", "**/__pycache__", ".git"]
# Where to store vector embeddings
chromadb_path: "./code_vectors_chroma"
# Analysis settings
max_graph_depth: 3
embedding_model: "all-MiniLM-L6-v2"
cleanup_interval_minutes: 30π Full CodeFlow documentation: See the CodeFlow repository for all configuration options.
This configures how DevGuides connects to CodeFlow and generates documentation.
Example (see .devguides.yaml in this repo):
# Server: How to connect to CodeFlow MCP
server:
command: "/path/to/code_flow_graph_mcp_server"
args: ["--config", "codeflow.config.yaml"]
working_directory: "/path/to/your/project"
timeout: 60
# LLM: Which AI model to use
llm:
provider: "openai"
model: "gpt-4"
# Use environment variable for API key (recommended)
# api_key: "sk-..." # NOT recommended - use env var instead
base_url: "https://api.openai.com/v1" # Optional: for OpenRouter, etc.
max_tokens: 2000
temperature: 0.3
# Output: Where and how to save documentation
output:
format: "markdown" # or "html"
include_diagrams: true
output_directory: "./docs"
# Generation: Documentation generation settings
generation:
detail_level: "comprehensive" # or "concise"
max_results: 10 # Number of code snippets to analyze
max_files: 5 # Number of files to expand with full context
timeout: 60π‘ Tips:
- Use environment variables for API keys (see below)
- Point
server.commandto your CodeFlow installation - Reference your
codeflow.config.yamlinserver.args
DevGuides automatically reads project-level context from AGENTS.md (or falls back to README.md) to help the LLM understand your codebase architecture and generate more accurate documentation.
π Learn more about AGENTS.md: Visit https://agents.md/ for the specification and best practices.
How it works:
- Place an
AGENTS.mdfile in your project root - DevGuides automatically includes it as context for the LLM
- This prevents hallucinations and ensures documentation is grounded in your actual architecture
- Falls back to
README.mdifAGENTS.mddoesn't exist
# Required for OpenAI integration
export DEVGUIDES_LLM_API_KEY="your-openai-api-key"
# Optional configurations
export DEVGUIDES_LLM_MODEL="gpt-4"
export DEVGUIDES_LLM_BASE_URL="https://api.openai.com/v1" # For OpenAI-compatible endpoints
export DEVGUIDES_OUTPUT_DIRECTORY="./docs"
export DEVGUIDES_LOG_LEVEL="INFO"# Install CodeFlow from GitHub (REQUIRED - no PyPI package yet)
git clone https://github.com/mrorigo/code-flow-mcp.git
cd code-flow-mcp
pip install -e .
# Optionally create a custom configuration
mkdir -p ~/.config/codeflow
cp config/default.yaml ~/.config/codeflow/custom.yamlDevGuides automatically manages CodeFlow MCP server:
- Starts Server: DevGuides launches CodeFlow when needed using stdio transport
- Manages Connection: Handles connection lifecycle via
mcp[cli]SDK - Cleans Up: Automatically terminates server when done
- Error Handling: Robust retry logic and graceful degradation
# Test that CodeFlow is properly installed
python -m code_flow_graph.cli.code_flow_graph --help
# Test DevGuides with CodeFlow integration
devguides generate "test query" --verboseIf you have a custom CodeFlow configuration:
# ~/.config/codeflow/custom.yaml
watch_directories: ["src", "app"] # Directories to monitor
ignored_patterns: ["venv", "**/__pycache__"] # Patterns to ignore
chromadb_path: "./code_vectors_chroma" # Vector store location
max_graph_depth: 3 # Maximum graph traversal depth# Generate comprehensive project overview
devguides generate "main application setup and architecture" \
--level comprehensive \
--output onboarding-guide.md# Document payment processing flow using CodeFlow's semantic analysis
devguides generate "payment processing flow and error handling" \
--level comprehensive \
--template default# Generate API endpoint documentation with CodeFlow call graphs
devguides generate "all REST API endpoints and their purposes" \
--level comprehensive \
--format html \
--output api-docs.html# Document authentication using CodeFlow's analysis capabilities
devguides generate "authentication and authorization mechanisms" \
--level comprehensive \
--include-diagrams# Quick overview using CodeFlow's vector search
devguides generate "database connection patterns" \
--level concise \
--output quick-ref.md# Test CodeFlow directly first (optional)
python -m code_flow_graph.cli.code_flow_graph . --output analysis.json
# Then generate documentation using DevGuides
devguides generate "core application logic" --level comprehensive# User Authentication Flow
*This documentation was generated in response to the query: "user authentication flow"*
Generated on 2024-01-15 10:30:45 using the default template.
### Metadata
- **Query:** user authentication flow
- **Detail Level:** Comprehensive
- **Functions Analyzed:** 12
- **Search Results:** 8
- **Generated:** 2024-01-15 10:30:45
- **Template:** default
## Overview
The user authentication system implements a multi-layered security approach...
## Key Components
- `auth_service.py:login_user()` - Handles user login with JWT tokens
- `middleware.py:authenticate_request()` - Validates tokens on each request
- `models.py:User` - User model with secure password hashing
## Call Flow Diagram
```mermaid
graph TD
A[Login Request] --> B[Validate Credentials]
B --> C[Generate JWT Token]
C --> D[Store Session]
D --> E[Return Token]This documentation was generated by DevGuides.
## π― Advanced Usage
### Open Source Extensibility
**π Complete Transparency**
- View and modify the entire codebase
- Audit security and privacy practices
- Contribute features and improvements
- Fork for custom requirements
**βοΈ Unlimited Customization**
```python
# Custom template creation
class MyTemplate(BaseTemplate):
def format_section(self, content: str, title: str) -> str:
return f"## π {title}\n\n{content}"
# Custom LLM provider
class MyLLMProvider(LLMProvider):
async def generate(self, prompt: str) -> str:
# Use any LLM service
return await my_custom_llm.call(prompt)
Automation-Friendly
# Batch documentation generation
for module in auth api database; do
devguides generate "$module patterns" --output docs/$module-guide.md
done
# CI/CD integration
- name: Generate Documentation
run: devguides generate "system architecture" --level comprehensive
# Editor integration (via terminal)
vim <(devguides generate "current file documentation" --format html)# .github/workflows/docs.yml
name: Generate Documentation
on:
push:
paths:
- 'src/**'
- 'app/**'
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install uv
- run: uv add devguides
- run: devguides generate "main application architecture" --output architecture.md
- uses: actions/upload-artifact@v3
with:
name: documentation
path: "*.md"# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=devguides --cov-report=html
# Run specific test categories
uv run pytest tests/unit/
uv run pytest tests/integration/Most Common Issue: DevGuides requires CodeFlow MCP to be installed from GitHub.
# Error: CodeFlow not found or import error
# Solution: Install CodeFlow from GitHub
git clone https://github.com/mrorigo/code-flow-mcp.git
cd code-flow-mcp
pip install -e .
# Verify installation
python -m code_flow_graph.cli.code_flow_graph --help
# Test with DevGuides
devguides generate "test query" --verbose# Error: OpenAI API key not provided
# Solution: Set environment variable
export DEVGUIDES_LLM_API_KEY="your-api-key"
# Or add to config file (not recommended)
echo 'llm:
api_key: "your-api-key"' >> .devguides.yaml# Error: CodeFlow dependencies missing
# Solution: Ensure all CodeFlow dependencies are installed
cd code-flow-mcp
pip install chromadb sentence-transformers mcp[cli] pyyaml watchdog pydantic
# Verify Python path is set correctly
export PYTHONPATH="${PYTHONPATH}:$(pwd)"# Error: MCP session initialization times out
# Solution: Increase timeout or check CodeFlow installation
devguides generate "query" --timeout 180 --verbose
# Or verify CodeFlow works standalone
python -m code_flow_graph.cli.code_flow_graph . --query "test"# Error: No relevant code found for query
# Solution: Try broader queries or verify CodeFlow analysis
devguides generate "functions" # Broader query
python -m code_flow_graph.cli.code_flow_graph . --output test.json # Test CodeFlow directly# Error: Generation timed out
# Solution: Increase timeout or reduce max_results
devguides generate "query" --timeout 120 --max-results 5# Enable verbose logging
devguides --verbose generate "your query"
# Check configuration
devguides config
# Test server connection
devguides server# View logs
tail -f ~/.local/share/devguides/logs/devguides.log
# Or enable console logging
export DEVGUIDES_LOG_LEVEL=DEBUG
devguides generate "query"- No Vendor Lock-in: Use any editor, any platform, any workflow
- Your Documentation: Remains yours forever, no usage limits
- Full Transparency: See exactly how your code analysis works
- Community Governance: Shape the roadmap with open contribution
- Future-Proof: Built on open protocols (MCP) independent of vendors
- Automation-Friendly: CLI-centric design for CI/CD integration
- Platform Agnostic: Works with VS Code, Vim, Emacs, or any tool
- Extensible: Modify templates, add LLM providers, create custom workflows
- Portable Output: Markdown/HTML that integrates anywhere
Tested and Proven:
- β 105/105 automated tests passing
- β Sub-5 second documentation generation
- β Handles 100K+ LOC codebases efficiently
- β Production-grade error handling and logging
- β Memory and CPU optimized for large projects
We welcome contributions! DevGuides is built by the community, for the community.
# Clone repository
git clone https://github.com/mrorigo/devguides.git
cd devguides
# Install development dependencies
uv sync --extra dev
# Run tests
uv run pytest
# Code formatting
uv run black devguides/
uv run isort devguides/
# Type checking
uv run mypy devguides/- π οΈ Feature Requests: Open an issue with your ideas
- π Bug Reports: Help us improve with detailed bug reports
- π‘ Enhancements: Contribute templates, LLM providers, integrations
- π Documentation: Improve guides, examples, and tutorials
- β
File Content Expansion:
--max-filesparameter to include Β±100 lines around search results - β AGENTS.md Support: Automatic project context injection from AGENTS.md or README.md
- β Strict Grounding: Anti-hallucination instructions in LLM prompts
- β Diagram Generation Fix: Corrected FQN extraction for Mermaid diagrams
- β Mermaid Formatting: Fixed JSON parsing and duplicate header removal
- β Improved Documentation: Clearer configuration examples with links to actual files
- β Jinja2 Templates: Replaced custom templates with industry-standard Jinja2
- β Pydantic Settings: Enhanced configuration with automatic env var loading
- β Improved Flexibility: Better template customization and maintainability
- β CodeFlow Integration: Production-ready MCP client with stdio transport
- β Async Architecture: Proper async context managers for resource management
- β Core Features: Semantic search, call graphs, LLM documentation generation
- Multi-LLM Support: Add support for Anthropic Claude, local models (Ollama)
- Streaming Output: Real-time documentation generation with progress updates
- Custom Templates: Template gallery and easier template creation
- Batch Generation: Generate documentation for multiple queries in one run
- Interactive Mode: REPL-style interface for iterative documentation refinement
- Documentation Versioning: Track documentation changes over time
- Code Change Detection: Auto-regenerate docs when code changes
- Multi-Language Support: Extend beyond Python to JavaScript, TypeScript, Go, Rust
- Documentation Testing: Verify documentation accuracy against actual code
- Integration Plugins: VS Code, JetBrains, Vim/Neovim extensions
- Collaborative Features: Team documentation workflows and review processes
- AI-Powered Suggestions: Recommend what to document based on code complexity
Want to contribute? Check out our Contributing section or open an issue to discuss new features!
This project is licensed under the MIT License - see the LICENSE file for details.
Built on CodeFlow's Foundation: DevGuides leverages the powerful analysis capabilities of CodeFlow and other open-source tools:
- CodeFlow - Essential MCP integration for semantic code analysis (MUST be installed from GitHub)
- Model Context Protocol - Open communication standards for agent integration
- ChromaDB - Vector database for semantic search (via CodeFlow)
- OpenAI - LLM capabilities for intelligent documentation synthesis
- Rich - Beautiful terminal output formatting
- Mermaid - Call graph diagram generation (via CodeFlow)
Special Thanks: CodeFlow MCP provides the semantic analysis foundation that enables DevGuides' intelligent code understanding.
- π Documentation
- π Issue Tracker
- π¬ Discussions
- π§ Email Support
Made with β€οΈ for the developer community | Powered by CodeFlow MCP integration | Choose transparency, extensibility, and community ownership.