OpenParable
Skip to content
← Back to skills

Guardrails AI

Agent Building
guardrails-ai

Guardrails AI is an Agent Skill for agent building published in the mkurman/zorai repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Guardrails AI — LLM output validation and guardrails. Define guardrails as XML/JSON specs, validate outputs against structural and semantic constraints, correct/retry on failure, and audit model behavior.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/mkurman/zorai/blob/HEAD/skills/scientific-skills/guardrails-ai/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/guardrails-ai, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Overview

Guardrails AI provides a guardrails framework for LLM applications with structured output validation, type safety, retry/reprompt logic, and risk management. Uses RAIL (Reliable AI Markup Language) specs or Pydantic models.

Installation

uv pip install guardrails-ai

Basic Guard

import guardrails as gd

rail_spec = (
    '<rail version="0.1">'
    '<output>'
    '  <string name="summary" description="Brief summary" format="length: 1-100"/>'
    '  <integer name="sentiment" format="valid-choices: {1, 0, -1}"/>'
    '</output>'
    '<prompt>'
    'Summarize this text: {{text}}'
    '</prompt>'
    '</rail>'
)

guard = gd.Guard.from_rail_string(rail_spec)
raw, validated = guard(text="I loved this movie!")
print(validated)  # {"summary": "...", "sentiment": 1}

Pydantic Guard

from pydantic import BaseModel
from guardrails import Guard

class Extraction(BaseModel):
    name: str
    age: int = 0

guard = Guard.from_pydantic(Extraction)
result = guard("John is 25 years old")

References