Loading...
Loading...
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.
npx skill4agent add mattpocock/skills git-guardrails-claude-codegit push--forcegit reset --hardgit clean -fgit clean -fdgit branch -Dgit checkout .git restore ..claude/settings.json~/.claude/settings.json.claude/hooks/block-dangerous-git.sh~/.claude/hooks/block-dangerous-git.shchmod +x.claude/settings.json{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}~/.claude/settings.json{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}hooks.PreToolUseecho '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>