Agent skill · magnus919

dspy

Expert skill for programming—not prompting—language models with Stanford's DSPy framework. Signatures, modules (Predict, ChainOfThought, ReAct), optimizer/teleprompter selection, compilation, caching, evaluation. Use when doing programmatic prompt optimization or building compiled prompt programs.

What it needs

About 4k tokens when loaded.

What this skill does

DSPy Expert Skill DSPy is a compiler for prompt programs, not a chain or RAG framework. You write Python programs with typed signatures and DSPy optimizes the prompts automatically. ⚠️ DSPy is NOT a chain framework. It does not use prompt model parser. It does not have LCEL. DSPy operates at a different layer: you define a program with Python control flow and typed signatures, then the compiler optimizes the prompts against a metric. If you reach for DSPy expecting LangChain-style composition, you are reaching for the wrong tool. Think of it as PyTorch for LMs — you define the architecture, the compiler tunes the weights (prompts). Core Paradigm Read this first. It is the most important thing to understand about DSPy. Core Principles 1. DSPy is a compiler, not a chain framework. You define the program structure with Python control flow and typed signatures. The compiler optimizes the prompts. This is fundamentally different from LangChain's explicit prompt composition. 2. Signatures define the task. Input/output field pairs with optional descriptions are the task definition. The syntax is input1, input2 -> output1, output2. 3. Modules are program components. dspy.Predict (direct), dspy.ChainOfThought (reasoning), dspy.ReAct (tool-use), and custom dspy.Module subclasses. Compose them with Python control flow (if/for/while). 4. Optimizers tune prompts, not weights. A dozen optimizers (teleprompters) tune instructions, few-shot demos, or both. Selection depends on bottleneck and budget. See the optimizer cheat sheet. 5. Compile once, serve many. Compilation is expensive ($3-$300+). The output is a portable artifact via program.save(path). Inference is cheap. 6. Cache aggressively. DSPy caches all LM calls by default. Set DSPYCACHEDIR for the current client. Disable with dspy.LM(..., cache=False). Where to Start You already have... …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills magnus919/dspy

View the source on GitHub

Browse the @skills marketplace