What problem does it solve?
Install Claude Code PreToolUse hooks that block destructive git commands before they execute — force-push to protected branches, git reset --hard of unstaged work, git push --no-verify, and rm -rf paths that escape the worktree. Smart-merges into the project's .claude/settings.json and writes one guardian script. Trigger when the user says /git-guardrails, asks to harden Claude Code against destructive git commands, or is about to run /night unattended for the first time.
Core Features & Use Cases
- Guards against force-pushes to protected branches (configurable via the protected list, default main, master, prod).
- Prevents destructive commands such as git reset --hard when there is unstaged or uncommitted work.
- Blocks git push --no-verify and commit bypass to preserve hooks and policies.
- Writes a guardian script at .claude/scripts/git-guardrails.sh and merges a settings entry into .claude/settings.json to enforce safety.
- Integrates with Claude Code workflows to protect unattended runs and initial project setups.
Quick Start
Run the /git-guardrails activation to install the guardian script and merge the hook into your project settings.