AI CompendiumA public chart of the language
Home / Safety & Alignment / Guardrails
Safety & Alignment

Guardrails

Constraints on what the system will do, enforced in code.

Definition

Policy enforcement around a model: input and output filters, allowed-tool lists, spend caps, scope limits, human approvals. Deterministic checks that do not rely on the model choosing well.

Guardrails are code, not prompts. A model can be argued out of an instruction; a spend cap and a tool allowlist cannot. Put the load-bearing safety in the layer that does not reason.

The principle is defence in depth, and specifically that model judgement should not be the only barrier. A filter, an allow-list, a spend cap and an approval rule are all deterministic — they hold even when the model has been persuaded, confused, or injected.

How people use it
Security sign-off.
"Refusals are in the prompt, but the deny-list is in the gateway. The prompt is a hint; the gateway is the control."
Worked example

The guardrail that is code

An agent must never send external email without approval.

Implement it as a permission rule on the tool, not as an instruction in the prompt. The prompt version holds until something in the context argues against it — and untrusted retrieved content can argue. The code version holds regardless.

Avoid

Relying on instructions alone as your only safety mechanism. Prompts are suggestions.

Sources
  • docsConfigure permissions ↗Claude Code docs · 2026

    Allow, ask and deny rules for edits, shell commands and other tools: what a permission mode looks like when it is written down.

  • docsSafety best practices ↗OpenAI API docs · 2026

    Application-level controls: adversarial testing, human review for high-stakes and code output, moderation, bounded inputs, and telling users what the model cannot do.

  • standardLLM01: Prompt injection ↗OWASP Gen AI Security Project · 2025

    Defines direct versus indirect injection and the downstream effects — data disclosure, unauthorised tool use, command execution — with least privilege and human approval as the recommended controls.

Related terms