Guardrails
Guardrails are workspace rules that intercept Claude Code tool calls before they run. Each enabled guardrail is enforced in every member's session — when a tool call matches, the guardrail can block it, prompt the member for approval, or note a warning and let it proceed.
Guardrails are admin-defined and enforced for the whole team. They apply automatically in every member's Claude Code session — members don't opt in or configure them.
How Guardrails Work
When Claude Code is about to run a tool (such as editing a file or running a shell command), each enabled guardrail checks whether the call matches its match configuration. If it does, the guardrail's action decides what happens next, and the guardrail's message is surfaced to the member.
- Guardrails are evaluated before the tool call executes.
- They run in every member's session, with no per-member setup.
- A guardrail only takes effect while it is enabled.
The Three Actions
Every guardrail has exactly one action that determines what happens when a tool call matches:
| Action | What happens |
|---|---|
| Deny | Blocks the tool call outright. The call never runs. |
| Ask | Prompts the member for approval before the call runs. The member can allow or decline. |
| Warn | Notes the concern with the guardrail's message but lets the call proceed. |
Match Configuration
A guardrail's match defines which tool calls it applies to. Every guardrail must target at least one tool; the optional pattern matchers narrow it further.
Tools
Choose which Claude Code tools the guardrail applies to. Select one or more specific tools, or All tools (*) to match every tool call.
- Edit, Write, MultiEdit — file changes
- Bash — shell commands
- WebFetch — fetching remote content
- All tools (*) — match every tool call
Path globs
Optional glob patterns matched against the file path of an edit (for Edit, Write, and MultiEdit). Use them to scope a guardrail to sensitive areas of the codebase.
**/auth/**
**/payments/**
**/migrations/**
Command patterns
Optional regular expressions matched against the command of a Bash tool call. Use them to catch destructive or risky commands.
\brm\s+-rf\b
git\s+push\s+.*--force
Content patterns
Optional regular expressions matched against the content being written (for Write and Edit). Use them to catch secrets, keys, or other content that shouldn't land in the codebase.
AKIA[0-9A-Z]{16}
(sk|pk)_(live|test)_[A-Za-z0-9]{8,}
The create/edit form reveals path globs and content patterns for file tools (Edit/Write/MultiEdit), and command patterns for Bash. A Bash-only rule won't be cluttered with path or content fields. You can add up to 20 patterns per list.
Presets
When you add a guardrail, you can start from a curated preset that prefills the form with a known-good rule, or configure a custom guardrail from scratch. A preset is just a starting point — you can adjust any field before saving.
| Preset | Action | What it does |
|---|---|---|
| Protect secrets | Warn | Warns when a write looks like it contains an API key or secret. |
| Dangerous shell commands | Deny | Blocks destructive shell commands like rm -rf and force pushes. |
| Protect auth & payments | Ask | Requires approval before editing auth or payments code. |
| Protect migrations | Deny | Blocks direct edits to database migration files. |
Creating a Guardrail
- Open Guardrails in your workspace
- Click Add guardrail
- Choose a preset, or pick Custom guardrail
- Fill in the details:
- Name — a short, kebab-case identifier (lowercase letters, numbers, and hyphens, e.g.
protect-secrets) - Action — Deny, Ask, or Warn
- Description — what the guardrail does (shown in the list)
- Tools — which tool calls it applies to (select at least one)
- Path globs / Command patterns / Content patterns — optional matchers for the selected tools
- Message — the text surfaced to the member when the rule fires
- Name — a short, kebab-case identifier (lowercase letters, numbers, and hyphens, e.g.
- Toggle Enabled and Experimental as needed
- Click Create guardrail
Enabled & Experimental
Each guardrail has two toggles that control when it is enforced:
- Enabled — when on, the guardrail is eligible for enforcement in every member's session. Disabled guardrails stay in the list but have no effect.
- Experimental — when on, the guardrail's live draft is enforced only for members running in Experimental mode. Use this to trial a draft rule before promoting it for everyone.
Enforcement also follows the guardrail's released version: a normal session enforces the stable release, while an Experimental session enforces the live draft (when the rule is flagged experimental). A guardrail with no stable release yet is not enforced. See Experimental Mode for how the per-member toggle works.
Favorites
Mark frequently referenced guardrails as favorites with the star icon. Favorites are personal to your account — other members won't see yours, and you won't see theirs.
Managing Guardrails
Guardrails are managed by workspace owners, admins, and maintainers. Members can view the list but cannot create, edit, enable/disable, or delete guardrails.
- Search and filter — find guardrails by name, or filter by enabled/disabled status.
- Enable / Disable — toggle enforcement without deleting the rule.
- Mark / Unmark experimental — switch a rule between everyone and Experimental-mode-only.
- Edit — change any field. Edits live in the draft until you publish and promote a release (see below).
- Versions — open the version history to publish, promote, or restore releases.
- Export as JSON / Share — download a guardrail, or create an unlisted link to share it.
- Delete — removes the rule. It stops being enforced in your team's sessions. This cannot be undone.
Versions & Releases
Guardrails are versioned just like skills, agents, commands, and workflows. Editing a guardrail changes its draft; publishing freezes that draft as an immutable release.
- Publish — freeze the current draft as a new version. Your first publish automatically becomes the stable release, so the guardrail starts enforcing.
- Promote — make any version the stable release. This is also how you roll back to an earlier version.
- Restore — copy an older version's content back into the draft so you can keep editing from it. History and the stable release are untouched until you publish again.
Because a normal session enforces the stable release, your edits don't affect the team until you publish and promote them. Flag a guardrail Experimental and test the draft in an Experimental session first, then promote it with confidence.
Sharing, Export & Import
Share a guardrail with another workspace, or move one between your own workspaces:
- Share links — create an unlisted, revocable link (from the guardrail's menu) once it has a stable release. Anyone with the link can preview the rule and import their own copy. Links can be pinned to a version or follow your latest stable release, with optional expiry and import limits.
- Export as JSON — download a guardrail as a portable JSON file (its name, description, match, action, and message).
- Import — upload a guardrail JSON, or open a share link. The imported guardrail is added as a draft (auto-renamed if the name is taken); publish and promote it to start enforcing.
Limits
The number of guardrails per workspace depends on your billing tier:
| Tier | Guardrails per workspace |
|---|---|
| Free | 1 |
| Paid | 50 |
Each guardrail also allows up to 20 patterns per matcher list (path globs, command patterns, content patterns). See Workspace Item Limits for all workspace limits.