dspy
Build complex AI systems with declarative programming, optimize prompts automatically, create modular RAG systems and agents with DSPy - Stanford NLP's framework for systematic LM programming. Use when you need to build complex AI systems, program LMs declaratively, optimize prompts automatically, create modular AI pipelines, or build RAG systems and agents.
How do I install this agent skill?
npx skills add https://github.com/zpankz/mcp-skillset --skill dspyIs this agent skill safe to install?
- Gen Agent Trust Hubwarn
This skill provides documentation and implementation examples for the DSPy framework. The analysis identified potential risks including dynamic Python code execution through the ProgramOfThought module, exposure of local development environment paths in multiple utility scripts, and an indirect prompt injection surface due to the ingestion of external medical curriculum data without sanitization.
- Socketpass
No alerts
- Snykwarn
Risk: MEDIUM · No issues
What does this agent skill do?
DSPy: Declarative Language Model Programming
Stanford NLP's framework for programming—not prompting—language models.
Quick Start
import dspy
# 1. Configure
dspy.settings.configure(lm=dspy.OpenAI(model='gpt-4o-mini'))
# 2. Define Module
qa = dspy.ChainOfThought("question -> answer")
# 3. Run
response = qa(question="What is the capital of France?")
print(response.answer)
Learning Path (DAG)
The DSPy framework follows a natural progression from core concepts through optimization to advanced applications. Use this directed acyclic graph to understand dependencies and navigate the skill components.
Foundation Layer (Start Here)
-
- Prerequisites: None
- Next: Signatures, Modules, Datasets
-
- Prerequisites: LM Configuration
- Next: Modules, Optimization
-
- Prerequisites: Signatures
- Next: Optimization, Applications
-
- Prerequisites: None
- Next: Optimization
Optimization Layer
-
- Prerequisites: Modules, Datasets
- Techniques: LabeledFewShot, BootstrapFewShot, KNNFewShot
- Next: Applications
-
- Prerequisites: Modules, Datasets
- Techniques: COPRO, MIPROv2, GEPA
- Next: Applications
-
- Prerequisites: Modules, Datasets
- Techniques: BootstrapFinetune
- Next: Applications
-
- Prerequisites: Multiple trained modules
- Next: Applications
Application Layer
-
- Prerequisites: Modules, Optimization (recommended)
-
- Prerequisites: Modules, Datasets
-
- Prerequisites: Modules, Haystack knowledge
Advanced Features (Cross-Cutting)
-
- Prerequisites: Modules
-
- Prerequisites: Signatures
-
- Prerequisites: ChainOfThought module
Reference Documentation
- Modules Reference - Complete module catalog
- Optimizers Reference - All optimization techniques
- Examples Reference - Real-world implementations
Common Workflows
Workflow 1: Basic QA System
- Configure LM → Design Signature → Build Module
- Path:
configuring-language-models.md→designing-signatures.md→building-modules.md
Workflow 2: Optimized RAG System
- Configure LM → Build RAG Module → Optimize with Few-Shot → Evaluate
- Path:
configuring-language-models.md→building-rag-pipelines.md→few-shot-learning.md→evaluating-programs.md
Workflow 3: Production Agent
- Configure LM → Design Signature → Build ReAct Module → Add Assertions → Optimize Instructions → Evaluate
- Path:
configuring-language-models.md→designing-signatures.md→building-modules.md→assertions-validation.md→instruction-optimization.md→evaluating-programs.md
Installation
pip install dspy
# Or with specific providers
pip install dspy[anthropic] # Claude
pip install dspy[openai] # GPT
pip install dspy[all] # All providers
Additional Resources
- Official Docs: dspy.ai
- GitHub: github.com/stanfordnlp/dspy
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/zpankz/mcp-skillset/dspy">View dspy on skillZs</a>