Command Reference
Complete reference for all DSPy Code slash commands available in interactive mode.
Overview
All DSPy Code commands are slash commands executed in interactive mode. Simply type / followed by the command name.
Project Management
/init - Initialize Project
Initialize a new DSPy project or scan an existing one.
Usage:
Options: - --fresh - Create a complete project structure with all directories
Examples:
What it does: - Creates dspy_config.yaml configuration file - Indexes your codebase for RAG features - Sets up project structure (if --fresh) - Displays entertaining messages during indexing
Code Generation
/create - Generate DSPy Components
Generate DSPy Signatures, Modules, or complete programs.
Usage:
Types: - signature - Create a DSPy Signature - module - Create a DSPy Module - program - Create a complete DSPy program
Examples:
/create signature sentiment analysis with text input and sentiment output
/create module email classifier with subject and body inputs
/create program question answering system with RAG
Model Connection
/model - Interactive model selection
Interactively choose and connect to a model (local via Ollama or cloud).
Usage:
Use this if you're not sure which model to pick or don't want to type the full /connect command.
/connect - Connect to LLM
Connect to a language model for code generation and execution when you already know the model name.
Usage:
Providers: - ollama - Local models via Ollama - openai - OpenAI models (GPT-4, GPT-5 family) - anthropic - Claude models - gemini - Google Gemini models
Examples:
/connect ollama gpt-oss:120b
/connect openai gpt-5-nano
/connect anthropic claude-sonnet-4.5
/connect gemini gemini-2.5-flash
Note: You may need to install provider SDKs separately. DSPy Code will guide you if needed.
Code Operations
/save - Save Generated Code
Save the last generated code to a file.
Usage:
Examples:
Note: Code must be generated first using natural language or /create.
/validate - Validate Code
Validate DSPy code for best practices and correctness.
Usage:
Examples:
What it checks: - Syntax correctness - DSPy best practices - Signature definitions - Module structure - Import statements
/run - Execute Program
Run a DSPy program in a sandboxed environment.
Usage:
Options: - --input - Provide input values as key=value pairs - --test-file - Run with test dataset
Examples:
/run sentiment_analyzer.py
/run my_program.py --input text="This is great!"
/run classifier.py --test-file test_data.jsonl
Optimization
/optimize - Optimize with GEPA
Optimize a DSPy program using GEPA (Genetic Pareto).
Usage:
Examples:
Requirements: - A DSPy program file - Training data (JSONL format) with input/output examples - Connected LLM model
What it does: - Evolves prompts using GEPA - Improves reasoning steps - Tests on validation set - Reports performance improvements
Data Generation
/generate data - Create Training Data
Generate training examples for optimization.
Usage:
Examples:
Output: Creates a JSONL file with training examples.
MCP Integration
/mcp-add - Add MCP Server
Add an MCP server configuration.
Usage:
Transport Types: - stdio - Standard input/output - sse - Server-Sent Events - websocket - WebSocket connection
Examples:
/mcp-add filesystem --transport stdio --command npx --args -y "@modelcontextprotocol/server-filesystem" /path/to/directory
/mcp-add github --transport sse --url https://api.github.com/mcp
/mcp-connect - Connect to MCP Server
Connect to a configured MCP server.
Usage:
Examples:
/mcp-tools - List MCP Tools
List available tools from connected MCP servers.
Usage:
Examples:
/mcp-tools # List all tools from all servers
/mcp-tools filesystem # List tools from specific server
/mcp-resources - List MCP Resources
List available resources from connected MCP servers.
Usage:
/mcp-prompts - List MCP Prompts
List available prompts from connected MCP servers.
Usage:
RAG & Performance
/refresh-index - Rebuild Codebase Index
Rebuild the RAG codebase index for better code generation context.
Usage:
Options: - --force - Force rebuild even if cache is fresh
Examples:
What it does: - Re-indexes installed packages (dspy, gepa, mcp) - Updates project code index - Improves code generation quality
/index-status - Show RAG Index Status
Display current RAG index statistics and status.
Usage:
Shows: - Total indexed elements - Number of codebases - Cache size - Index age - Per-codebase statistics
/fast-mode - Toggle Fast Mode
Enable or disable fast mode for faster responses (disables RAG context building).
Usage:
Options: - on - Enable fast mode (faster responses, lower code quality) - off - Disable fast mode (slower responses, better code quality) - (no args) - Show current status
Examples:
/fast-mode on # Enable fast mode
/fast-mode off # Disable fast mode
/fast-mode # Show current status
Trade-offs: - â Faster responses (0.5-1s vs 2-5s) - â ī¸ Lower code generation quality (no real DSPy examples) - â Still uses templates and reference docs
/disable-rag - Disable RAG Completely
Disable RAG indexing for maximum speed.
Usage:
What it does: - Disables RAG index loading - Disables all RAG searches - Fastest mode (0.3-0.8s responses) - Code generation uses templates only
Note: Code generation quality will be significantly reduced. Use only if speed is critical.
/enable-rag - Re-enable RAG
Re-enable RAG indexing for better code quality.
Usage:
What it does: - Re-enables RAG indexing - Restores code generation quality - Slower responses (2-5s) but better code
Note: Run /init to build index if not already built.
Session Management
/status - Show Session Status
Display current session information.
Usage:
Shows: - Connected models - Active MCP servers - Last generated code - Project configuration
/history - View Command History
View your command history in the current session.
Usage:
/clear - Clear Screen
Clear the terminal screen.
Usage:
Help & Information
/help - Show Help
Display help information for all commands.
Usage:
Examples:
/intro - Introduction Guide
Show comprehensive introduction to DSPy Code.
Usage:
Includes: - What is DSPy Code - Key features - Getting started guide - Tips and best practices
/version - Show Version
Display DSPy Code and DSPy versions.
Usage:
Exit
/exit - Exit Interactive Mode
Exit the DSPy Code interactive session.
Usage:
Note: Your session state is automatically saved.
Natural Language
You can also use natural language instead of slash commands:
Examples:
Build a sentiment analyzer module
Create a signature for email classification
Generate 20 training examples for sentiment analysis
Optimize my_program.py with training_data.jsonl
DSPy Code will understand your intent and execute the appropriate action.
Command Aliases
Some commands have shorter aliases:
/hâ/help/qâ/exit/vâ/validate/sâ/save
Tips
- Tab Completion: Use tab to autocomplete command names
- Command History: Use up/down arrows to navigate history
- Natural Language: Describe what you want instead of remembering commands
- Help: Use
/helpanytime to see available commands - Status: Use
/statusto see what's currently loaded
For more details, see the User Guide