Skip to content
Back to search

dspy-skills-marketplace

MarketplaceWorks with Claude CodeGitHub

Collection of Claude Skills for DSPy framework - program language models, optimize prompts, and build RAG pipelines systematically

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/omidzamani--dspy-skills/badge.svg)](/listings/omidzamani--dspy-skills)

HTML

<a href="/listings/omidzamani--dspy-skills"><img src="/api/listings/omidzamani--dspy-skills/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

/plugin marketplace add OmidZamani/dspy-skills
/plugin install dspy-skills@dspy-skills-marketplace

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 19 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "dspy-skills-marketplace",
  3. "owner": {
  4. "name": "OmidZamani",
  5. "url": "https://github.com/OmidZamani"
  6. },
  7. "plugins": [
  8. {
  9. "name": "dspy-skills",
  10. "source": "./",
  11. "description": "Collection of 22 focused skills for building, optimizing, evaluating, and deploying DSPy applications.",
  12. "version": "2.0.0",
  13. "author": {
  14. "name": "OmidZamani",
  15. "url": "https://github.com/OmidZamani"
  16. }
  17. }
  18. ]
  19. }
README.md · README · 108 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # DSPy Skills Collection
  2. A Claude Code plugin containing 22 focused skills for programming, optimizing, evaluating, and deploying LLM applications with [DSPy](https://dspy.ai/).
  3. **Stable DSPy baseline:** `3.2.1`, released May 5, 2026. Install the stable series with:
  4. ```bash
  5. pip install -U "dspy>=3.2.1,<3.3"
  6. ```
  7. DSPy `3.3.0b1` is a prerelease published May 28, 2026. See [prerelease notes](docs/dspy-prerelease-3.3.md) before opting in.
  8. ## Skills Index
  9. ### Start Here
  10. | Skill | Use it for |
  11. |-------|------------|
  12. | [dspy-signature-designer](skills/dspy-signature-designer/SKILL.md) | Typed signatures and structured outputs |
  13. | [dspy-custom-module-design](skills/dspy-custom-module-design/SKILL.md) | Reusable `dspy.Module` architecture |
  14. | [dspy-evaluation-suite](skills/dspy-evaluation-suite/SKILL.md) | Metrics, baselines, and comparisons |
  15. | [dspy-optimizer-selection](skills/dspy-optimizer-selection/SKILL.md) | Choosing among DSPy's optimizer families |
  16. ### Retrieval and Data
  17. | Skill | Use it for |
  18. |-------|------------|
  19. | [dspy-rag-pipeline](skills/dspy-rag-pipeline/SKILL.md) | RAG and multi-hop retrieval pipelines |
  20. | [dspy-embedding-retrieval](skills/dspy-embedding-retrieval/SKILL.md) | `Embedder`, `Embeddings`, FAISS, and local corpora |
  21. | [dspy-haystack-integration](skills/dspy-haystack-integration/SKILL.md) | Optimizing Haystack-backed pipelines |
  22. ### Agents and Reasoning
  23. | Skill | Use it for |
  24. |-------|------------|
  25. | [dspy-react-agent-builder](skills/dspy-react-agent-builder/SKILL.md) | ReAct tool agents |
  26. | [dspy-mcp-tool-integration](skills/dspy-mcp-tool-integration/SKILL.md) | MCP tools in DSPy agents |
  27. | [dspy-reasoning-modules](skills/dspy-reasoning-modules/SKILL.md) | `RLM`, `ProgramOfThought`, `CodeAct`, and `Parallel` |
  28. | [dspy-advanced-module-composition](skills/dspy-advanced-module-composition/SKILL.md) | Ensembles and composed modules |
  29. ### Optimizers
  30. | Skill | Use it for |
  31. |-------|------------|
  32. | [dspy-bootstrap-fewshot](skills/dspy-bootstrap-fewshot/SKILL.md) | Fast demo bootstrapping |
  33. | [dspy-miprov2-optimizer](skills/dspy-miprov2-optimizer/SKILL.md) | Instruction and demo search |
  34. | [dspy-gepa-reflective](skills/dspy-gepa-reflective/SKILL.md) | Reflective instruction optimization |
  35. | [dspy-simba-optimizer](skills/dspy-simba-optimizer/SKILL.md) | Mini-batch introspective optimization |
  36. | [dspy-finetune-bootstrap](skills/dspy-finetune-bootstrap/SKILL.md) | Weight optimization and distillation |
  37. | [dspy-better-together](skills/dspy-better-together/SKILL.md) | Sequencing prompt and weight optimizers |
  38. | [dspy-optimize-anything](skills/dspy-optimize-anything/SKILL.md) | GEPA optimization for text artifacts outside DSPy |
  39. ### Production and Interfaces
  40. | Skill | Use it for |
  41. |-------|------------|
  42. | [dspy-output-refinement-constraints](skills/dspy-output-refinement-constraints/SKILL.md) | `Refine` and `BestOfN` constraints |
  43. | [dspy-adapters-multimodal](skills/dspy-adapters-multimodal/SKILL.md) | Adapters, native tools, image, audio, and file inputs |
  44. | [dspy-production-deployment](skills/dspy-production-deployment/SKILL.md) | Cache hardening, save/load, usage tracking, async, and streaming |
  45. | [dspy-debugging-observability](skills/dspy-debugging-observability/SKILL.md) | Inspection, callbacks, and MLflow tracing |
  46. ## Typical Workflow
  47. 1. Define typed inputs and outputs with [dspy-signature-designer](skills/dspy-signature-designer/SKILL.md).
  48. 2. Build a module, RAG pipeline, or agent.
  49. 3. Establish a baseline with [dspy-evaluation-suite](skills/dspy-evaluation-suite/SKILL.md).
  50. 4. Choose an optimizer with [dspy-optimizer-selection](skills/dspy-optimizer-selection/SKILL.md).
  51. 5. Harden the runtime with [dspy-production-deployment](skills/dspy-production-deployment/SKILL.md).
  52. ## Optional Dependencies
  53. ```bash
  54. # Bayesian search for MIPROv2
  55. pip install -U "dspy[optuna]>=3.2.1,<3.3"
  56. # MCP tool integration
  57. pip install -U "dspy[mcp]>=3.2.1,<3.3"
  58. # Large local embedding corpora
  59. pip install faiss-cpu
  60. # optimize_anything
  61. pip install -U "gepa>=0.1.1,<0.2"
  62. ```
  63. ## Install as a Claude Code Plugin
  64. ```text
  65. /plugin marketplace add OmidZamani/dspy-skills
  66. /plugin install dspy-skills@dspy-skills-marketplace
  67. ```
  68. ## Documentation
  69. - [DSPy framework guide](docs/dspy-framework.md)
  70. - [DSPy official documentation](https://dspy.ai/)
  71. - [DSPy releases](https://github.com/stanfordnlp/dspy/releases)
  72. ## Validate Changes
  73. ```bash
  74. python3 scripts/validate_repo.py
  75. python3 -m compileall -q examples skills/dspy-haystack-integration/examples
  76. ```
  77. ## License
  78. MIT License. See [LICENSE](LICENSE).
examples/code-snippets.py · Bundled script · 322 lines · 1 finding marked
  1. """Production-ready DSPy code examples.
  2. This module contains comprehensive examples for all DSPy skills.
  3. """
  4. import dspy
  5. from typing import Literal, Optional
  6. import logging
  7. logger = logging.getLogger(__name__)
  8. # =============================================================================
  9. # CONFIGURATION
  10. # =============================================================================
  11. def configure_dspy(model: str = "openai/gpt-4o-mini", retriever_url: Optional[str] = None):
  12. """Configure DSPy with LM and optional retriever."""
  13. lm = dspy.LM(model)
  14. if retriever_url:
  15. rm = dspy.ColBERTv2(url=retriever_url)
  16. dspy.configure(lm=lm, rm=rm)
  17. else:
  18. dspy.configure(lm=lm)
  19. return lm
  20. # =============================================================================
  21. # SIGNATURES
  22. # =============================================================================
  23. class QASignature(dspy.Signature):
  24. """Answer questions concisely."""
  25. question: str = dspy.InputField()
  26. answer: str = dspy.OutputField(desc="Brief, factual answer")
  27. class ClassificationSignature(dspy.Signature):
  28. """Classify text sentiment."""
  29. text: str = dspy.InputField()
  30. sentiment: Literal['positive', 'negative', 'neutral'] = dspy.OutputField()
  31. confidence: float = dspy.OutputField(desc="0.0 to 1.0")
  32. class RAGSignature(dspy.Signature):
  33. """Answer using retrieved context."""
  34. context: list[str] = dspy.InputField(desc="Retrieved passages")
  35. question: str = dspy.InputField()
  36. answer: str = dspy.OutputField(desc="Answer grounded in context")
  37. # =============================================================================
  38. # MODULES
  39. # =============================================================================
  40. class SimpleQA(dspy.Module):
  41. """Basic question answering."""
  42. def __init__(self):
  43. self.predict = dspy.Predict(QASignature)
  44. def forward(self, question: str):
  45. return self.predict(question=question)
  46. class ChainOfThoughtQA(dspy.Module):
  47. """QA with reasoning."""
  48. def __init__(self):
  49. self.cot = dspy.ChainOfThought("question -> answer")
  50. def forward(self, question: str):
  51. return self.cot(question=question)
  52. class RAGModule(dspy.Module):
  53. """Retrieval-Augmented Generation."""
  54. def __init__(self, num_passages: int = 3):
  55. super().__init__()
  56. self.retrieve = dspy.Retrieve(k=num_passages)
  57. self.generate = dspy.ChainOfThought(RAGSignature)
  58. def forward(self, question: str):
  59. try:
  60. context = self.retrieve(question).passages
  61. pred = self.generate(context=context, question=question)
  62. return dspy.Prediction(context=context, answer=pred.answer)
  63. except Exception as e:
  64. logger.error(f"RAG failed: {e}")
  65. return dspy.Prediction(context=[], answer="Error processing question")
  66. class ReActAgent(dspy.Module):
  67. """Agent with tool use."""
  68. def __init__(self, tools: list):
  69. self.react = dspy.ReAct("question -> answer", tools=tools)
  70. def forward(self, question: str):
  71. return self.react(question=question)
  72. # =============================================================================
  73. # TOOLS FOR AGENTS
  74. # =============================================================================
  75. def search_wikipedia(query: str) -> str:
  76. """Search Wikipedia for information."""
  77. try:
  78. results = dspy.ColBERTv2(
  79. url='http://20.102.90.50:2017/wiki17_abstracts'
    • Note: Talks to a raw IP address or throwaway host, where malware is often staged
    • Line 113 on GitHub
  80. )(query, k=1)
  81. return results[0]['text'] if results else "No results found"
  82. except Exception as e:
  83. return f"Search error: {e}"
  84. def calculate(expression: str) -> float:
  85. """Evaluate a mathematical expression."""
  86. try:
  87. with dspy.PythonInterpreter() as interpreter:
  88. return interpreter.execute(expression)
  89. except Exception as e:
  90. return f"Calculation error: {e}"
  91. # =============================================================================
  92. # METRICS
  93. # =============================================================================
  94. def exact_match_metric(example, pred, trace=None) -> bool:
  95. """Check for exact answer match."""
  96. if not hasattr(pred, 'answer') or not pred.answer:
  97. return False
  98. return example.answer.lower().strip() == pred.answer.lower().strip()
  99. def contains_answer_metric(example, pred, trace=None) -> float:
  100. """Check if prediction contains the answer."""
  101. if not hasattr(pred, 'answer') or not pred.answer:
  102. return 0.0
  103. return float(example.answer.lower() in pred.answer.lower())
  104. def gepa_feedback_metric(example, pred, trace=None, pred_name=None, pred_trace=None):
  105. """Metric with feedback for GEPA optimizer."""
  106. if not hasattr(pred, 'answer') or not pred.answer:
  107. return dspy.Prediction(score=0.0, feedback="No answer generated")
  108. correct = example.answer.lower() in pred.answer.lower()
  109. if correct:
  110. return dspy.Prediction(score=1.0, feedback="Correct answer provided")
  111. else:
  112. return dspy.Prediction(
  113. score=0.0,
  114. feedback=f"Expected '{example.answer}', got '{pred.answer}'"
  115. )
  116. # =============================================================================
  117. # OPTIMIZATION EXAMPLES
  118. # =============================================================================
  119. def optimize_with_bootstrap(program, trainset, metric=None):
  120. """Optimize using BootstrapFewShot."""
  121. from dspy.teleprompt import BootstrapFewShot
  122. metric = metric or contains_answer_metric
  123. optimizer = BootstrapFewShot(
  124. metric=metric,
  125. max_bootstrapped_demos=4,
  126. max_labeled_demos=4
  127. )
  128. return optimizer.compile(program, trainset=trainset)
  129. def optimize_with_miprov2(program, trainset, auto="medium"):
  130. """Optimize using MIPROv2."""
  131. optimizer = dspy.MIPROv2(
  132. metric=dspy.evaluate.answer_exact_match,
  133. auto=auto,
  134. num_threads=24
  135. )
  136. return optimizer.compile(program, trainset=trainset)
  137. def optimize_with_gepa(program, trainset):
  138. """Optimize using GEPA with reflection."""
  139. optimizer = dspy.GEPA(
  140. metric=gepa_feedback_metric,
  141. reflection_lm=dspy.LM("openai/gpt-4o"),
  142. auto="medium"
  143. )
  144. return optimizer.compile(program, trainset=trainset)
  145. def optimize_anything_single_task(seed_artifact, evaluator_fn, background_info=None):
  146. """Optimize any text artifact using GEPA's optimize_anything (single-task)."""
  147. import gepa.optimize_anything as oa
  148. from gepa.optimize_anything import EngineConfig, GEPAConfig
  149. result = oa.optimize_anything(
  150. seed_candidate=seed_artifact,
  151. evaluator=evaluator_fn,
  152. background=background_info,
  153. config=GEPAConfig(engine=EngineConfig(max_metric_calls=100)),
  154. )
  155. return result.best_candidate
  156. def optimize_anything_generalization(seed_artifact, evaluator_fn, trainset, valset, background_info=None):
  157. """Optimize a text artifact that generalizes to unseen examples."""
  158. import gepa.optimize_anything as oa
  159. from gepa.optimize_anything import EngineConfig, GEPAConfig
  160. result = oa.optimize_anything(
  161. seed_candidate=seed_artifact,
  162. evaluator=evaluator_fn,
  163. dataset=trainset,
  164. valset=valset,
  165. background=background_info,
  166. config=GEPAConfig(engine=EngineConfig(max_metric_calls=100)),
  167. )
  168. return result.best_candidate
  169. def optimize_anything_seedless(evaluator_fn, objective, background_info=None):
  170. """Optimize from scratch — describe what you need, no seed required."""
  171. import gepa.optimize_anything as oa
  172. from gepa.optimize_anything import EngineConfig, GEPAConfig
  173. result = oa.optimize_anything(
  174. evaluator=evaluator_fn,
  175. objective=objective,
  176. background=background_info,
  177. config=GEPAConfig(engine=EngineConfig(max_metric_calls=100)),
  178. )
  179. return result.best_candidate
  180. def finetune_program(program, trainset, output_dir="./finetuned"):
  181. """Fine-tune model weights."""
  182. optimizer = dspy.BootstrapFinetune(
  183. metric=exact_match_metric,
  184. train_kwargs={
  185. 'learning_rate': 5e-5,
  186. 'num_train_epochs': 3,
  187. 'output_dir': output_dir
  188. }
  189. )
  190. program.set_lm(dspy.settings.lm)
  191. return optimizer.compile(program, trainset=trainset)
  192. # =============================================================================
  193. # EVALUATION
  194. # =============================================================================
  195. def evaluate_program(program, devset, metric=None, num_threads=8):
  196. """Evaluate program on development set."""
  197. from dspy.evaluate import Evaluate
  198. metric = metric or contains_answer_metric
  199. evaluator = Evaluate(
  200. devset=devset,
  201. metric=metric,
  202. num_threads=num_threads,
  203. display_progress=True
  204. )
  205. return evaluator(program)
  206. def compare_programs(programs: dict, devset, metric=None):
  207. """Compare multiple program variants."""
  208. results = {}
  209. for name, program in programs.items():
  210. score = evaluate_program(program, devset, metric)
  211. results[name] = score
  212. logger.info(f"{name}: {score:.2%}")
  213. best = max(results, key=results.get)
  214. logger.info(f"Best: {best} ({results[best]:.2%})")
  215. return results
  216. # =============================================================================
  217. # EXAMPLE USAGE
  218. # =============================================================================
  219. if __name__ == "__main__":
  220. # Configure
  221. configure_dspy()
  222. # Simple QA
  223. qa = SimpleQA()
  224. result = qa(question="What is the capital of France?")
  225. print(f"Answer: {result.answer}")
  226. # Chain of Thought
  227. cot_qa = ChainOfThoughtQA()
  228. result = cot_qa(question="What is 15% of 80?")
  229. print(f"Reasoning: {result.reasoning}")
  230. print(f"Answer: {result.answer}")
  231. # Agent with tools
  232. agent = ReActAgent(tools=[search_wikipedia, calculate])
  233. result = agent(question="What is the population of Paris divided by 1000?")
  234. print(f"Agent answer: {result.answer}")

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.