ai-following-rules

Installation
SKILL.md

Make Your AI Follow the Rules

Guide the user through defining and enforcing rules their AI must follow. The key insight: don't ask the AI to follow rules — program constraints that enforce them automatically.

Step 1: Identify your rules

Ask the user:

  1. What rules does the AI break? (too long? wrong format? forbidden content? missing fields?)
  2. Which rules are hard requirements vs nice-to-haves? (Refine with threshold vs lower reward weight)
  3. What should happen when a rule is broken? (retry with feedback, pick best attempt, fail loudly)

Step 2: The two enforcement patterns

DSPy 3.x provides two constraint primitives — dspy.Refine and dspy.BestOfN:

dspy.Refine dspy.BestOfN
Behavior Iterative - retries with feedback until threshold met Parallel - runs N times, picks best score
Use for Strict rules where feedback helps the LM self-correct Rules where sampling variation is more useful than feedback
Related skills

More from lebsral/dspy-programming-not-prompting-lms-skills

Installs
19
GitHub Stars
5
First Seen
Feb 8, 2026