/ 目錄 / 演練場 / dspy-skills
● 社群 OmidZamani ⚡ 即開即用

dspy-skills

作者 OmidZamani · OmidZamani/dspy-skills

Claude 的 DSPy 技能包——系統化地編程語言模型、優化提示詞、建構 RAG 流水線。

dspy-skills 教導 Claude DSPy 的核心思維模型:簽名、模組、預測器、電子提示器與評估迴圈。不需要手工撰寫提示詞,只需透過簽名描述任務,讓 DSPy 的優化器完成工作——Claude 會以慣用的 DSPy 方式撰寫程式碼,而非退回到原始提示詞模板。

為什麼要用

核心特性

即時演示

實際使用效果

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

如何建構你的第一個 DSPy 程式並優化它

👤 機器學習工程師與應用研究人員 ⏱ ~90 min advanced

何時使用: 你有一個提示詞品質至關重要的任務,並希望以系統化的方式加以改善。

前置條件
  • Python 3.10+ 並已安裝 dspy-ai — pip install dspy-ai
  • 已複製技能包 — git clone https://github.com/OmidZamani/dspy-skills ~/.claude/skills/dspy-skills
步驟
  1. 定義簽名
    Task: classify support tickets into {billing, technical, account}. Give me a DSPy signature and a simple Predict module.✓ 已複製
    → 簽名與模組程式碼
  2. 撰寫評估集
    Add an evaluation set of 50 labeled examples and an accuracy metric.✓ 已複製
    → 含指標可呼叫物件的評估框架
  3. 優化
    Run BootstrapFewShot to compile the module against the eval set.✓ 已複製
    → 已編譯的預測器與提升後的分數

結果: 一個超越手工提示詞的 DSPy 優化預測器,並附有可重現的程式碼。

注意事項
  • 評估集太小——優化器過擬合 — 至少需要 100–200 個範例;保留一個真正的測試集
  • 指標無法衡量你真正在意的事 — 在選擇模型之前,先投入心力設計好指標
搭配使用: filesystem

使用 DSPy 建構 RAG 流水線

👤 建構檢索增強系統的工程師 ⏱ ~120 min advanced

何時使用: 你想要模組化、可優化的 RAG,而非手工串接的鏈式結構。

步驟
  1. 定義模組
    Create a DSPy RAG pipeline: RetrieveThenRead with ColBERTv2 or a local retriever.✓ 已複製
    → 具備獨立檢索與生成步驟的模組化流水線
  2. 端對端優化
    Write an eval on our QA set and run MIPRO to improve.✓ 已複製
    → 已編譯的流水線與分數差異

結果: 一個只需修改評估集即可改善的 RAG 流水線,無需重寫提示詞。

注意事項
  • 檢索器品質限制了端對端的整體品質 — 在優化生成步驟之前,先單獨評估檢索效果(recall@k)
搭配使用: local-rag

組合

與其他 MCP 搭配,撬動十倍槓桿

dspy-skill + local-rag

將本地檢索器接入 DSPy 的 RAG 模組

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

在程式碼倉庫中組織 DSPy 程式、評估集與產出物

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

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
signature-design task spec 任何 DSPy 程式的起始階段 0
module-authoring signatures + flow 完成簽名定義之後 0
teleprompter-optimization module + eval 評估集準備就緒之後 LLM tokens during optimization
evaluation-harness task data 開始優化之前 0

成本與限制

運行它的成本

API 配額
優化執行期間以 LLM token 消耗為主
每次呼叫 Token 數
可能很高——優化過程可能呼叫 LLM 數百次
費用
depends on provider
提示
電子提示器執行期間使用便宜的模型,僅在最終評估時才升級至更強的模型

安全

權限、密鑰、影響範圍

憑證儲存: LLM 提供商金鑰存放於環境變數中
資料出站: LLM provider endpoints

故障排查

常見錯誤與修復

Teleprompter seems to make things worse

檢查指標的正確性;使用保留的測試集;擴大範例資料池。

Optimization eats your budget

限制 max_bootstrapped_demos 的數量,並在搜尋期間使用較便宜的模型。

替代方案

dspy-skills 對比其他方案

替代方案何時用它替代權衡
prompt-architect-skill你想要手工打磨提示詞,而非採用 DSPy 的程式化方式手工撰寫 vs 自動優化

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills