Güvenlik ve İzinler Orta
Tehlikeli Komutları Engelleme (Hook'lar)
rm -rf, DROP TABLE ve diğer yıkıcı komutları engellemek için PreToolUse hook'larını kullanın
Komut
"color:#9CA3AF;font-style:italic"># ."color:#7C5CFC">claude/settings.json $ { "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "./.">claude/hooks/block-rm.sh" }] }] } }
Yanıt
#!/bin/bash # .claude/hooks/block-rm.sh COMMAND=$(cat | jq -r '.tool_input.command') if echo "$COMMAND" | grep -q 'rm -rf'; then echo "Blocked: rm -rf is not allowed" >&2 exit 2 # Exit code 2 = BLOCK fi exit 0 # Exit code 0 = allow
Ayrıştırma Kodu
059669">">// Hook exit codes: 059669">">// 0 = allow the tool call 059669">">// 2 = BLOCK the tool call (stderr message fed back to Claude) // other = non-blocking error, tool still runs
Tuzaklar
! Çıkış kodu 2 araç çağrısını engeller; çıkış kodu 0 izin verir
! stderr mesajı, komutun neden engellendiğine dair bağlam olarak Claude'a geri beslenir