# prompt-engineering-dspy

Learn to structure language-model tasks with DSPy, assemble RAG workflows, and tune modules from examples. Useful when a project needs more than a hand-written prompt.

- skill · `type=skill` · Claude Code · 147 installs
- Author: Orchestra Research
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/prompt-engineering-dspy
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/prompt-engineering-dspy

## What it does

This skill introduces DSPy as a way to define model tasks through their inputs and outputs. You can combine those task definitions into workflows for question answering, retrieval, and tool-using agents.

The examples cover `Predict`, `ChainOfThought`, and `ReAct`, along with optimizers that use training examples to adjust modules. RAG examples retrieve context before generating an answer. The listed dependencies are `dspy`, `openai`, and `anthropic`; model-based examples also configure a language model. Optimizers need training examples to work from.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill ai-research/prompt-engineering-dspy
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill prompt-engineering-dspy -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/prompt-engineering-dspy/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/prompt-engineering-dspy/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/prompt-engineering-dspy/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/prompt-engineering-dspy/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates prompt-engineering-dspy
```

2. **Manually: put the files in place**
- File: `.github/skills/prompt-engineering-dspy/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/ai-research/prompt-engineering-dspy
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/prompt-engineering-dspy/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/prompt-engineering-dspy

## When to use it
- Define inputs and outputs for a language-model task
- Build a retrieval-and-answer workflow
- Give a DSPy agent a search tool
- Tune a module using training examples

## Example prompts
- Design a DSPy workflow that retrieves context before answering a question.
- Show me how to use `ChainOfThought` for a word problem.
- Add a search tool to this DSPy agent and show how to pass it a query.

## Similar
- [skill-creator](https://affpapa.org/en/nevibecode/skills/skill-creator.md) — skill · 414180 installs
- [writing-for-agents](https://affpapa.org/en/nevibecode/skills/writing-for-agents.md) — skill · 466719 installs
- [media-use](https://affpapa.org/en/nevibecode/skills/media-use.md) — skill · 1100000 installs
- [mcp-builder](https://affpapa.org/en/nevibecode/skills/mcp-builder.md) — skill · 130949 installs
- [subagent-driven-development](https://affpapa.org/en/nevibecode/skills/subagent-driven-development.md) — skill · 237746 installs
- [orchestration](https://affpapa.org/en/nevibecode/skills/orchestration.md) — skill · 350300 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 495 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
