AI Skill MartBrowse skillsPromptsProgramsLearnWhat is a Skill?
← Back to list

Guardrail Hooks — rules held by code

Turn rules an agent keeps breaking into hooks, permission rules or tool-level refusals so code enforces them instead of prose.

Security & ReviewAdvanced★ 788⑂ 95AI score 9/10Last updated: Nov 21, 2026

What it does

  • Fires on cues like "it did it again", "make this impossible", "add a hook", "my hook didn't fire".
  • Gives a decision table for picking the smallest code path that holds a rule: permission rules (permissions.ask/deny), PreToolUse hooks, a refusal inside your own tool, git pre-commit hooks, and Stop / SessionStart / PostToolUse hooks.
  • Twelve field rules for guards that hold without becoming noise: strip heredocs before matching, open the scripts a command runs, pick ask vs deny vs exit 2 deliberately, never block the escape hatch, set onFailure: block, and start new blocking hooks in observe mode.
  • Ships three template scripts: guard_one_way_doors.py (gate irreversible or public actions), block_wrong_identity.py (forbid a commit author address), and test_hooks.py (payload-driven test runner).
  • Covers Windows pitfalls, Codex and Cursor differences, and a re-verification routine for dated vendor facts.

Who it's for

  • Claude Code, Codex or Cursor users who need hard limits on what an agent may run.
  • Anyone whose CLAUDE.md rules keep getting ignored at the decisive moment.
  • Teams that want a human click before destructive or public one-way-door actions.

Examples

  1. Require a human prompt before the agent runs gh repo delete or any publish command, even in auto mode.
  2. Block commits authored by a forbidden email across user.email, -c user.email= and --author, while still allowing git log --author= searches.
  3. Add a Stop hook returning decision: "block" so the agent cannot claim it is done before tests have run.

· · · Install guide · · ·

Try it now, no install

Paste this into Claude to use the skill without installing anything.

Read the instructions in this file and follow them to help me:
https://raw.githubusercontent.com/phuryn/product-engineering/HEAD/agent-harness/skills/guardrail-hooks/SKILL.md

What I want: (describe your task here)

If Claude can't open the link, open it yourself and paste the contents instead.

↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.

Install in the Claude app (no terminal)
  1. Download the ZIP with the button below.
  2. In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
  3. Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
↓ Download ZIP
Install in Claude Code

Let Claude do it — paste this into Claude Code

Install the skill I found on AI Skill Mart.
Copy the agent-harness/skills/guardrail-hooks folder from the GitHub repo phuryn/product-engineering into my ~/.claude/skills/guardrail-hooks/.
When it's done, tell me in one line what this skill can do.

Install with a command instead

git clone https://github.com/phuryn/product-engineering.git && mkdir -p ~/.claude/skills && cp -r product-engineering/agent-harness/skills/guardrail-hooks ~/.claude/skills/

⚠ This is a third-party skill. Check the source repository before installing.

  1. Clone the repository: git clone https://github.com/phuryn/product-engineering.git
  2. Install the skill: mkdir -p ~/.claude/skills && cp -r product-engineering/agent-harness/skills/guardrail-hooks ~/.claude/skills/
  3. Copy the Python files from scripts/ into your hooks directory — .claude/hooks/ for a single project, or ~/.claude/hooks/ machine-wide.
  4. Edit the CONFIG block at the top of each script, replacing the example rules with your own commands and addresses.
  5. Run the tests until they pass: python .claude/hooks/test_hooks.py (use python3 if needed).
  6. Wire the hooks in settings.json under hooks.PreToolUse with matcher: "Bash", exec form (args), and "onFailure": "block".
  7. Verify with /hooks in Claude Code, then run the canaries: true guard-canary and true user.email=<a blocked address>. Never test a guard with a real destructive command.