/ 目录 / 演练场 / dspy-skills
● 社区 OmidZamani ⚡ 即开即用

dspy-skills

作者 OmidZamani · OmidZamani/dspy-skills

Claude skills pack for DSPy — program language models, optimize prompts, build RAG pipelines systematically.

dspy-skills teaches Claude the DSPy mental model: signatures, modules, predictors, teleprompters, and evaluation loops. Instead of hand-crafting prompts, you describe the task via signatures and let DSPy's optimizers do the work — and Claude writes the DSPy code idiomatically rather than resorting to raw prompt templates.

为什么要用

核心特性

实时演示

实际使用效果

dspy-skill.replay ▶ 就绪
0/0

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "dspy-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/OmidZamani/dspy-skills",
        "~/.claude/skills/dspy-skills"
      ],
      "_inferred": true
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "dspy-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/OmidZamani/dspy-skills",
        "~/.claude/skills/dspy-skills"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "dspy-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/OmidZamani/dspy-skills",
        "~/.claude/skills/dspy-skills"
      ],
      "_inferred": true
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "dspy-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/OmidZamani/dspy-skills",
        "~/.claude/skills/dspy-skills"
      ],
      "_inferred": true
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "dspy-skill",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/OmidZamani/dspy-skills",
        "~/.claude/skills/dspy-skills"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "dspy-skill": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/OmidZamani/dspy-skills",
          "~/.claude/skills/dspy-skills"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add dspy-skill -- git clone https://github.com/OmidZamani/dspy-skills ~/.claude/skills/dspy-skills

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: dspy-skills

How to build your first DSPy program and optimize it

👤 ML engineers and applied researchers ⏱ ~90 min advanced

何时使用: You have a task where prompt quality matters and want a systematic way to improve it.

前置条件
  • Python 3.10+ with dspy-ai installed — pip install dspy-ai
  • Skill cloned — git clone https://github.com/OmidZamani/dspy-skills ~/.claude/skills/dspy-skills
步骤
  1. Define the signature
    Task: classify support tickets into {billing, technical, account}. Give me a DSPy signature and a simple Predict module.✓ 已复制
    → Signature + module code
  2. Write an eval
    Add an evaluation set of 50 labeled examples and an accuracy metric.✓ 已复制
    → Eval harness with metric callable
  3. Optimize
    Run BootstrapFewShot to compile the module against the eval set.✓ 已复制
    → Compiled predictor + improved score

结果: A DSPy-optimized predictor that beats a hand-written prompt, with reproducible code.

注意事项
  • Eval too small — optimizer overfits — Minimum 100–200 examples; hold out a true test set
  • Metric doesn't capture what you care about — Spend on metric design before on model choice
搭配使用: filesystem

Build a RAG pipeline with DSPy

👤 Engineers building retrieval-augmented systems ⏱ ~120 min advanced

何时使用: You want modular, optimizable RAG rather than a hand-wired chain.

步骤
  1. Define the modules
    Create a DSPy RAG pipeline: RetrieveThenRead with ColBERTv2 or a local retriever.✓ 已复制
    → Modular pipeline with separate retrieval and generation
  2. Optimize end-to-end
    Write an eval on our QA set and run MIPRO to improve.✓ 已复制
    → Compiled pipeline with score delta

结果: A RAG pipeline you can improve by changing the eval, not by rewriting prompts.

注意事项
  • Retriever quality caps end-to-end quality — Evaluate retrieval separately (recall@k) before optimizing generation
搭配使用: local-rag

组合

与其他 MCP 搭配,撬动十倍杠杆

dspy-skill + local-rag

Plug a local retriever into DSPy's RAG modules

Swap the ColBERT retriever for a local-rag MCP as the retrieval source.✓ 已复制
dspy-skill + filesystem

Organize DSPy programs, evals, and artifacts in a repo

Lay out a DSPy project with programs/, evals/, and artifacts/ directories.✓ 已复制

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
signature-design task spec Start of any DSPy program 0
module-authoring signatures + flow After signatures 0
teleprompter-optimization module + eval After eval is ready LLM tokens during optimization
evaluation-harness task data Before optimizing 0

成本与限制

运行它的成本

API 配额
LLM tokens dominate during optimization runs
每次调用 Token 数
Can be high — optimizations may invoke the LLM hundreds of times
费用
depends on provider
提示
Use cheap models during teleprompter runs, upgrade only for final evaluation

安全

权限、密钥、影响范围

凭据存储: LLM provider keys in env vars
数据出站: LLM provider endpoints

故障排查

常见错误与修复

Teleprompter seems to make things worse

Check metric correctness; use a held-out set; widen the example pool.

Optimization eats your budget

Cap max_bootstrapped_demos and use cheaper models during search.

替代方案

dspy-skills 对比其他方案

替代方案何时用它替代权衡
prompt-architect-skillYou want prompt-level craft, not DSPy's programmatic approachHand-crafted vs optimized

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills