git-guardrails-claude-code

Installation
SKILL.md

Setup Git Guardrails

Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.

What Gets Blocked

  • git push, in every form
  • git reset --hard
  • git clean with -f or --force, in any flag cluster (-fd, -xfd)
  • git branch -D, and --delete with --force
  • git checkout . and git restore ., including checkout -- . and restore --staged --worktree .

The script splits the command into shell tokens and checks each git subcommand and its flags. It also checks commands after &&, ;, and |, inside $(...), and inside bash -c "...". A dangerous phrase inside a commit message or a heredoc body does not block. A command it cannot parse is blocked.

When blocked, Claude sees a message that the user has prevented the command.

Requirements: python3 on the machine. Known limit: it checks the command text, so a script file that runs git internally is not inspected.

Steps

Installs
10
GitHub Stars
2
First Seen
Oct 11, 2026