#!/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