Guardrails

The skills’ instructions guide the agent; they don’t stop it. Guardrails do. There are three layers:

  1. Read-only reviewers. The PR, Security, and Privacy reviewers have only read and search tools.
  2. The guardrails hook. A PreToolUse hook checks every tool call before it runs, while the plugin is enabled.
  3. Your repository’s own policies. Branch protection, required reviewers, and least-privilege tokens: the only layer that holds when everything else fails.

This page is about the hook.

What the hook decides

For each tool call, the hook returns one of three outcomes:

flowchart TD
  Call[Agent wants to run a tool] --> Hook[guardrails hook]
  Hook --> CD{A deny rule in<br/>your config matches?}
  CD -->|yes| Deny([Blocked])
  CD -->|no| BD{A built-in<br/>deny rule matches?}
  BD -->|yes| Deny
  BD -->|no| BA{A built-in or config<br/>ask rule matches?}
  BA -->|yes| Ask([You confirm or cancel])
  BA -->|no| Run([Runs])

When several hooks are installed, VS Code applies the most restrictive answer: deny beats ask, and ask beats allow.

Built-in rules

Denied:

Asked about:

Add your own rules

Create .github/guardrails/guardrails.yaml in your repo. The hook also accepts guardrails.yml, config.yaml, or config.yml in the same folder.

extends: https://github.com/contoso/eng-standards.git#main:guardrails/guardrails.yaml
deny:
  - terraform destroy
  - '\bdrop table\b'
ask:
  - kubectl apply

What your rules can and can’t change

Limits to know

Check it yourself

From the plugin folder:

bash scripts/guardrails.test.sh
bash scripts/guardrails-config.test.sh

The first suite covers the built-in rules; the second covers repo config, extends, and the rule that config can’t loosen a built-in deny.