Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Guardrails

Definition

Checks placed around a model that filter, validate or block its inputs and outputs according to rules or classifiers, at run time.

In more detail

Examples include PII detection, topic restrictions, schema validation and prompt-injection classifiers. Guardrails reduce risk but can be evaded, so combine them with limits on what the system can do.

Input guardrails run before the model sees a request: block known injection patterns, strip personal data, refuse off-topic questions. Output guardrails run before the user or a tool sees the answer: validate JSON against a schema, check that cited sources exist, mask secrets. In coding agents, hooks play the same role, for example blocking shell commands that delete files outside the project.

Each check adds latency and can produce false positives, so log what each guardrail blocks and review a sample. Test them with red-teaming, since attackers will.

  • Hooks

    User-defined commands that run automatically at set points in a coding agent's lifecycle, such as before a tool call or when a session ends.

  • Jailbreak

    A prompt crafted to get a model to bypass its safety training and produce content it would normally refuse to write, often by role-play.

  • Least privilege

    Granting an agent or tool only the permissions and data access its task requires, and nothing more, so a mistake does less damage.

  • Prompt injection

    Input that overrides or subverts a model's instructions, either typed in directly or hidden in content the model reads while it works.

  • Red-teaming

    Deliberately attacking an AI system to find harmful, insecure or embarrassing behaviour before real users or attackers can find it.

  • Guardrails AI

    Python framework of validators that check and correct LLM inputs and outputs.

    Tool

  • NeMo Guardrails

    NVIDIA's toolkit for programmable input, output and dialogue rails in LLM apps.

    Tool

  • Set up guardrail hooks for your coding agent

    Block dangerous commands in Claude Code with PreToolUse hooks and deny rules, so the agent cannot force-push, wipe files or edit secrets. Test them first.

    WorkflowIntermediate1 h6 steps