Dspy Output Refinement Constraints

Use for dspy.Refine, dspy.BestOfN, output constraints, validation, reward functions, and iterative output refinement.

125 stars 13 forksOther Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add OmidZamani/dspy-skills

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add OmidZamani/dspy-skills --skill dspy-output-refinement-constraints
Manual install
git clone --depth 1 https://github.com/OmidZamani/dspy-skills.git /tmp/dspy-skills
mkdir -p ~/.claude/skills
cp -r /tmp/dspy-skills/skills/dspy-output-refinement-constraints ~/.claude/skills/dspy-output-refinement-constraints

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# DSPy Output Refinement & Constraints

## Goal

Improve output quality using iterative refinement (dspy.Refine) and best-of-N selection (dspy.BestOfN) with custom constraint validation.

## When to Use

- Outputs need format validation (JSON, specific structure)
- Length constraints (max tokens, word count)
- Content requirements (must include X, avoid Y)
- Quality improvement through multiple attempts
- Replacing deprecated Assert/Suggest patterns

## Related Skills

- Design signatures: [dspy-signature-designer](../dspy-signature-designer/SKILL.md)
- Optimize programs: [dspy-miprov2-optimizer](../dspy-miprov2-optimizer/SKILL.md)
- Evaluate quality: [dspy-evaluation-suite](../dspy-evaluation-suite/SKILL.md)

## Inputs

| Input | Type | Description |
|-------|------|-------------|
| `module` | `dspy.Module` | Module to refine |
| `reward_fn` | `callable` | Constraint validation function |
| `N` | `int` | Number of attempts |
| `threshold` | `float` | Minimum reward to accept |

## Outputs

| Output | Type | Description |
|--------|------|-------------|
| `refined_output` | `dspy.Prediction` | Validated, refined result |

## Workflow

### Phase 1: dspy.Refine for Iterative Improvement

Refine iteratively improves outputs across multiple attempts:
Read the full skill on GitHub

Details

Skill name
dspy-output-refinement-constraints
Path
skills/dspy-output-refinement-constraints/SKILL.md
License
MIT
Repo updated
23 June 2026

FAQ

What does the Dspy Output Refinement Constraints skill do?

Use for dspy.Refine, dspy.BestOfN, output constraints, validation, reward functions, and iterative output refinement.

How do I install the Dspy Output Refinement Constraints skill?

Claude Code plugin: /plugin marketplace add OmidZamani/dspy-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Dspy Output Refinement Constraints popular?

It lives in OmidZamani/dspy-skills, which has 125 GitHub stars and 13 forks, and is included in 1 curated skill list.

Related skills

Browse the most popular Claude skills, all other skills, or write your own with the skills generator.