dspy

Program language models declaratively with automated prompt optimization in DSPy.

Updated May 8, 2026
One-click install
npx skills add https://github.com/gztcode/my-skills --skill dspy-gztcode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/gztcode/my-skills/tree/main/dspy
Command: npx skills add https://github.com/gztcode/my-skills --skill dspy-gztcode

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires dspy, openai, anthropic, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill streamlines the development of AI systems by providing systematic approaches to programming and optimizing LMs declaratively.

Core Features & Use Cases

  • Declarative Programming: Program LMs without manual prompting.
  • Prompt Optimization: Automate prompt optimization using data-driven methods.
  • Modular AI: Build modular AI pipelines and systems that are maintainable and portable.
  • Use Case: Build a RAG system for information retrieval and answer generation, with automatic optimization for better model outputs.

Quick Start

Use the dspy skill to create a question answering module for the provided text, with the expected output being a summary of the text.

import dspy

lm = dspy.Claude(model="claude-sonnet-4-5-20250929")
dspy.settings.configure(lm=lm)

class QA(dspy.Signature):
    question = dspy.InputField()
    answer = dspy.OutputField(desc="summary of the provided text")

qa = dspy.Predict(QA)
response = qa(question="Summarize the text.")
print(response.answer)

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 LLM applications?

Automate prompt optimization by programming LLMs declaratively, which shifts focus from manual prompting to data-driven methods that systematically improve model performance.

What is declarative programming for modular AI systems?

Declarative programming for modular AI builds maintainable and portable pipelines by defining what the model should achieve rather than writing manual prompt instructions.

Can I use dspy with Anthropic Claude and OpenAI models?

Yes, the framework is compatible with Anthropic Claude, OpenAI, and local models, allowing you to configure your preferred LM for modular AI pipelines and agents.

How do I build a RAG system with automated prompt optimization?

Build a RAG system by defining declarative LM modules for information retrieval and answer generation, leveraging automated optimization to refine model outputs.

Does dspy work with local models for AI programming?

Yes, local models are supported alongside OpenAI and Anthropic Claude, enabling automated prompt optimization and modular AI programming across different environments.

Why shift from manual prompting to declarative LM programming?

Shifting to declarative LM programming eliminates manual prompt tuning by using data-driven optimization, resulting in more maintainable and systematically improved AI pipelines.