dspy-modules

Installation
SKILL.md

Build Composable AI Programs with dspy.Module

Guide the user through structuring DSPy programs as reusable, composable modules. A dspy.Module is the building block for all DSPy programs -- like PyTorch's nn.Module but for language model pipelines.

Step 1 — Gather context

Ask before writing any code:

  1. What kind of pipeline? (RAG, classify-then-route, iterative refinement, simple extraction?)
  2. How many sub-modules / steps? (Single-step can skip the Module wrapper; 2+ steps benefit from it)
  3. Will you optimize this with a DSPy optimizer? (If yes, sub-module layout as self. attributes is critical)
  4. Do you need async support? (Requires async def forward() and acall — impacts design from the start)

Then build or explain the pattern that fits.

What is dspy.Module

dspy.Module is the building block for multi-step DSPy programs. Declare sub-modules in __init__ as self. attributes, wire them together with Python logic in forward(). DSPy optimizers automatically discover and tune all sub-modules in the tree.

Installs
7
GitHub Stars
11
First Seen
Mar 17, 2026
dspy-modules — lebsral/dspy-programming-not-prompting-lms-skills