Loading...
#!/bin/bash
tool=$(jq -r '.tool_name')
[ "$tool" = "Bash" ] && exit 2
exit 0#!/bin/bash
cmd=$(jq -r '.tool_input.command // empty')
if echo "$cmd" | grep -qE 'rm -rf|git push --force'; then
echo "Blocked: destructive command. Ask the user first." >&2
exit 2
fi
exit 0Checking the actual command blocks only dangerous calls and returns a reason, instead of blocking every shell command silently.
In many tools, yes: the hook can return modified input, such as a safer command or a corrected path, as well as allow or block the call.
No. Pattern matching can be bypassed with other spellings, so combine hooks with permission rules and a sandbox.
Usually JSON on standard input with the tool name and its input, such as the shell command or the file path to edit.