dspy

Build declarative LM programs with automated prompt optimization.

2|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/Clay-HHK/claude-config --skill dspy-clay-hhk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/Clay-HHK/claude-config/tree/main/skills/AI-research-SKILLs/16-prompt-engineering/dspy
Command: npx skills add https://github.com/Clay-HHK/claude-config --skill dspy-clay-hhk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

DSPy eliminates ad-hoc prompt engineering and brittle orchestration when building multi-component language-model systems by providing a declarative programming model, automated prompt optimizers, and modular building blocks for reliable pipelines.

Core Features & Use Cases

  • Declarative LM Programming: Define structured Signatures and compose modules like Predict, ChainOfThought, ProgramOfThought, and ReAct to express tasks as input→output transforms.
  • Automatic Prompt Optimization: Improve prompts and few-shot examples automatically using teleprompters such as BootstrapFewShot, MIPRO, and BootstrapFinetune to boost accuracy.
  • Modular RAG & Agents: Build retrieval-augmented generation, reranking, multi-stage QA, and tool-using agents with reusable components and retrievers.
  • Use Case: Assemble an optimized multi-hop RAG pipeline that retrieves relevant passages, reranks candidates, and produces verified answers, then iteratively optimize the prompts using labeled examples.

Quick Start

Use DSPy to create a ChainOfThought module that answers factual questions and optimize it with BootstrapFewShot using your labeled question-answer examples.

Frequently Asked Questions about dspy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate prompt optimization for language model pipelines instead of manual tuning?

Automate prompt optimization by applying teleprompters like BootstrapFewShot, MIPRO, and BootstrapFinetune to iteratively improve prompt instructions and few-shot examples using labeled data, replacing ad-hoc manual tuning with data-driven accuracy boosts.

What is the best way to build modular RAG pipelines with multi-stage reasoning?

Build modular RAG pipelines by composing declarative modules like ChainOfThought and ReAct to express multi-stage reasoning tasks as structured input to output transforms, enabling reliable retrieval, reranking, and verified answer generation.

Does declarative LM programming work with both OpenAI and Anthropic models?

Declarative LM programming supports multiple model providers including OpenAI, Anthropic, and local models, allowing you to define signature-based interfaces and compose complex workflows across different platforms without changing your core pipeline logic.

How do I build tool-using agents that retrieve and rerank information?

Build tool-using agents by composing modular components like ReAct and retrievers within a declarative programming framework, enabling your agent workflows to retrieve relevant passages, rerank candidates, and execute multi-hop question answering reliably.

Why does my language model classifier output inconsistent results across different prompts?

Inconsistent classifier outputs often stem from brittle ad-hoc prompt engineering; defining structured Signatures and applying automated teleprompters like BootstrapFewShot standardizes the input to output transforms and optimizes few-shot examples for reliable accuracy.

Can I fine-tune language model prompts using my own labeled question-answer examples?

You can fine-tune and optimize prompts using your own labeled question-answer examples by applying the BootstrapFinetune teleprompter, which leverages your data to automatically improve and adapt few-shot demonstrations for better task performance.