Set up Claude Code hooks to block dangerous git commands (force push, reset --hard, clean, force-delete branches, etc.) before they execute, while still allowing safe everyday operations like pushing branches from worktrees and cleaning up branches whose remote was deleted. Use when user wants to prevent destructive git operations, add git safety hooks, or block dangerous git in Claude Code.
Receba novas skills de Desenvolvimento toda segunda
1 email curto, só com as skills novas de Desenvolvimento. 4 minutos de leitura, sem spam, cancela com 1 clique.
Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.
Ler descrição completaRecolher descrição
Setup Git Guardrails
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them — without getting in the way of normal target-branch workflows.
Always blocked, everywhere:
git reset --hard
git clean -f / git clean -fd
git checkout . / git restore .
git push --force / git push -f
Context-aware:
git push — if at least one worktree exists, pushing from the main checkout is blocked (agents are kept in their worktre
[Description truncada. Veja o README completo no GitHub.]