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 formgit reset --hardgit cleanwith-for--force, in any flag cluster (-fd,-xfd)git branch -D, and--deletewith--forcegit checkout .andgit restore ., includingcheckout -- .andrestore --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.