dspy-core
DSPy Core
Core guidance for working with the DSPy framework: signatures, modules, programs, compilation, and testing.
Environment Setup
This skill requires uv as the Python package manager. Always ensure a uv virtual environment is active before running any DSPy code.
# Create and activate a uv virtual environment
uv venv
source .venv/bin/activate
# Install dspy
uv pip install dspy
Rule: Never use raw
piporpython -m pip. Always useuv pipfor package installation anduv runfor script execution.
Quick Start
Creating a new signature
import dspy
class MySignature(dspy.Signature):
"""Input and output fields with descriptions."""
input_field = dspy.InputField(desc="Description of input")
output_field = dspy.OutputField(desc="Description of output")
Compiling a program
# Use the compile-dspy script for safe compilation
uv run scripts/compile-dspy.py --module my_module --teleprompter teleprompter_name
When to Use This Skill
Use this skill when:
- Creating or modifying DSPy signatures
- Building new DSPy programs or modules
- Running DSPy compilation
- Testing DSPy signatures and programs
- Learning DSPy fundamentals
Core Concepts
Signatures
DSPy signatures define the input/output contract for your programs. See signatures.md for:
- Signature design patterns
- InputField vs OutputField usage
- Type hints and validation
- Hint and description best practices
Programs & Modules
DSPy programs are composed of modules that process inputs. See programs.md for:
- Building DSPy programs
- Module composition
- Compilation workflows
- Chain-of-thought and other patterns
Scripts
- compile-dspy.py: Compile DSPy modules with proper caching
- test-signature.py: Validate signature structure and types
- clear-cache.py: Clear DSPy cache safely
Templates
The assets/templates/ directory provides boilerplate:
- signature-template.py: Starting point for new signatures
- program-template.py: Starting point for new programs
Critical Rules
- Always use
uv: Useuv venvfor environment creation,uv pipfor installs, anduv runfor script execution - Compilation is offline-only: Never compile at runtime in production
- Clear cache after changes: Run
clear-cache.pyafter modifying DSPy modules
Related Skills
- dspy-optimization: Optimization, metrics, evaluation, and teleprompters
- dspy-fleet-rlm: fleet-rlm-specific DSPy patterns, debugging, and integration
Progressive Disclosure
- SKILL.md (this file): Quick reference and navigation
- references/: Detailed technical docs loaded as needed
- scripts/: Executable tools (can be run without reading)
- assets/: Templates for new work
More from qredence/skills
agent-converter
Converts agent definitions between Markdown (with YAML frontmatter) and TOML formats. Use when transforming agent configurations for different agent systems — MD format for rich tool restrictions, TOML format for Codex-style agents with sandbox modes.
14dspy-gepa
>-
7dspy-fleet-rlm
fleet-rlm-specific DSPy patterns, debugging, and integration with the qredence/fleet-rlm-dspy codebase. Use when working on fleet-rlm DSPy modules, debugging fleet-rlm DSPy issues, or following fleet-rlm architecture conventions.
7babysit-pr
Babysits a GitHub pull request by continuously polling CI checks, review comments, and mergeability state until the PR is ready to merge or closed. Diagnoses failures, retries flaky failures up to 3 times, auto-fixes branch-related issues, and stops only when user help is required. Use when asked to monitor a PR, watch CI, handle review comments, or track failures on an open PR.
7dspy-optimization
DSPy optimization workflows — teleprompters, metrics, evaluation, and compilation strategies. Use when optimizing DSPy programs with BootstrapFewShot, MIPROv2, or custom metrics.
7fastapi-router-py
Creates FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.
7