Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
97
96%
Does it follow best practices?
Impact
100%
1.19xAverage score across 3 eval scenarios
—
The risk profile of this skill
The canonical home for this skill is git-guardrails-claude-code in mattpocock/skills
Global-scoped setup with settings merge
Script in global hooks dir
100%
100%
Global settings file used
100%
100%
Tilde path in command
100%
100%
PreToolUse array merged
100%
100%
Existing memory setting preserved
100%
100%
Existing formatter hook preserved
100%
100%
Bash matcher used
100%
100%
Command type field
100%
100%
Script executable
100%
100%
Merged contents logged
100%
100%
Project-scoped hook setup and verification
Script in hooks dir
0%
100%
Script executable
100%
100%
PreToolUse hook key
100%
100%
Bash matcher
100%
100%
Command type field
100%
100%
CLAUDE_PROJECT_DIR in path
0%
100%
Verification command shown
100%
100%
Exit code 2 observed
100%
100%
BLOCKED in stderr
100%
100%
Settings file path correct
100%
100%
Custom blocked patterns and script editing
git tag -d added
100%
100%
git stash drop added
100%
100%
git push removed
71%
100%
Script in hooks dir
25%
100%
Script executable
33%
100%
Settings file written
100%
100%
Blocked pattern test shown
100%
100%
Allowed pattern test shown
100%
100%
CLAUDE_PROJECT_DIR in command
0%
100%
Script contents logged
100%
100%
d6882ad
Table of Contents
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.