ai-following-rules

Enforce hard and soft constraints on AI outputs using DSPy Assert and Suggest.

11|1|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/lebsral/DSPy-Programming-not-prompting-LMs-skills --skill ai-following-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-following-rules
Source: https://github.com/lebsral/DSPy-Programming-not-prompting-LMs-skills/tree/main/skills/ai-following-rules
Command: npx skills add https://github.com/lebsral/DSPy-Programming-not-prompting-LMs-skills --skill ai-following-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you ensure AI outputs follow defined rules and policies by programmatically enforcing constraints instead of relying on ad-hoc prompting.

Core Features & Use Cases

  • Hard rules with dspy.Assert to block violations (format, safety, policy) and retry until compliant.
  • Soft guidance with dspy.Suggest to steer outputs without blocking progress.
  • Modular composition: chaining multiple rules, content-policy checks, and custom error messages for deterministic results.

Quick Start

Configure a DSPy module that applies hard and soft rules to AI outputs to ensure compliance.

Frequently Asked Questions about ai-following-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce constraints on AI outputs instead of relying on prompting?

To enforce constraints on AI outputs, you can programmatically apply hard and soft rules to model generations. This approach uses dspy.Assert to block policy or format violations and dspy.Suggest to steer outputs without halting progress.

What is the difference between hard and soft constraints in DSPy?

Hard constraints in DSPy use dspy.Assert to block violations and retry until the output is compliant, ensuring strict policy adherence. Soft constraints use dspy.Suggest to gently steer model outputs without blocking the generation pipeline.

How do I chain multiple validation rules for AI content safety?

You can chain multiple validation rules for content safety by modularly composing hard and soft constraints. This allows you to sequence policy checks, apply custom error messages, and use backtracking across multiple steps for deterministic compliance.

Can I use dspy.Assert to retry AI outputs until format correctness is achieved?

Yes, you can use dspy.Assert to enforce hard rules that block format violations and automatically retry AI outputs. This ensures strict format correctness and policy compliance by programmatically validating model responses.

When should I use soft guidance instead of hard rules for AI validation?

You should use soft guidance via dspy.Suggest when you need to steer AI outputs toward desired constraints without blocking progress or triggering retries. Use hard rules with dspy.Assert only when strict policy compliance and format correctness are mandatory.

Does this constraint enforcement approach support backtracking and optional components?

Yes, this constraint enforcement approach supports backtracking and optional components as needed. It programmatically applies hard and soft constraints across multiple steps, allowing modular composition for complex content safety and policy validation workflows.