Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b86yyhhudsSLnwNUFY
24 lines
857 B
Bash
Executable File
24 lines
857 B
Bash
Executable File
#!/bin/bash
|
|
# PreToolUse hook for the Bash tool. Reads the hook JSON on stdin (needs jq).
|
|
# Denies a few commands by returning a permissionDecision, which Claude sees as the reason.
|
|
COMMAND=$(jq -r '.tool_input.command // empty')
|
|
|
|
deny() {
|
|
jq -n --arg reason "$1" '{
|
|
hookSpecificOutput: {
|
|
hookEventName: "PreToolUse",
|
|
permissionDecision: "deny",
|
|
permissionDecisionReason: $reason
|
|
}
|
|
}'
|
|
exit 0
|
|
}
|
|
|
|
case "$COMMAND" in
|
|
*"mvn deploy"*|*"mvn release:"*) deny "Publishing artifacts is a human decision. Run mvn verify instead." ;;
|
|
*"git push --force"*|*"git push -f"*) deny "Force-pushing is blocked in this project." ;;
|
|
*"rm -rf"*) deny "rm -rf is blocked. Delete specific files instead." ;;
|
|
*"| sh"*|*"| bash"*) deny "Piping downloaded text into a shell is blocked." ;;
|
|
esac
|
|
exit 0
|