Alert Immediately on Every Auto-Mode Permission Denial
A denial is often the single most interesting event in an unattended auto-mode run — it means the classifier thought something looked wrong. This makes sure it surfaces immediately rather than sitting unnoticed in a log until someone reviews the session later.
1. Save this as the hook script
#!/usr/bin/env python3
"""PermissionDenied hook — prints an immediate, visible alert on every
auto-mode denial. Observational only."""
import json, sys
data = json.load(sys.stdin)
print(f"ALERT: auto mode denied {data.get('tool_name')} — reason: "
f"{data.get('reason')}. Review this session.", file=sys.stderr)
sys.exit(0)
Save to a path inside your project, e.g. .claude/hooks/alert-on-auto-mode-denial.sh, then chmod +x it.
2. Wire it into .claude/settings.json
{
"hooks": {
"PermissionDenied": [
{
"hooks": [
{"type": "command", "command": "python3 .claude/hooks/alert-on-auto-mode-denial.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