Require Parent Re-Confirmation Before a Subagent Touches a Prod Path
The production-guardrail hooks catch the write itself, but a delegated subagent's parent session may never actually read what the subagent did in detail. This forces a block at stop-time if the subagent's own summary mentions touching a production path, so the parent has to look before accepting the result.
1. Save this as the hook script
#!/usr/bin/env python3
"""SubagentStop hook — blocks stopping if the final message mentions a
production-config path. Forces the parent session to review."""
import json, re, sys
data = json.load(sys.stdin)
message = data.get("last_assistant_message", "")
if re.search(r"(?i)(settings_production\.py|/etc/nginx/|deploy_manifest)", message):
print("BLOCKED: this subagent's summary mentions touching a production-"
"config path — surface this explicitly to the parent session before stopping.", file=sys.stderr)
sys.exit(2)
sys.exit(0)
Save to a path inside your project, e.g. .claude/hooks/require-reconfirmation-subagent-prod-touch.sh, then chmod +x it.
2. Wire it into .claude/settings.json
{
"hooks": {
"SubagentStop": [
{
"hooks": [
{"type": "command", "command": "python3 .claude/hooks/require-reconfirmation-subagent-prod-touch.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