Skip to content

DSPy Declarative LM Programming

Helps an agent build structured LLM pipelines, RAG systems and optimized prompts with the DSPy framework

Stars
14,195
Licence
MIT
Files
4 files

What it does

This skill teaches the agent how to use DSPy, a Python framework from Stanford NLP for programming language models declaratively. Instead of hand-writing prompts, the agent defines input/output signatures and modules (such as Predict, ChainOfThought and ReAct), then uses optimizers that tune prompts or few-shot examples from a labelled training set. It also covers building multi-step pipelines and retrieval-augmented (RAG) systems. The skill's files are reference documentation and code examples; they do not contain executable scripts of their own.

Great for

  • Python developers building multi-step LLM pipelines who want to replace hand-written prompts with structured code
  • Teams with a labelled dataset and a clear metric who want automatic prompt optimization
  • Engineers prototyping RAG or tool-using agents with DSPy

Skip it if

  • Simple one-off prompts or chat tasks, where DSPy adds setup overhead without benefit
  • Users without Python experience or without a language model API key, since the examples need both
  • Anyone expecting the skill to run safely on sensitive data without review: the examples call external model providers and the ProgramOfThought module generates and executes code, so outputs should be checked before use

Try asking

  • “Write a DSPy program that classifies support tickets into categories using a ChainOfThought signature”
  • “Build a multi-hop question answering pipeline with a retriever in DSPy”
  • “Optimize my existing DSPy prompt using BootstrapFewShot on this labelled dataset”
  • “Create a ReAct agent in DSPy that can call a search tool”
Step-by-step guide: how to use DSPy Declarative LM ProgrammingInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 4 original files, the MIT licence and an attribution note.

    dspy.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip dspy.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip dspy.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Start with dspy.Predict on a small example, then add an optimizer once you have a metric and training examples
  • Define a clear validation metric before running MIPRO or BootstrapFewShot, since optimization quality depends on it
  • Review any code generated by ProgramOfThought before running it, and keep API keys in environment variables

What's inside

  • references/examples.md
  • references/modules.md
  • references/optimizers.md
  • SKILL.md

Redistributed unmodified from Orchestra-Research/AI-Research-SKILLs under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.