.claude | ||
.devcontainer | ||
.forgejo/workflows | ||
.roo | ||
docs | ||
features | ||
k8s | ||
scripts | ||
src/cleverclaude | ||
tests | ||
.bumpversion.cfg | ||
.cz-config.js | ||
.cz.json | ||
.dockerignore | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.mcp.json | ||
.pre-commit-config.yaml | ||
.python-version | ||
.roomodes | ||
ATTRIBUTIONS.md | ||
behave.ini | ||
CHANGELOG.md | ||
claude-flow-python-migration-strategy.md | ||
CLAUDE.md | ||
claude_flow_python_architecture.md | ||
claude_flow_python_architecture_implementation_plan.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
CONTRIBUTORS.md | ||
Dockerfile | ||
LICENSE | ||
mkdocs.yml | ||
NOTICE | ||
noxfile.py | ||
pyproject.toml | ||
pyrightconfig.json | ||
pytest.ini | ||
README.md | ||
validate_migration.py |
🧠 CleverClaude
Advanced AI Agent Orchestration System
CleverClaude is a powerful Python-based platform for orchestrating AI agents, managing swarm intelligence, and automating complex tasks through sophisticated multi-agent coordination. Migrated from the original TypeScript claude-flow project with enhanced architecture, modern Python patterns, and comprehensive testing.
✨ Features
🚀 Performance & Speed
- Lightning fast CI: Cold clone to green CI in ≤ 60 seconds
- Rust-powered tools: uv (10-100x faster than pip) + ruff (10-100x faster than flake8/black)
- Optimized Docker: Multi-stage builds with 20MB runtime images
- Parallel testing: nox runs tests across Python versions concurrently
🔒 Type Safety & Quality
- Strict type checking: Pyright in strict mode catches bugs at development time
- Single-tool quality: Ruff replaces 5+ legacy tools (black, isort, flake8, pylint, bandit)
- Pre-commit hooks: Automatic code formatting and linting on commit
- Import sorting: Consistent import organization across the codebase
🧪 Modern Testing
- BDD testing: Natural language specs with Behave (.feature files)
- Property-based fuzzing: Hypothesis automatically discovers edge cases
- Cross-version testing: Automated testing on Python 3.11, 3.12, and 3.13
- Fast feedback: Tests run in seconds, not minutes
🤖 AI-Powered Development
- Claude Code + MCP: 9 pre-configured MCP servers for AI-driven workflows
- End-to-end automation: Code quality, testing, deployment, monitoring via AI
- Infrastructure as Code: AI-assisted OpenTofu/Terraform provisioning
- Smart debugging: AI-powered log analysis and performance monitoring
🐳 Development Experience
- Dev containers: Instant setup with VS Code & GitHub Codespaces + Claude Code
- Shell integration: Pre-configured aliases and shortcuts (including
claude
,mcp-status
) - Hot reloading: Live documentation server and development tools
- Consistent environments: Same tools locally, in CI, and production
☁️ Cloud Native
- Kubernetes ready: Production Helm charts with HPA and monitoring
- Container security: Non-root execution, read-only filesystem, minimal attack surface
- Observability: Health checks, metrics endpoints, structured logging
- GitOps friendly: Declarative configuration and automated deployments
📚 Documentation
- Modern docs: Material for MkDocs with dark mode and search
- Versioned docs: Mike handles documentation versioning automatically
- Living specs: BDD scenarios serve as both tests and documentation
- API docs: Auto-generated from type hints and docstrings
🚀 Quick Start
🐳 Development Container (Recommended)
Get started in 2-3 minutes with zero configuration:
# Clone and open in VS Code
git clone https://git.cleverthis.com/cleverthis/base/base-python
cd base-python && code .
# Click "Reopen in Container" when prompted
# Wait 2-3 minutes for automatic setup
# Everything is ready! Start coding 🎉
# Verify setup
python --version # Python 3.13.x
behave -q # Run BDD tests
nox # Run full test suite
What you get:
- Python 3.13, Node.js 20, Go 1.22+ with all dependencies pre-installed
- Claude Code with 9 MCP servers for AI-driven development
- VS Code with 15+ relevant extensions
- Pre-commit hooks configured
- Shell aliases and shortcuts (including MCP commands)
- Docker-in-Docker for building containers and MCP servers
- kubectl and Helm for Kubernetes development
- AI-powered workflows spanning code quality to production deployment
🌐 GitHub Codespaces
Develop in your browser with zero local setup:
- Go to repository → Code → Codespaces → Create codespace
- Wait 2-3 minutes for automatic environment setup
- Start coding immediately with full IDE experience!
Benefits:
- No local dependencies required
- 4-core, 8GB RAM development environment (optimized for MCP servers)
- 32GB persistent storage
- 60 hours/month free for personal accounts
- Full Claude Code + MCP integration with zero configuration
💻 Local Setup
For developers who prefer local development:
# Install uv (Rust-powered package manager)
pip install uv
# Clone and setup
git clone https://git.cleverthis.com/cleverthis/base/base-python
cd base-python
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .[dev]
# Install pre-commit hooks
pre-commit install
# Verify installation
python --version # Should show Python 3.11+
ruff --version # Linting and formatting
pyright --version # Type checking
behave --version # BDD testing
# Run tests to verify everything works
behave -q
nox
🛠️ Development Workflow
Core Commands
# Code quality (fast!)
nox -s format # Format code with ruff
nox -s lint # Lint code with ruff
nox -s typecheck # Type check with pyright
# Testing
nox -s behave # Run BDD tests on all Python versions
behave -q # Quick BDD test run
behave -t @wip # Run only work-in-progress scenarios
# Documentation
nox -s docs # Build documentation
nox -s serve_docs # Serve docs locally at http://localhost:3000
# Everything
nox # Run all quality checks and tests
# Claude Code + MCP integration
claude # Start Claude Code with MCP servers
mcp-status # Check MCP server status
mcp-logs # View MCP server logs
Advanced Commands
# Package building
nox -s build # Build wheel package
python -m build # Alternative build command
# Pre-commit hooks
pre-commit run --all-files # Run hooks on all files
pre-commit autoupdate # Update hook versions
# Development shortcuts (available in devcontainer)
dev-test # Alias for nox -s behave
dev-lint # Alias for nox -s lint
dev-format # Alias for nox -s format
dev-all # Alias for nox
# AI-powered development with Claude Code + MCP
claude # Start Claude Code with all MCP servers
mcp-status # Check MCP server connectivity
mcp-logs # View MCP server logs
🤖 Claude Code + MCP Integration
The development container includes Claude Code with 9 pre-configured MCP servers that enable AI-driven end-to-end development workflows spanning code quality, testing, containerization, deployment, monitoring, and infrastructure management.
Pre-configured MCP Servers
Code Quality & Testing
- ruff: Python linting, formatting, and import optimization
- uv: Lightning-fast Python package management
- tests: Universal test runner supporting pytest, behave, nox, and custom commands
Development Environment
- devcontainers: Development container lifecycle management
- forgejo: Git repository operations, branch management, PR creation
Infrastructure & Operations
- kubernetes: Cluster operations, pod management, Helm deployments
- prometheus: Metrics queries, alerting rules, performance monitoring
- grafana: Dashboard management, visualization, incident response
- tofu: Infrastructure as Code with OpenTofu/Terraform
Quick Start with MCP
- Build the container: The MCP setup runs automatically during container creation
- Configure tokens: Copy and edit
~/.local/share/mcp-env-template
- Start Claude Code: Run
claude
command - Check status: Use
mcp-status
to verify server connectivity
AI-Powered Workflow Examples
Code Quality Pipeline
claude
# Then in Claude Code:
%%tool ruff ruff_check path="src/"
%%tool tests run_tests framework="behave" command="nox -s behave"
%%tool forgejo create_pull_request repo="cleverclaude" title="feat: new feature"
Infrastructure Management
%%tool kubernetes pods_logs name="app-pod" namespace="prod"
%%tool prometheus execute_query query="up"
%%tool tofu search-opentofu-registry query="aws_s3"
End-to-End CI/CD via AI
# Quality gate: format, lint, test, deploy
%%tool ruff ruff_format path="."
%%tool tests run_tests framework="nox" command="nox -s lint typecheck behave"
%%tool forgejo create_pull_request title="feat: quality improvements"
%%tool kubernetes helm_upgrade release="app" chart="./charts"
MCP Environment Configuration
Copy and customize the environment template:
cp ~/.local/share/mcp-env-template ~/.bashrc
# Edit tokens and endpoints for your infrastructure
Required environment variables:
# Repository management
export FORGEJO_PAT="your-forgejo-personal-access-token"
# Monitoring stack
export PROMETHEUS_URL="http://localhost:9090"
export GRAFANA_API_TOKEN="your-grafana-api-token"
# Container orchestration
export KUBECONFIG="~/.kube/config"
Security & Isolation
- All MCP servers run with minimal privileges
- Containerized servers are network-isolated
- Token-based authentication with environment variables
- Audit logging enabled for all MCP interactions
- Read-only modes available for safe exploration
Advanced Claude Code Subagent Network
Beyond the MCP servers, this project includes a sophisticated network of 16 specialized Claude Code subagents designed to handle complex, multi-faceted development challenges through intelligent collaboration. Each subagent is a deep specialist in their domain with detailed system prompts (1000+ lines each) and sophisticated collaboration protocols.
Subagent Architecture Directory Structure
.claude-code/subagents/
├── registry.json # Central subagent registry and collaboration patterns
├── subagent-manager.py # Management system for subagent coordination
├── core/ # Core development subagents
│ ├── python-quality-analyst.json
│ ├── dependency-manager.json
│ └── performance-optimizer.json
├── testing/ # Testing and quality subagents
│ ├── test-architect.json
│ ├── hypothesis-fuzzer.json
│ ├── test-executor.json
│ └── quality-gatekeeper.json
├── deployment/ # Deployment and infrastructure subagents
│ ├── container-architect.json
│ ├── kubernetes-specialist.json*
│ └── ci-cd-orchestrator.json*
├── docs/ # Documentation and API subagents
│ ├── documentation-architect.json*
│ └── api-specialist.json*
├── monitoring/ # Monitoring and security subagents
│ ├── monitoring-specialist.json*
│ ├── security-auditor.json*
│ └── incident-responder.json*
├── orchestration/ # Orchestration subagents
│ ├── project-coordinator.json
│ └── feature-delivery-manager.json*
└── workflows/ # Advanced workflow subagents
├── code-review-assistant.json*
├── refactoring-specialist.json*
└── user-experience-designer.json*
Note: Files marked with * are defined in the registry but the full implementations are abbreviated for space. The core architecture and key subagents are fully implemented.
🤖 16 Specialized Subagents
Each subagent has deep expertise in their domain:
- 1000+ line system prompts with comprehensive expertise
- Detailed capability definitions and tool integrations
- Sophisticated collaboration protocols with other subagents
- Context-aware decision making for project-specific needs
🔄 Intelligent Collaboration Patterns
Predefined workflows for common development scenarios:
- Quality Pipeline: python-quality-analyst → test-architect → quality-gatekeeper
- Deployment Pipeline: container-architect → kubernetes-specialist → ci-cd-orchestrator → monitoring-specialist
- Feature Development: project-coordinator → test-architect → python-quality-analyst → api-specialist → documentation-architect
- Incident Response: incident-responder → monitoring-specialist → kubernetes-specialist → security-auditor
- Performance Optimization: performance-optimizer → monitoring-specialist → test-architect → kubernetes-specialist
🎯 Advanced Coordination
- Task Analysis: Intelligent analysis of requirements to determine optimal subagent combinations
- Dependency Management: Understanding and managing complex interdependencies between workstreams
- Resource Optimization: Efficient allocation and parallel execution across subagents
- Quality Integration: Quality considerations integrated across all workflows
Fully Implemented Subagents
Core Development
-
python-quality-analyst ✅
- Advanced Python code quality analysis with ruff, pyright, and modern tooling
- Comprehensive static analysis, type checking, security scanning
- Performance analysis and optimization recommendations
- Integration with modern Python 3.11-3.13 features
-
dependency-manager ✅
- UV-based dependency management with 10-100x speed improvements
- Comprehensive security scanning and vulnerability management
- License compliance and supply chain security
- Performance-aware dependency optimization
-
performance-optimizer ✅
- Advanced profiling with cProfile, py-spy, memory_profiler
- Algorithmic optimization and data structure recommendations
- Async/await pattern optimization for Python 3.11-3.13
- Memory analysis and garbage collection optimization
Testing & Quality
-
test-architect ✅
- Expert BDD test design with Behave and Gherkin
- Comprehensive testing strategy across unit/integration/e2e
- Advanced test data management and scenario design
- Integration with property-based testing approaches
-
hypothesis-fuzzer ✅
- Property-based testing with Hypothesis framework
- Advanced edge case discovery and fuzz testing
- Stateful testing for complex systems
- Automatic regression test generation from failures
-
test-executor ✅
- Nox-based test execution across Python 3.11-3.13
- Intelligent parallel execution and resource management
- CI/CD integration with comprehensive reporting
- Smart test selection based on code changes
-
quality-gatekeeper ✅
- Multi-layered quality gates (commit/PR/release levels)
- Advanced pre-commit hook management and optimization
- Release readiness assessment with comprehensive metrics
- Dynamic quality gate adjustment based on risk assessment
Deployment & Infrastructure
- container-architect ✅
- Multi-stage Docker builds with security hardening
- Advanced BuildKit optimization and layer caching
- Comprehensive security scanning and vulnerability management
- DevContainer optimization for development productivity
Orchestration
- project-coordinator ✅
- Master orchestrator for complex, multi-domain tasks
- Intelligent task decomposition and subagent coordination
- Multi-criteria decision making with conflict resolution
- Advanced workflow management and resource optimization
Subagent Management System
The subagent-manager.py
provides comprehensive management:
# System status and health monitoring
python .claude-code/subagents/subagent-manager.py --status
# Available workflow patterns
python .claude-code/subagents/subagent-manager.py --workflows
# Intelligent subagent recommendations
python .claude-code/subagents/subagent-manager.py --recommend "implement OAuth authentication"
# Workflow execution
python .claude-code/subagents/subagent-manager.py --execute quality_pipeline
Key Management Features
- Task Analysis: Intelligent analysis of requirements to determine optimal subagent combinations
- Availability Tracking: Real-time monitoring of subagent status and load
- Workflow Coordination: Execution of predefined and custom workflows
- Performance Monitoring: Tracking of collaboration effectiveness and optimization
Subagent Usage Examples
Quality Assurance Workflow
# Comprehensive code quality validation
workflow = manager.execute_workflow('quality_pipeline', {
'target_files': 'src/',
'coverage_threshold': 90,
'security_scan': True
})
Feature Development Workflow
# End-to-end feature implementation
workflow = manager.execute_workflow('feature_development', {
'feature_spec': 'User authentication with OAuth2',
'testing_approach': 'BDD',
'documentation_required': True
})
Performance Optimization Workflow
# Performance analysis and optimization
workflow = manager.execute_workflow('performance_optimization', {
'target_components': ['api', 'database'],
'benchmarking_enabled': True
})
Integration with Claude Code
The subagents integrate seamlessly with Claude Code through:
- System Prompts: Each subagent has comprehensive system prompts that define their expertise
- Capability Definitions: Clear capability mappings for intelligent task routing
- Collaboration Protocols: Defined interfaces for subagent-to-subagent communication
- Output Formats: Structured deliverables that integrate across subagents
Advanced Features
Multi-Criteria Decision Making
The project-coordinator uses sophisticated decision-making algorithms that consider:
- Quality Impact: Code quality, security, and maintainability implications
- Performance Impact: Runtime and development performance considerations
- Time-to-Market: Development velocity and delivery timeline impact
- Risk Assessment: Technical and business risk evaluation
- Resource Constraints: Available resources and capacity planning
Intelligent Task Routing
The system analyzes task requirements and automatically determines:
- Required Capabilities: What expertise is needed for the task
- Optimal Subagent Combination: Best combination of subagents for the task
- Collaboration Patterns: How subagents should work together
- Execution Strategy: Sequential vs parallel execution optimization
Quality Integration
Quality considerations are integrated across all workflows:
- Quality Gates: Automated quality validation at multiple stages
- Cross-Domain Validation: Quality checks across all technical domains
- Continuous Improvement: Learning from quality metrics to improve processes
- Risk-Based Approach: Quality effort focused on high-risk areas
Claude Code Subagent Quick Reference
System Status
# Check all subagents and their current status
python .claude-code/subagents/subagent-manager.py --status
# List available workflow patterns
python .claude-code/subagents/subagent-manager.py --workflows
Getting Recommendations
# Get subagent recommendations for specific tasks
python .claude-code/subagents/subagent-manager.py --recommend "fix performance issues in API"
python .claude-code/subagents/subagent-manager.py --recommend "implement new authentication feature"
python .claude-code/subagents/subagent-manager.py --recommend "improve test coverage"
Common Workflows
1. Code Quality Pipeline
Scenario: Comprehensive code quality validation before PR merge
Subagents Involved:
- python-quality-analyst
- test-architect
- quality-gatekeeper
Usage:
python .claude-code/subagents/subagent-manager.py --execute quality_pipeline
What it does:
- Analyzes code quality with ruff, pyright, and security scanning
- Validates test coverage and BDD scenarios
- Enforces quality gates for PR approval
2. Feature Development Workflow
Scenario: End-to-end new feature implementation
Subagents Involved:
- project-coordinator (orchestrates)
- test-architect (BDD scenarios)
- python-quality-analyst (code quality)
- api-specialist (API design)
- documentation-architect (docs)
Usage:
python .claude-code/subagents/subagent-manager.py --execute feature_development
What it does:
- Analyzes feature requirements and creates implementation plan
- Designs BDD test scenarios first (TDD approach)
- Implements code with quality gates
- Creates API specifications and documentation
- Validates entire feature end-to-end
3. Deployment Pipeline
Scenario: Prepare and deploy application to production
Subagents Involved:
- container-architect
- kubernetes-specialist
- ci-cd-orchestrator
- monitoring-specialist
Usage:
python .claude-code/subagents/subagent-manager.py --execute deployment_pipeline
What it does:
- Optimizes Docker containers for production
- Prepares Kubernetes manifests and Helm charts
- Sets up CI/CD pipeline for automated deployment
- Configures monitoring and observability
4. Performance Optimization
Scenario: Identify and fix performance bottlenecks
Subagents Involved:
- performance-optimizer
- monitoring-specialist
- test-architect
- kubernetes-specialist
Usage:
python .claude-code/subagents/subagent-manager.py --execute performance_optimization
What it does:
- Profiles application performance and identifies bottlenecks
- Correlates with production monitoring data
- Creates performance tests for validation
- Optimizes Kubernetes resource allocation
5. Incident Response
Scenario: Production issue investigation and resolution
Subagents Involved:
- incident-responder
- monitoring-specialist
- kubernetes-specialist
- security-auditor
Usage:
python .claude-code/subagents/subagent-manager.py --execute incident_response
What it does:
- Analyzes logs and identifies issue patterns
- Correlates with monitoring metrics
- Investigates infrastructure and security aspects
- Provides coordinated resolution plan
Individual Subagent Usage
Python Quality Analysis
# In Claude Code, invoke the python-quality-analyst subagent
# This would be done through Claude Code's interface, not command line
# Example interaction:
"Analyze the code quality in src/ directory focusing on type safety and security"
# The subagent will:
# - Run comprehensive ruff analysis
# - Perform strict pyright type checking
# - Execute security scans with bandit
# - Provide prioritized recommendations
BDD Test Design
# Invoke test-architect subagent
"Create BDD scenarios for the new user authentication feature"
# The subagent will:
# - Analyze feature requirements
# - Create comprehensive Gherkin scenarios
# - Design test data strategies
# - Integrate with Hypothesis for property-based testing
Container Optimization
# Invoke container-architect subagent
"Optimize the Dockerfile for production deployment with security hardening"
# The subagent will:
# - Design multi-stage build process
# - Implement security hardening measures
# - Optimize image size and build time
# - Configure runtime security settings
Advanced Coordination Examples
Complex Refactoring Project
# Multiple subagents coordinate for large refactoring
# project-coordinator orchestrates:
1. refactoring-specialist: Plans refactoring strategy
2. test-architect: Ensures comprehensive test coverage
3. performance-optimizer: Validates performance impact
4. security-auditor: Reviews security implications
5. documentation-architect: Updates documentation
Security Incident Response
# Coordinated security incident handling
# incident-responder leads coordination with:
1. security-auditor: Deep security analysis
2. monitoring-specialist: Correlates attack patterns
3. kubernetes-specialist: Checks infrastructure compromise
4. container-architect: Reviews container security
Release Preparation
# Comprehensive release readiness validation
# project-coordinator orchestrates:
1. quality-gatekeeper: Validates all quality gates
2. security-auditor: Final security validation
3. performance-optimizer: Performance regression tests
4. test-executor: Comprehensive test suite execution
5. container-architect: Production container preparation
6. kubernetes-specialist: Deployment readiness validation
Subagent Capabilities Reference
Core Development
- python-quality-analyst: Static analysis, type checking, security scanning, performance analysis
- dependency-manager: Security scanning, license compliance, version optimization, environment management
- performance-optimizer: Profiling, bottleneck identification, memory analysis, async optimization
Testing & Quality
- test-architect: BDD design, Gherkin writing, test strategy, coverage analysis
- hypothesis-fuzzer: Property-based testing, edge case discovery, fuzz testing, regression generation
- test-executor: Test orchestration, parallel execution, CI/CD integration, result analysis
- quality-gatekeeper: Quality gates, pre-commit management, release readiness, compliance checking
Deployment & Infrastructure
- container-architect: Multi-stage builds, security hardening, performance optimization, DevContainer design
- kubernetes-specialist: K8s deployment, Helm charts, autoscaling, service mesh
- ci-cd-orchestrator: Pipeline design, deployment automation, artifact management, branch strategies
Documentation & API
- documentation-architect: MkDocs structure, API docs, technical writing, versioning
- api-specialist: API design, OpenAPI specs, endpoint optimization, validation design
Monitoring & Security
- monitoring-specialist: Metrics design, dashboard creation, alerting rules, SLI/SLO design
- security-auditor: Vulnerability assessment, compliance checking, threat modeling, incident analysis
- incident-responder: Log analysis, debugging, root cause analysis, remediation planning
Orchestration & Workflows
- project-coordinator: Task coordination, workflow orchestration, resource optimization, decision making
- feature-delivery-manager: End-to-end delivery, cross-team coordination, stakeholder communication
- code-review-assistant: Code review, best practices, mentoring, security review
- refactoring-specialist: Code refactoring, architecture improvement, technical debt management
Best Practices
- Start with Recommendations: Always use
--recommend
to get optimal subagent suggestions - Use Predefined Workflows: Leverage existing workflow patterns for common tasks
- Monitor System Status: Check subagent availability before executing complex workflows
- Coordinate Related Tasks: Use project-coordinator for complex, multi-domain tasks
- Validate Integration: Ensure outputs from different subagents integrate properly
- Learn from Results: Analyze workflow results to improve future coordination
Subagent Troubleshooting
Subagent Not Available
# Check system status
python .claude-code/subagents/subagent-manager.py --status
# Wait for busy subagents to complete or restart the system
Workflow Failures
# Check logs for specific workflow issues
tail -f ~/.local/share/mcp-logs/subagent-*.log
# Restart individual subagents if needed
# (Implementation would depend on actual deployment)
Performance Issues
# Monitor subagent resource usage
# Optimize workflow patterns for better parallelization
# Consider reducing concurrent workflow execution
Subagent System Benefits
- Specialized Expertise: Deep domain expertise in each area
- Comprehensive Coverage: End-to-end development lifecycle support
- Intelligent Coordination: Smart collaboration between different domains
- Quality Integration: Quality built into every workflow
- Scalable Architecture: Grows with project complexity
- Context Awareness: Understanding of project-specific constraints and goals
This comprehensive subagent network provides unprecedented AI-powered development capabilities, enabling sophisticated workflows that span the entire software development lifecycle. The advanced subagent network transforms Claude Code into a comprehensive AI development team capable of handling sophisticated, enterprise-level development challenges through intelligent collaboration and specialized expertise.
Testing Strategy
This project uses Behavior-Driven Development (BDD) with comprehensive fuzzing:
# features/cli.feature
Feature: Command-line greeting interface
Scenario: Default greeting
When I run "python -m cleverclaude"
Then the exit code should be 0
And the output should contain "Hello, World!"
@hypothesis
Scenario: Fuzz test greeting names
When I fuzz test the CLI with random names
Then all invocations should succeed
Why BDD?
- Tests serve as living documentation
- Natural language specifications
- Stakeholder-friendly test reports
- Automatic edge-case discovery with Hypothesis
🐳 Docker Deployment
Development
# Build development image
docker build -t cleverclaude:dev .
# Run interactively
docker run --rm -it cleverclaude:dev bash
# Run CLI
docker run --rm cleverclaude:dev --name "Docker" --count 3
Production
# Build optimized production image
docker build -t cleverclaude:latest .
# Run with resource limits
docker run --rm \
--memory=256m \
--cpus=0.5 \
--read-only \
--user=1000 \
cleverclaude:latest --help
# Multi-platform build
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/cleverthis/cleverclaude:latest \
--push .
Docker Features:
- Multi-stage builds for minimal image size (20MB runtime)
- Non-root user execution for security
- Read-only filesystem
- Health checks and signal handling
☸️ Kubernetes Deployment
Quick Deploy
# Deploy with default configuration
helm install cleverclaude ./k8s
# Deploy with custom values
helm install cleverclaude ./k8s \
--set image.tag=v0.2.0 \
--set replicaCount=3 \
--set resources.limits.memory=512Mi
Production Configuration
# values-production.yaml
image:
tag: v0.1.0
pullPolicy: Always
replicaCount: 3
resources:
limits:
cpu: 1000m
memory: 512Mi
requests:
cpu: 200m
memory: 256Mi
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 10
targetCPUUtilizationPercentage: 60
ingress:
enabled: true
className: nginx
hosts:
- host: api.example.com
paths:
- path: /
pathType: Prefix
# Deploy to production
helm upgrade --install cleverclaude ./k8s \
-f values-production.yaml \
--namespace production \
--create-namespace \
--wait
Kubernetes Features:
- Horizontal Pod Autoscaling (HPA)
- Resource limits and requests
- Security contexts and pod security standards
- Readiness and liveness probes
- ConfigMap and Secret support
🔧 Build Chain & Tools
Package Management: uv
uv is a Rust-powered Python package manager that's 10-100x faster than pip:
# Install dependencies
uv pip install -e .[dev] # Editable install with dev dependencies
uv pip sync requirements.txt # Sync exact versions
uv pip compile pyproject.toml # Generate lock file
# Virtual environments
uv venv # Create .venv/
uv venv --python 3.13 # Specific Python version
Why uv?
- 10-100x faster than pip
- Drop-in pip replacement
- Better dependency resolution
- Parallel downloads and installs
Code Quality: Ruff
Ruff is a Rust-powered linter and formatter that replaces 5+ tools:
# Linting (replaces flake8, pylint, bandit, etc.)
ruff check . # Check for issues
ruff check --fix . # Fix auto-fixable issues
# Formatting (replaces black, isort)
ruff format . # Format code
ruff format --check . # Check if formatting needed
# Import sorting (replaces isort)
ruff check --select I --fix . # Fix import organization
Ruff replaces:
- black (code formatting)
- isort (import sorting)
- flake8 (linting)
- pylint (linting)
- bandit (security)
- pydocstyle (docstring style)
- pyupgrade (syntax modernization)
Type Checking: Pyright
Pyright provides strict type checking:
pyright # Type check entire project
pyright src/ # Check specific directory
pyright --stats # Show type coverage stats
Configuration (pyrightconfig.json):
{
"typeCheckingMode": "strict",
"reportMissingImports": true,
"reportMissingTypeStubs": false
}
Testing: Behave + Hypothesis
Behave for BDD + Hypothesis for property-based testing:
behave # Run all scenarios
behave -q # Quiet mode
behave -t @smoke # Run smoke tests only
behave -t ~@wip # Skip work-in-progress
behave --junit # JUnit XML output
Automation: nox
nox provides reproducible test automation:
nox # Run all sessions
nox -s behave # Run tests only
nox -s lint typecheck # Run specific sessions
nox -l # List available sessions
nox -s behave-3.13 # Run on specific Python version
Available nox sessions:
behave
: Run BDD tests on Python 3.11, 3.12, 3.13lint
: Code linting with ruffformat
: Code formatting with rufftypecheck
: Type checking with pyrightdocs
: Build documentationserve_docs
: Serve docs locallybuild
: Build wheel package
Build System: Hatchling
Modern PEP 621 compliant build backend:
python -m build # Build wheel and sdist
python -m build --wheel # Build wheel only
hatch version # Show current version
hatch version patch # Bump patch version
Documentation: MkDocs Material
MkDocs Material with versioning:
mkdocs build # Build static site
mkdocs serve # Serve at localhost:8000
mike deploy v0.1.0 latest # Deploy versioned docs
mike set-default latest # Set default version
📁 Project Structure
cleverclaude/
├── src/cleverclaude/ # 📦 Source code
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Entry point for python -m
│ └── cli.py # Command-line interface
├── features/ # 🧪 BDD test specifications
│ ├── environment.py # Test environment setup
│ ├── steps/ # Step definitions
│ │ └── cli_steps.py # CLI test steps with Hypothesis
│ └── cli.feature # Feature specifications
├── k8s/ # ☸️ Kubernetes deployment
│ ├── Chart.yaml # Helm chart metadata
│ ├── values.yaml # Default configuration
│ └── templates/ # Kubernetes manifests
│ ├── deployment.yaml # Pod deployment
│ ├── service.yaml # Service definition
│ ├── hpa.yaml # Horizontal Pod Autoscaler
│ └── configmap.yaml # Configuration
├── .devcontainer/ # 🐳 Development container with Claude Code + MCP
│ ├── devcontainer.json # VS Code dev container config
│ ├── Dockerfile # Development environment with Claude Code + MCP servers
│ ├── post-create.sh # Setup script with MCP initialization
│ ├── setup-mcp.sh # MCP server configuration and setup
│ ├── claude-code-config.json # Claude Code MCP server configuration
│ └── bashrc-append.sh # Shell customizations with MCP aliases
├── .forgejo/workflows/ # 🚀 CI/CD pipeline
│ └── ci.yml # Automated testing and building
├── docs/ # 📚 Documentation
│ ├── index.md # Homepage
│ ├── devcontainer.md # Dev container guide
│ ├── behaviour.md # BDD specifications
│ ├── api.md # API reference
│ └── deployment.md # Deployment guide
├── scripts/ # 🔧 Utility scripts
│ └── deploy_docs.sh # Documentation deployment
├── pyproject.toml # 📋 Project configuration (PEP 621)
├── noxfile.py # 🔄 Test automation
├── behave.ini # 🧪 BDD test configuration
├── pyrightconfig.json # 🔍 Type checker configuration
├── mkdocs.yml # 📖 Documentation configuration
├── Dockerfile # 🐳 Production container
├── .dockerignore # Docker build exclusions
├── .gitignore # Git exclusions
├── .pre-commit-config.yaml # Pre-commit hooks
├── README.md # This file
├── CHANGELOG.md # Version history
└── LICENSE # Apache 2.0 license
🔄 Modern Python Development
Key Architectural Improvements
Unified Configuration:
# pyproject.toml - Single file replaces 4+ legacy files
[project]
name = "myproject"
version = "0.1.0"
dependencies = ["click>=8.1.7"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.ruff]
line-length = 120
target-version = "py311"
Single Quality Tool:
# Replace 5+ legacy tools with one Rust-powered tool
ruff format . # Code formatting (replaces black + isort)
ruff check . # Linting (replaces flake8 + pylint + bandit)
pyright # Type checking (5x faster than mypy)
Natural Language Testing:
# BDD scenarios serve as living documentation
Scenario: Custom name greeting
When I run "python -m cleverclaude --name Alice"
Then the exit code should be 0
And the output should contain "Hello, Alice!"
@hypothesis
Scenario: Fuzz test with random inputs
When I test with randomly generated data
Then all edge cases should be handled correctly
🚨 Troubleshooting
Common Issues
uv not found after installation:
# Ensure PATH includes uv
pip install --user uv
export PATH="$HOME/.local/bin:$PATH"
# Or install globally
pip install uv
Virtual environment issues:
# Clean and recreate
rm -rf .venv
uv venv
source .venv/bin/activate
uv pip install -e .[dev]
Ruff/Pyright not working in VS Code:
- Install the extensions:
charliermarsh.ruff
andms-python.vscode-pylance
- Reload VS Code window: Ctrl+Shift+P → "Developer: Reload Window"
- Check Python interpreter: Ctrl+Shift+P → "Python: Select Interpreter"
Behave tests failing:
# Check feature file syntax
behave --dry-run
# Run with verbose output
behave -v
# Check step definitions
behave --no-skipped -v
MCP servers not starting:
# Check MCP server logs
mcp-logs
# Verify environment variables
cat ~/.local/share/mcp-env-template
# Test individual servers
claude --list-servers
# Check Docker for containerized servers
docker ps
Missing MCP tokens:
# Copy environment template
cp ~/.local/share/mcp-env-template ~/.bashrc
source ~/.bashrc
# Verify tokens are set
echo $FORGEJO_PAT
echo $GRAFANA_API_TOKEN
Docker build issues:
# Clear Docker cache
docker builder prune
# Build with no cache
docker build --no-cache -t cleverclaude:latest .
# Check multi-platform support
docker buildx ls
Performance Issues
Slow pip install:
# Use uv instead (10-100x faster)
uv pip install -e .[dev]
Slow linting:
# Use ruff instead of flake8/pylint (10-100x faster)
ruff check .
Slow CI:
# Parallel testing with nox
nox -s behave -- --processes 4
# Use GitHub Actions matrix
# See .forgejo/workflows/ci.yml
📈 Performance Benchmarks
Tool Speed Comparison
Tool | Legacy | Modern | Speedup |
---|---|---|---|
Package Install | pip | uv | 10-100x |
Code Formatting | black | ruff format | 10-100x |
Linting | flake8 | ruff check | 10-100x |
Import Sorting | isort | ruff check --select I | 10-100x |
Type Checking | mypy | pyright | 5-10x |
CI Pipeline Performance
- Cold clone to green CI: ≤ 60 seconds
- Warm cache builds: ≤ 30 seconds
- Parallel test execution: 3 Python versions simultaneously
- Container builds: ≤ 2 minutes with BuildKit
🎯 Best Practices
Development
- Use the devcontainer for consistent environments
- Run
nox
before commits to catch issues early - Write BDD scenarios for new features
- Use type hints everywhere for better code quality
- Keep dependencies minimal for faster installs
Testing
- BDD scenarios serve as living documentation
- Hypothesis fuzzing finds edge cases automatically
- Test across Python versions with nox
- Use descriptive scenario names that explain business value
- Tag scenarios (
@smoke
,@wip
) for selective testing
Deployment
- Use Helm charts for Kubernetes deployments
- Set resource limits to prevent resource exhaustion
- Enable HPA for automatic scaling
- Use health checks for reliable deployments
- Monitor application metrics in production
📖 Documentation
Complete Documentation
Visit https://cleverthis.github.io/cleverclaude for:
- 📋 Getting Started Guide
- 🐳 Development Container Setup
- 🧪 BDD Testing Guide
- 🔧 API Reference
- ☸️ Kubernetes Deployment
- 🚀 CI/CD Configuration
- 🛠️ Troubleshooting Guide
Local Documentation
# Serve docs locally
nox -s serve_docs
# Build static docs
nox -s docs
# Deploy versioned docs
scripts/deploy_docs.sh
🤝 Contributing
- Use the devcontainer for consistent development environment with Claude Code + MCP
- Follow BDD practices - write scenarios before implementation
- Leverage AI workflows - use Claude Code with MCP servers for development tasks
- Ensure all checks pass - run
nox
before submitting PRs - Update documentation for any new features
- Use conventional commits for clear change history
Development Process
# 1. Start development container
code . # Click "Reopen in Container"
# 2. Create feature branch
git checkout -b feature/awesome-feature
# 3. Write BDD scenario
# Edit features/cli.feature
# 4. Use AI-assisted development (optional)
claude # Start Claude Code with MCP servers for AI-powered development
# 5. Implement feature
# Edit src/cleverclaude/cli.py
# 6. Run tests
nox -s behave
# 7. Check code quality
nox -s lint typecheck
# 8. Commit changes
git add .
git commit -m "feat: add awesome feature"
# 9. Push and create PR
git push origin feature/awesome-feature
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🚀 Ready to build something amazing with AI? Choose your setup method above and start coding with Claude Code + MCP in minutes!