Claude Code for DSPy: AI-powered interactive development environment for DSPy
Project description
๐ Your AI-Powered DSPy Development Assistant
Build, Optimize, and Deploy DSPy Applications with Natural Language. Think of it as Claude Code for DSPy
๐ Documentation โข ๐ Quick Start โข ๐ก Examples โข ๐ค Contributing
โก Claude Code for DSPy
pip install dspy-code
dspy-code
Ask in natural language โ Get working DSPy code โ Optimize with GEPA โ Deploy
๐ก 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 First Purpose-Built CLI for DSPy Development
DSPy Code is an interactive development environment that transforms how you learn and build with DSPy. Built as an intelligent CLI tool, it provides natural language interactions, code generation, optimization workflows, and comprehensive validation, all designed specifically for DSPy development.
๐ก Learn as you build. doesn't matter, you're a complete beginner or a DSPy expert, the CLI adapts to your level and guides you through every step.
๐ฏ Perfect For:
| ๐ Learning DSPy | ๐ Building Projects | โก Optimizing Code |
|---|---|---|
| Interactive Q&A about DSPy concepts | Generate complete DSPy applications | Real GEPA optimization workflows |
| Built-in examples and templates | Natural language to code | Automated metric evaluation |
| Step-by-step guidance | Code validation & best practices | Progress tracking & resumption |
๐ฏ 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.
๐ฏ Key Features
- ๐ฃ๏ธ Natural Language Interface - Describe your DSPy task in plain English
- ๐ Built-in MCP Client - Connect to any MCP server for external tools and services
- ๐ง Version-Aware Intelligence - Adapts to your installed DSPy version
- ๐งฌ GEPA Optimization - Real Genetic Prompt Evolution Algorithm integration
- ๐ Codebase RAG - Understands your project with intelligent indexing
- โ Smart Validation - Ensures code follows DSPy best practices
- ๐ Code Generation - Generate signatures, modules, and complete programs
- ๐พ Session Management - Save and resume your work across sessions
- ๐ฆ Export/Import - Package and share your DSPy projects
๐ Quick Start
Installation
โ ๏ธ CRITICAL: Always create your virtual environment INSIDE your project directory!
# 1. Create a project directory
mkdir my-dspy-project
cd my-dspy-project
# 2. Create virtual environment IN this directory (not elsewhere!)
python -m venv .venv
# 3. Activate it
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# 4. Install dspy-code (installs into .venv/ in your project)
pip install dspy-code
# 5. Run dspy-code (everything stays in this directory!)
dspy-code
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
๐ก Use Cases
๐ Starting a New DSPy Project
dspy-code
/init
/connect ollama llama3.1:8b
Create a RAG system for document Q&A
/save rag_system.py
๐ง Optimizing Existing Code
dspy-code
/init
/optimize-start my_module.py training_data.jsonl
/optimize-status
๐ Using MCP for External Tools
dspy-code
/mcp-connect filesystem
/mcp-tools
/mcp-call read_file {"path": "data.json"}
๐ Learning DSPy
dspy-code
/intro
/examples
/explain ChainOfThought
/predictors
๐ 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 Genetic Prompt Evolution Algorithm 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)
pip install dspy-code
From Source
git clone https://github.com/SuperagenticAI/dspy-code.git
cd dspy-code
pip install -e .
With uv (Faster)
uv pip install 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
uv pip install -e ".[dev,test,docs]"
pre-commit install
# Or using pip
python -m venv .venv
source .venv/bin/activate
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.3.tar.gz.
File metadata
- Download URL: dspy_code-0.0.3.tar.gz
- Upload date:
- Size: 297.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
148cf993142961188253fd69c56a46480f6e9a54282328da01214a8607100dd3
|
|
| MD5 |
5ff11cbaac3427ef46f9843c4af37ea1
|
|
| BLAKE2b-256 |
6a018d07d81be0df9b98f61fe5278bb6104126b16721764ab7b700f17fe372fa
|
File details
Details for the file dspy_code-0.0.3-py3-none-any.whl.
File metadata
- Download URL: dspy_code-0.0.3-py3-none-any.whl
- Upload date:
- Size: 322.4 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 |
a5d62894da0ca96bd69fcb42b1e350ab40ae4b99a1bed453017725149b27216f
|
|
| MD5 |
a43f62c986a8309c526fb908c232f6df
|
|
| BLAKE2b-256 |
45c87c36f365c7f7efa777e16526b3c99afb10ebffbc56f6d6f38cbf940feafa
|