Skill Tracer
Skills › Skills For Real Engineers › git-guardrails-claude-code › block-dangerous-git.sh

block-dangerous-git.sh

25 lines · skills/misc/git-guardrails-claude-code/scripts/block-dangerous-git.sh at 4ae2317

1#!/bin/bash
2
3INPUT=$(cat)
4COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
5
6DANGEROUS_PATTERNS=(
7 "git push"
8 "git reset --hard"
9 "git clean -fd"
10 "git clean -f"
11 "git branch -D"
12 "git checkout \."
13 "git restore \."
14 "push --force"
15 "reset --hard"
18for pattern in "${DANGEROUS_PATTERNS[@]}"; do
19 if echo "$COMMAND" | grep -qE "$pattern"; then
20 echo "BLOCKED: '$COMMAND' matches dangerous pattern '$pattern'. The user has prevented you from doing this." >&2
21 exit 2
22 fi
23done
25exit 0