Claude Code for DSPy: AI-powered interactive development environment for DSPy
Project description
๐ Your AI-Powered DSPy Development & Optimization Assistant
Develop DSPy Applications โข Optimize with GEPA โข Deploy with Confidence. Think of it as Claude Code for DSPy
๐ Documentation โข ๐ Quick Start โข ๐ก Examples โข ๐ค Contributing
โก Claude Code for DSPy
๐ Get Started in 30 Seconds
pip install --upgrade dspy-code
dspy-code
Develop DSPy Code โ Optimize with GEPA โ Deploy Production-Ready Apps
๐ก Note: DSPy Code is in its initial release and under active development. The quality and effectiveness of generated code depends on several factors: the language model you connect, MCP (Model Context Protocol) servers you integrate, and the context you provide to DSPy Code. We're continuously improving based on community feedback.
โจ What is DSPy Code?
The Complete DSPy Development & Optimization Platform
DSPy Code is a dual-purpose CLI that empowers you to:
๐๏ธ Develop DSPy Applications
Build, learn, and create DSPy programs with natural language. Generate signatures, modules, and complete applications with AI-powered assistance.
๐งฌ Optimize with GEPA
Transform your DSPy code into production-ready applications using GEPA (Genetic Pareto). Automatically improve accuracy, evolve prompts, and achieve better performance.
The Complete Workflow:
Develop โ Validate โ Optimize with GEPA โ Deploy
๐ก Learn as you build. Whether you're a complete beginner or a DSPy expert, the CLI adapts to your level and guides you through every step.
๐ฏ Perfect For:
| ๐๏ธ Development | ๐งฌ Optimization |
|---|---|
| ๐ Learning DSPy concepts | โก GEPA optimization workflows |
| ๐ Building new projects | ๐ Automated metric evaluation |
| ๐ Code generation | ๐ Prompt evolution |
| โ Validation & best practices | ๐ Performance improvement |
| ๐ Codebase understanding | ๐ฏ Production-ready code |
๐ฏ Why DSPy Code?
"Why not just use Claude Code or Cursor, DeepWiki, CodeWiki with the DSPy repository?" While general AI assistants can help with DSPy, they lack the deep specialization that makes DSPy Code uniquely powerful:
What Makes DSPy Code Special?
| Generic AI Assistants | DSPy Code |
|---|---|
| ๐ Generic coding help | ๐ DSPy-Native Intelligence - Built-in knowledge of all 10 predictors, 11 optimizers, 4 adapters, and DSPy patterns |
| ๐ Unaware of your setup | ๐ฆ Version-Aware - Indexes YOUR installed DSPy version and generates compatible code |
| ๐ญ Code suggestions only | ๐งฌ Real GEPA Execution - Actually runs optimization workflows, not just code generation |
| ๐ Basic file reading | ๐ Codebase RAG - Deeply understands your entire project structure and patterns |
| โ๏ธ Syntax checking | โ DSPy Validation - Enforces signatures, modules, predictors, and best practices |
| ๐คท Generic workflows | โ๏ธ Complete Automation - End-to-end workflows from /init to /export |
| ๐ No tool integration | ๐ MCP Client Built-in - Connect to external tools and services seamlessly |
| ๐ Start from scratch | ๐ 20+ Templates - Pre-built patterns for RAG, QA, classification, and more |
Real-World Impact
Learning DSPy:
- Generic AI: Hours of reading docs, piecing together concepts
- DSPy Code: Ask "What is ChainOfThought?" โ Get comprehensive answer with examples instantly
Building a RAG System:
- Generic AI: Days of manual setup, configuration, testing
- DSPy Code:
/initโ "Create a RAG system" โ/validateโ/optimizeโ Done in hours
Optimizing Code:
- Generic AI: Manual GEPA setup, metric functions, data formatting
- DSPy Code:
/optimize my_program.pyโ Automated workflow with progress tracking
The Bottom Line
DSPy Code is a purpose-built development environment that embeds DSPy expertise into every interaction, automates tedious workflows, and accelerates your development from hours to minutes.
๐ Two Core Workflows
Workflow 1: Develop DSPy Applications
From idea to working code in minutes:
- Start -
/initto create or scan your project - Describe - Tell DSPy Code what you want in natural language
- Generate - Get working DSPy code (signatures, modules, programs)
- Validate - Ensure code follows DSPy best practices
- Iterate - Refine and improve with interactive Q&A
Example:
dspy-code
/init
โ "Create a sentiment analyzer for customer reviews"
/validate
Workflow 2: Optimize with GEPA
From working code to production-ready in hours:
- Prepare - Have your DSPy program ready
- Generate Data - Create training examples with
/data - Optimize - Run GEPA optimization with
/optimize - Evaluate - Test performance improvements
- Deploy - Export optimized, production-ready code
Example:
dspy-code
/data sentiment 20 # Generate 20 training examples
/optimize my_program.py # Run GEPA optimization
/eval # Evaluate performance
/export # Package for deployment
The Complete Journey
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Development Phase โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Init โโ โ Generate โโ โ Validate โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Optimization Phase โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Data โโ โ Optimize โโ โ Deploy โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Result: Production-ready DSPy applications with optimized performance
๐ฏ Key Features
๐๏ธ Development Features
- ๐ฃ๏ธ Natural Language Interface - Describe your DSPy task in plain English
- ๐ง Version-Aware Intelligence - Adapts to your installed DSPy version
- ๐ Codebase RAG - Understands your project with intelligent indexing
- โ Smart Validation - Ensures code follows DSPy best practices
- ๐ Code Generation - Generate signatures, modules, and complete programs
- ๐ Built-in MCP Client - Connect to any MCP server for external tools
- ๐ 20+ Templates - Pre-built patterns for RAG, QA, classification
๐งฌ Optimization Features
- ๐งฌ GEPA Optimization - Real Genetic Pareto integration
- ๐ Automated Metrics - Built-in evaluation (Accuracy, F1, ROUGE, BLEU)
- ๐ Prompt Evolution - Automatically improve instructions and examples
- ๐ Performance Tracking - Monitor optimization progress in real-time
- ๐พ Session Management - Save and resume optimization workflows
- ๐ฏ Production Ready - Export optimized code for deployment
- ๐ฆ Export/Import - Package and share optimized DSPy projects
๐ Quick Start
Installation
โ ๏ธ CRITICAL: Always create your virtual environment INSIDE your project directory!
โจ Always install the latest version for the best experience! โจ
๐ Step 1: Create a project directory
mkdir my-dspy-project
cd my-dspy-project
๐ Step 2: Create virtual environment IN this directory (not elsewhere!)
python -m venv .venv
โก Step 3: Activate it
# For bash/zsh:
source .venv/bin/activate
# For fish shell:
source .venv/bin/activate.fish
# On Windows:
.venv\Scripts\activate
๐ Step 4: Install latest dspy-code (always upgrade to get newest features!)
pip install --upgrade dspy-code
๐ฏ Step 5: Run dspy-code (everything stays in this directory!)
dspy-code
๐ก Pro Tip: Always use
pip install --upgrade dspy-codeto get the latest features, bug fixes, and improvements!
Why virtual environment IN your project directory?
- ๐ Security: All file scanning stays within your project directory
- ๐ฆ Isolation: Your project dependencies are self-contained
- ๐ Portability: Share your project by zipping the entire directory
- ๐ฏ Simplicity: Everything in one place - no scattered files
- ๐งน Clean: Delete the project folder to remove everything
Project Structure
When you follow this setup, your project will be fully self-contained:
my-dspy-project/ # Your CWD
โโโ .venv/ # Virtual environment (packages installed here)
โโโ .dspy_cache/ # DSPy's LLM response cache
โโโ .dspy_code/ # dspy-code's internal data
โ โโโ cache/ # RAG index cache
โ โโโ sessions/ # Session state
โ โโโ optimization/ # GEPA workflow data
โ โโโ history.txt # Command history
โโโ generated/ # Your generated code
โโโ modules/ # Your modules
โโโ signatures/ # Your signatures
โโโ dspy_config.yaml # Your config
Everything in one directory! Delete the folder, and it's all gone. Zip it, and share with others.
Never run dspy-code from:
- โ Your home directory (
~/) - โ Desktop, Documents, Downloads, or Pictures folders
- โ System directories
- โ With a virtual environment outside your project
Never do this:
# โ DON'T: Virtual env outside project
cd ~/
python -m venv my_global_venv
# โ DON'T: System-wide installation
pip install dspy-code
Your First Program (5 minutes)
# From your project directory with activated venv:
dspy-code
# Initialize your project (creates config and scans your environment)
/init
# Connect to a model (example with Ollama)
/connect ollama llama3.1:8b
# Generate your first program using natural language
Create a sentiment analyzer that takes text and outputs positive or negative
# Save the generated code
/save sentiment.py
# Validate and run
/validate
/run
That's it! You just created, validated, and ran your first DSPy program. ๐
๐ Available Commands
DSPy Code is interactive-only - all commands are slash commands. Here are the main categories:
๐ Getting Started
/init- Initialize or scan your DSPy project/intro- Show introduction and getting started guide/help- Show all available commands/exit- Exit the interactive session
๐ค Model Connection
/connect <provider> <model>- Connect to LLM (ollama, openai, anthropic, gemini)/disconnect- Disconnect current model/models- List available models/status- Show current connection status
๐ป Code Generation & Management
/demo- Generate demo DSPy code/save <filename>- Save generated code to file/validate- Validate DSPy code/run- Execute your DSPy program/test- Run tests on your code
๐งฌ Optimization
/optimize- Start optimization workflow/optimize-start- Begin GEPA optimization/optimize-status- Check optimization progress/optimize-cancel- Cancel running optimization/optimize-resume- Resume paused optimization/eval- Evaluate your DSPy program
๐ MCP Integration
/mcp-connect <server>- Connect to MCP server/mcp-disconnect <server>- Disconnect MCP server/mcp-servers- List configured MCP servers/mcp-tools- Show available MCP tools/mcp-call <tool> <args>- Call an MCP tool/mcp-resources- List MCP resources/mcp-read <resource>- Read MCP resource/mcp-prompts- List MCP prompts/mcp-prompt <name>- Get MCP prompt
๐พ Session Management
/sessions- List all saved sessions/session <name>- Load or switch session
๐ฆ Export & Import
/export <path>- Export project as package/import <path>- Import project package
๐ Reference & Examples
/reference <topic>- Get DSPy reference documentation/examples- Show example DSPy programs/predictors- Show available DSPy predictors/adapters- Show DSPy adapters/retrievers- Show DSPy retrievers/async- Show async patterns/streaming- Show streaming examples/data- Show data handling examples/explain <concept>- Explain DSPy concepts
๐ง Project Management
/project- Show project information/refresh-index- Rebuild codebase index/index-status- Show index status/save-data- Save training/evaluation data
๐๏ธ History & Context
/history- Show conversation history/clear- Clear current context
๐ก Primary Use Cases
1. ๐๏ธ Developing New DSPy Applications
Perfect for:
- Building new AI applications from scratch
- Prototyping ideas quickly
- Learning DSPy fundamentals
dspy-code
/init
/connect ollama llama3.1:8b
Create a RAG system for document Q&A
/save rag_system.py
/validate
โ
Complete project structure
โ
Code generation with natural language
โ
Validation & best practices
โ
Ready to code in minutes
2. ๐งฌ Optimizing Existing DSPy Programs with GEPA
Perfect for:
- Improving accuracy of existing programs
- Automatic prompt engineering
- Production optimization
dspy-code
/init
/data sentiment 20 # Generate training examples
/optimize my_program.py training_data.jsonl
/optimize-status
/eval
โ
Real GEPA execution (not just code generation)
โ
Automated metric functions
โ
Progress tracking & resumption
โ
Production-ready optimized code
โ
Performance improvements documented
Real results: 75% โ 92% accuracy automatically!
3. ๐ Learning DSPy (No Docs Required!)
Perfect for:
- First time using DSPy
- Understanding DSPy concepts
- Exploring different patterns
dspy-code
/intro
/examples
/explain ChainOfThought
/predictors
Just ask questions in natural language - the CLI answers using YOUR installed DSPy version!
4. ๐ Using MCP for External Tools
Perfect for:
- Connecting to external APIs and services
- Building powerful, connected AI applications
dspy-code
/mcp-connect filesystem
/mcp-tools
/mcp-call read_file {"path": "data.json"}
๐ Model Connection
Connect to any LLM provider:
# Ollama (local, free)
/connect ollama llama3.1:8b
# OpenAI
/connect openai gpt-4
# Anthropic
/connect anthropic claude-3-5-sonnet-20241022
# Google Gemini
/connect gemini gemini-2.0-flash-exp
๐งฌ GEPA Optimization
DSPy Code includes real GEPA (Genetic Pareto) optimization:
# Start optimization workflow
/optimize my_program.py training_data.jsonl
# Or use step-by-step optimization
/optimize-start my_program.py training_data.jsonl
/optimize-status
/optimize-resume
๐ Requirements
- Python: 3.10 or higher
- DSPy: 3.0.4 or higher (automatically installed)
- Dependencies: All dependencies are automatically installed
๐ ๏ธ Installation Options
From PyPI (Recommended)
โจ Always install the latest version! โจ
pip install --upgrade dspy-code
๐ก Why upgrade? We're actively developing and releasing new features, bug fixes, and improvements regularly. Always use
--upgradeto get the best experience!
From Source
git clone https://github.com/SuperagenticAI/dspy-code.git
cd dspy-code
pip install -e .
With uv (Faster)
# Always get the latest version
uv pip install --upgrade dspy-code
๐๏ธ Architecture
DSPy Code is built with a modular architecture:
- Commands - Interactive slash commands
- Models - LLM connection and code generation
- MCP - Model Context Protocol client
- Optimization - GEPA workflow management
- Validation - Code quality and best practices
- RAG - Codebase indexing and search
- Execution - Sandboxed code execution
- Session - State management
- Export - Project packaging
๐ Documentation
Full documentation available at: https://superagenticai.github.io/dspy-code/
Quick Links
- ๐ฆ Installation Guide
- โก Quick Start
- ๐ฌ Interactive Mode
- โจ๏ธ Slash Commands
- ๐ MCP Integration
- ๐ฏ Optimization Guide
๐ค Contributing
Contributions are welcome! We follow modern Python best practices:
- Code Quality: Ruff for linting and formatting
- Testing: pytest with coverage
- CI/CD: GitHub Actions
- Pre-commit: Automated quality checks
See CONTRIBUTING.md for detailed guidelines.
Quick Development Setup
git clone https://github.com/SuperagenticAI/dspy-code.git
cd dspy-code
# Using uv (recommended)
uv venv
source .venv/bin/activate # For fish: source .venv/bin/activate.fish
uv pip install -e ".[dev,test,docs]"
pre-commit install
# Or using pip
python -m venv .venv
source .venv/bin/activate # For fish: source .venv/bin/activate.fish
pip install -e ".[dev,test,docs]"
pre-commit install
# Run tests
pytest
# Run linting
ruff check .
# Format code
ruff format .
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
โ ๏ธ Development Status
DSPy Code is currently in Beta and under active development. While it's functional and ready for experimentation, it's not yet production-ready. We're actively adding features to make it production-worthy so you can use it in real projects to enhance your workflow.
We'd love your feedback! Try it out, share your experience, and help us shape the future of DSPy development:
- ๐ Report issues
- โญ Star the repo to show your support
๐ Acknowledgments
Built with โค๏ธ by Superagentic AI
Special thanks to the DSPy community and all contributors!
๐ Resources
๐ Documentation โข ๐ Issues โข ๐ค Contributing
โญ Show Your Support
If DSPy Code helps your workflow, give us a star! โญ
It helps others discover the project and motivates us to keep improving it.
Made with ๐ for the DSPy community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dspy_code-0.0.4.tar.gz.
File metadata
- Download URL: dspy_code-0.0.4.tar.gz
- Upload date:
- Size: 299.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
972907aa22d4bf0deb2a0fab178568839838e0f50f941c4cdc3281b2e0f42a45
|
|
| MD5 |
2d0fcedc11911c8d94f72db4681b74dc
|
|
| BLAKE2b-256 |
86f121183e4ced9b49ba3867cb40b92ce96c9b6ba7c70121ab23514fb54c2a4f
|
File details
Details for the file dspy_code-0.0.4-py3-none-any.whl.
File metadata
- Download URL: dspy_code-0.0.4-py3-none-any.whl
- Upload date:
- Size: 324.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22eac5f6e505da2b3ba632a291ca538a7fc956576437228cbad980c613750e82
|
|
| MD5 |
f63078d51cf897260c30d97b29fe44a6
|
|
| BLAKE2b-256 |
c2b1f611c94a8feedb2907c19b02e6cd3dc277e0914b73378d90e67165ab0605
|