
Dspy Fundamentals
If you're building LLM pipelines and tired of prompt spaghetti, this skill teaches you DSPy 3.2.x the right way: typed Signatures for I/O contracts, dspy.Module subclasses for composition, and predictors like ChainOfThought and ReAct instead of raw prompt strings. It's opinionated about modern idioms (no more TypedPredictor, no legacy dspy.OpenAI calls) and includes a ten-point anti-pattern list that will save you from common mistakes. The canonical template and predictor cheatsheet are copy-paste ready. Use this when starting any DSPy project or refactoring prompt-heavy code into something you can actually serialize, version, and optimize programmatically.
- GitHub stars
- 250
- last updated
- May 25, 2026
Install
$ npx -y skills add intertwine/dspy-agent-skills --skill dspy-fundamentals --agent claude-codeInstalls into .claude/skills of the current project.
Files
DSPy Fundamentals (3.2.x)
DSPy is the "PyTorch for prompts" — you declare Signatures (typed I/O contracts), compose them into Modules, and let optimizers (not you) tune the instructions and few-shot examples. Never write raw prompts.
The one-paragraph model
Configure a single LM globally with dspy.configure(lm=...). Define a dspy.Signature subclass with dspy.InputField() / dspy.OutputField() (docstring becomes the instruction). Wrap it in a predictor — dspy.Predict (direct), dspy.ChainOfThought (adds reasoning), dspy.ReAct (tool-using agent), dspy.ProgramOfThought (code-executing), or dspy.RLM (long-context). Subclass dspy.Module to compose multi-step programs. For built-in providers, use dspy.LM("provider/model"); for a truly custom backend, subclass dspy.BaseLM. Optimize later with GEPA.
Canonical template
import dspy
dspy.configure(lm=dspy.LM("openai/gpt-4o"), track_usage=True)
class QuestionAnswer(dspy.Signature):
"""Answer questions with rigorous step-by-step reasoning."""
question: str = dspy.InputField()
answer: str = dspy.OutputField(desc="concise final answer")
Sponsors
Details
- Repository
- github.com/intertwine/dspy-agent-skills
- Categories
- Frontend Development, AI & Agent Building
- License
- MIT
- First seen
- Jun 11, 2026