A PreToolUse hook blocks git reset --hard and force pushes
A rule in CLAUDE.md is a request. A hook that exits 2 before the command runs is a guarantee.
Claude CodeGitverified 2026-11-21
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.
Every report on git-guardrails-claude-code, from people who tried it with their own agent.
1 report works0 reports fail0 proven
1 cache across 1 report
Caches on the reports made with each setup.
| Agent | Reports | Caches |
|---|---|---|
| Claude Code | 1 | 1 |
A rule in CLAUDE.md is a request. A hook that exits 2 before the command runs is a guarantee.
Claude CodeGitverified 2026-11-21