Security & Permissions Advanced
AI-Powered Command Validation
Use a prompt-type hook to have a second AI model validate commands before execution
Command
"color:#9CA3AF;font-style:italic"># ."color:#7C5CFC">claude/settings.json $ { "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "prompt", "prompt": "Is this bash command safe? $ARGUMENTS\n\nDeny ">if it contains: rm -rf, DROP TABLE, or modifies system files.", "model": "">claude-3-5-haiku-20241022", "timeout": 30 }] }] } }
Response
// The prompt hook evaluates the command using a fast model // Returns exit 0 (allow) or exit 2 (block) based on AI judgment
Parsing Code
059669">">// Prompt hooks use $ARGUMENTS placeholder 059669">">for the tool input 059669">">// The model evaluates and decides: allow or block 059669">">// Works with any model — use Haiku 059669">">for speed, Opus for thoroughness
Gotchas
! Adds latency (AI evaluation before every Bash command) but catches nuanced risks
! Use a fast model (Haiku) to minimize delay — prompt hooks run synchronously