dspy-output-refinement-constraints
This skill should be used when the user asks to "refine DSPy outputs", "enforce constraints", "use dspy.Refine", "select best output", "use dspy.BestOfN", mentions "output validation", "constraint checking", "multi-attempt generation", "reward function", or needs to improve output quality through iterative refinement or best-of-N selection with custom constraints.
npx skills add majiayu000/claude-skill-registry --skill dspy-output-refinement-constraints --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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 i
- Goal
- When to Use
- Related Skills
- Inputs
- Outputs
- Workflow
- Phase 1: dspy.Refine for Iterative Improvement
- Phase 2: dspy.BestOfN for Selection
- Phase 3: Multi-Constraint Reward Functions
- Production Example
- Migration from Assert/Suggest
- Best Practices
- Limitations
- Official Documentation
What does the dspy-output-refinement-constraints skill do?
This skill should be used when the user asks to "refine DSPy outputs", "enforce constraints", "use dspy.Refine", "select best output", "use dspy.BestOfN", mentions "output validation", "constraint checking", "multi-attempt generation", "reward function", or needs to improve output quality through iterative refinement or best-of-N selection with custom constraints.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill dspy-output-refinement-constraints --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
