Require a Reviewer-Note Env Var Before a Destructive Tool Call
A lightweight paper trail for the cases a full ticketing system is overkill for: a destructive command is blocked unless the person running it set `REVIEWER_NOTE` in the shell first, which at minimum forces a deliberate pause and leaves a one-line justification sitting in the terminal history.
1. Save this as the hook script
#!/usr/bin/env python3
"""PreToolUse hook — blocks a destructive-tool matcher unless
REVIEWER_NOTE is set. Wire this to whichever matcher you consider
destructive in your project."""
import json, os, sys
data = json.load(sys.stdin)
if not os.environ.get("REVIEWER_NOTE"):
print(f"BLOCKED: set REVIEWER_NOTE=\"<why>\" before running "
f"{data.get('tool_name')} on this matcher.", file=sys.stderr)
sys.exit(2)
sys.exit(0)
Save to a path inside your project, e.g. .claude/hooks/require-reviewer-note-destructive-call.sh, then chmod +x it.
2. Wire it into .claude/settings.json
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{"type": "command", "command": "python3 .claude/hooks/require-reviewer-note-destructive-call.py"}
]
}
]
}
}
Before you use this
A hook runs with your local shell's permissions — review the script above before adding it, the same way you'd review any script you didn't write yourself. See our guide on hook security risks for the specific CVEs this category of feature has already produced.
Related hooks