A Python implementation of the Compounding Engineering Plugin using DSPy.
Each unit of engineering work should make subsequent units of work easier—not harder.
This CLI tool provides AI-powered development tools for code review, planning, and workflow automation, following the compounding engineering philosophy. It is designed as a Local-First tool that runs on your machine, keeping your code secure while leveraging powerful LLMs.
-
🧠 Compounding Engineering: True learning system where every operation makes the next one easier
- Auto-Learning: Every todo resolution automatically codifies learnings
- KB Auto-Injection: Past learnings automatically inform all AI operations
- Pattern Recognition: Similar issues are prevented based on past resolutions
- Knowledge Accumulation: System gets smarter with every use
-
🔍 Multi-Agent Code Review: Run 10+ specialized review agents in parallel
- Security Sentinel: Detects vulnerabilities (SQLi, XSS, etc.)
- Performance Oracle: Identifies bottlenecks and O(n) issues
- Architecture Strategist: Reviews design patterns and SOLID principles
- Data Integrity Guardian: Checks transaction safety and validation
- KB-Augmented: All agents benefit from past code review learnings
- And many more...
-
🤖 ReAct File Editing: Intelligent file operations with reasoning
- Smart Context Gathering: Relevance-scored file selection and token budget management
- Iterative Reasoning: Think → Act → Observe → Iterate pattern
- Zero Hallucination: Direct file manipulation, not text generation
-
🛡️ Secure Work Execution: Safely execute AI-generated plans
- Isolated Worktrees: High-level isolation for safe parallel execution via
--worktree - Parallel Processing: Multi-threaded todo resolution with
--workers - Auto-Codification: Every resolution creates learnings for future use
- Isolated Worktrees: High-level isolation for safe parallel execution via
-
📋 Smart Planning: Transform feature descriptions into detailed plans
- Repository research & pattern analysis
- 🌐 Internet Search: Access live sources and current standards
- Documentation Fetcher: Deep-read official documentation from URLs
- SpecFlow user journey analysis
- KB-Informed: Plans leverage past architectural decisions
-
✅ Interactive Triage: Manage code review findings
- Batch Operations: Approve multiple findings at once
- Smart Priorities: Auto-detection of P1/P2/P3 severity
- Work Logs: Tracks decisions and rationale automatically
- KB-Augmented: Triage decisions informed by past patterns
Install uv (fast Python package installer):
curl -LsSf https://astral.sh/uv/install.sh | sh# Clone repository
git clone https://github.com/Strategic-Automation/dspy-compounding-engineering.git
cd dspy-compounding-engineering
# Configure environment
cp .env.example .env
# Edit .env with your API keys (OpenAI, Anthropic, or Ollama)
# Install dependencies
uv syncTo use compounding in other repositories, install it globally using uv tool:
# Install globally from source
uv tool install .
# or from git once published
# uv tool install git+https://github.com/Strategic-Automation/dspy-compounding-engineering.gitThis exposes the compounding command globally, allowing you to run it inside any project folder.
This project uses Qdrant for semantic search. A Docker Compose configuration is provided.
-
Start Qdrant:
docker compose up -d qdrant
This will start Qdrant on
localhost:6333. -
Configure Embeddings: Ensure your
.envhas the correctEMBEDDING_BASE_URLif you are using a non-standard provider (like OpenRouter). See.env.example.
Note: If Qdrant is not running, the system will automatically fall back to keyword-based search using local JSON files.
The repository includes a small wrapper script uvx that runs the CLI via uv run without doing a global install. It's useful for quickly trying commands locally:
./uvx -h
./uvx generate-agent "create an agent to check for hardcoded secrets"The script is in the repository root and is executable; run it from the repo directory.
You can also prefix commands with compounding, for example ./uvx compounding generate-agent.
Quick example using the temporary runner uvx to see the generate-agent help:
./uvx generate-agent -hExpected excerpt:
Usage: compounding generate-agent [OPTIONS] DESCRIPTION
Generate a new Review Agent from a natural language description.
Options:
--dry-run -n Show what would be created without writing files
--help -h Show this message and exit.
You can run other commands similarly, for example:
./uvx -h
./uvx review --project
./uvx work p1 --env-file test.envThe tool supports several global options that can be used with any command:
-e, --env-file PATH: Explicitly specify a.envfile to load.-h, --help: Show help for any command.
The tool loads configuration from multiple sources in the following priority order:
- Explicit Flag:
--env-file/-eon the command line. - Environment Variable:
COMPOUNDING_ENVpointing to a.envfile path. - Local Override:
.envin the current working directory (CWD). - Tool-Specific Global:
~/.config/compounding/.env. - System Fallback:
~/.envin the user's home directory.
Tip
This priority allows you to have a global ~/.config/compounding/.env with your API keys while using local .env files for project-specific model selections.
This implementation embodies the core philosophy: each unit of work makes subsequent work easier.
graph LR
A[Plan] -->|KB Context| B[Execute Work]
B -->|KB Context| C[Review Code]
C -->|KB Context| D[Triage Findings]
D -->|Auto-Codify| KB[(Knowledge Base)]
KB -->|Auto-Inject| A
KB -->|Auto-Inject| B
KB -->|Auto-Inject| C
KB -->|Auto-Inject| D
style KB fill:#4CAF50,stroke:#333,stroke-width:3px
style D fill:#FFC107,stroke:#333,stroke-width:2px
How it works:
- Auto-Injection: All AI operations (
review,triage,plan,work) automatically receive relevant past learnings - Auto-Codification: Every todo resolution automatically extracts and stores learnings
- Pattern Recognition: The system identifies similar issues and suggests solutions based on past successes
- Continuous Improvement: The more you use it, the smarter it gets
- Persistent Learning: Learnings stored in
.knowledge/as structured JSON - Smart Retrieval: Keyword-based similarity matching (extensible to vector embeddings)
- Auto-Documentation:
AI.mdautomatically updated with consolidated learnings - Tagged Search: Filter learnings by category, source, or topic
See our detailed Roadmap for upcoming features.
Key focus areas:
- GitHub Integration: Create Issues, post PR comments, manage Projects (Partially Completed)
- Vector Embeddings: Upgrade from keyword matching to semantic similarity (Completed)
- Smart Context: Intelligent relevance-scored gathering (Completed)
- Learning Analytics: Dashboard showing knowledge growth and reuse
Edit .env to configure your LLM provider:
# OpenAI
DSPY_LM_PROVIDER=openai
DSPY_LM_MODEL=gpt-5.1-codex
OPENAI_API_KEY=sk-...
# Anthropic
DSPY_LM_PROVIDER=anthropic
DSPY_LM_MODEL=claude-4-5-haiku
ANTHROPIC_API_KEY=sk-ant-...
# Ollama (Local)
DSPY_LM_PROVIDER=ollama
DSPY_LM_MODEL=qwen3
# OpenRouter (Multi-Model Access)
DSPY_LM_PROVIDER=openrouter
DSPY_LM_MODEL=x-ai/grok-4.1-fast:free
OPENROUTER_API_KEY=sk-or-...
# Context Limits (Optional)
CONTEXT_WINDOW_LIMIT=128000
CONTEXT_OUTPUT_RESERVE=4096
DOCS_MAX_TOKENS=32768 # Limit for documentation fetching (default: 32k)As a tool meant to be used across multiple repositories, configuration can be managed at different levels:
- Global: Store your API keys in
~/.config/compounding/.envso they are available everywhere. - Local: Add a
.envin your project root to override models or settings for that specific project. - On-the-fly: Use
--env-file path/to/.envto quickly switch between different environments (e.g., testing vs. production models).
The tool will warn you if multiple conflicting configuration files are detected.
Tip
If you have installed the tool via uv tool install --from ., you can use the compounding command directly. Otherwise, use uv run python cli.py.
Run a comprehensive multi-agent review on your current changes or a specific PR:
# Review latest local changes
compounding review
# Review a specific PR ID
compounding review 86
# Review a specific branch
compounding review dev
# Review a full PR URL (requires gh cli)
compounding review https://github.com/user/repo/pull/123
# Review entire project (not just changes)
compounding review --projectNote: The review process automatically ignores lock files (e.g.,
uv.lock,package-lock.json) and standard binary/cache directories to reduce noise.
Process the findings generated by the review:
compounding triage- Yes: Approve and convert to ready todo
- Next: Skip or delete
- All: Batch approve all remaining items
- Custom: Change priority or details
Unified command for resolving todos or executing plans using ReAct agents:
# Resolve all P1 priority todos
compounding work p1
# Resolve specific todo by ID
compounding work 001
# Execute a plan file
compounding work plans/feature.md
# Preview changes without applying (dry run)
compounding work p1 --dry-run
# Use isolated worktree (safe parallel execution)
compounding work p1 --worktree
# Control parallelization
compounding work p2 --sequential # Sequential execution
compounding work p2 --workers 5 # 5 parallel workersThis will:
- Auto-detect input type (todo ID, plan file, or pattern)
- Use ReAct reasoning for intelligent file operations
- Execute in-place (default) or in isolated worktree (
--worktree) - Process todos in parallel (default) or sequentially (
--sequential) - Mark todos as complete (
*-complete-*.md) - Clean up worktrees automatically
Generate new review agents from natural language descriptions:
# Generate a new agent
compounding generate-agent "Check for SQL injection vulnerabilities"
# Preview without creating files
compounding generate-agent "Ensure all Python functions have docstrings" --dry-runGenerate a detailed implementation plan from a description or GitHub issue:
# Plan from a natural language description
compounding plan "Add user authentication with OAuth"
# Plan from a GitHub issue (ID or URL)
compounding plan 30
compounding plan https://github.com/user/repo/issues/30Capture and codify learnings into the knowledge base:
compounding codify "Always validate user input before database operations"
compounding codify "Use factory pattern for agent creation" --source retroThe system is built on a layered architecture designed for modularity and compounding intelligence:
- Entry Point:
cli.pyusesTyperto provide a robust command-line interface. - Commands: Maps user intents (e.g.,
review,work) to specific workflows.
- Logic: Python scripts in
workflows/orchestrate complex multi-step processes. - Responsibility: Manages state, handles user interaction, and coordinates agents.
- Key Workflows:
- Unified Work: Combines planning and execution using ReAct loops.
- Review Pipeline: Parallelizes multiple specialized review agents.
- Triage System: Manages findings and prioritizes work.
- Signatures: Declarative definitions of AI tasks in
agents/. - Modules:
dspy.Moduleimplementations that chain thoughts and actions. - Optimization: Agents are optimized via DSPy teleprompters.
- Storage: JSON-based knowledge base in
.knowledge/. - Retrieval:
KBPredictwrapper automatically injects relevant context into agent calls. - Learning:
LearningExtractorcodifies outcomes from every task into reusable patterns.
- Git Service: Manages isolated worktrees for safe execution.
- Project Context: Efficiently gathers and token-limits codebase context.
- Todo Service: Standardizes the unit of work (Markdown-based todos).
Based on the Compounding Engineering philosophy:
- Plan → Delegate → Assess → Codify (fully implemented)
- Each unit of work makes subsequent work easier (via KB auto-injection)
- Systematic beats heroic (automated learning and reuse)
- Quality compounds over time (system gets smarter with use)
- Knowledge is automatically codified (not optional)
| Feature | Original Plugin | This DSPy Edition |
|---|---|---|
| Runtime | Claude Code Plugin | Standalone Python CLI |
| LLM | Claude Only | OpenAI, Anthropic, Ollama |
| Execution | Direct File Edit | Secure Git Worktrees |
| Integration | GitHub App | Local-First CLI |
| Learning | Manual CLAUDE.md | Automatic KB Injection |
| Codification | Manual | Automatic on every resolution |
We welcome contributions! If you're looking for ways to help, please check out our Issues on GitHub.
See CONTRIBUTING.md for detailed guidelines.
MIT
Original concept by Kieran Klaassen at Every.to. DSPy framework by Stanford NLP Group.