
"branch-guard: Stop Claude Code From Committing to Main"
You gave Claude Code a task. It did the work, then committed directly to main . Now you have untested code on your production branch with no PR review. branch-guard prevents this by blocking git commit on protected branches. Install curl -fsSL https://raw.githubusercontent.com/Bande-a-Bonnot/Boucle-framework/main/tools/branch-guard/install.sh | bash What it does branch-guard is a Claude Code hook that runs before every bash command. When it sees git commit on a protected branch, it blocks the command and suggests creating a feature branch instead. Blocked: $ git commit -m "fix: update auth" (on main) → branch-guard: Direct commit to 'main' is not allowed. Suggestion: Create a feature branch first: git checkout -b feature/your-change Allowed: $ git commit -m "fix: update auth" (on feature/auth-fix) → ✓ proceeds normally $ git commit --amend (on main) → ✓ amending existing commits is allowed Default protected branches: main , master , production , release . Configure Create .branch-guard
Continue reading on Dev.to
Opens in a new tab



