v1.0.0
First stable release of branch-guard — a Claude Code PreToolUse hook that cuts routine git/gh approval prompts while keeping a human in the loop for protected-branch and destructive operations.
Highlights
- git/gh command classifier — auto-approves read-only, staging, and branch/worktree-create commands; allows feature-branch commits & pushes; asks before protected-branch or destructive operations (
reset --hard,clean -f,branch -D, …); defers on anything it can't classify. - shlex-based lexing (
tokenize→command_segments→parse_invocation) instead of substring matching, so a non-git segment can never ride along into an allow (git status && rm -rf foois not auto-approved). Shell command/process substitution downgrades a would-be allow to defer. - Configurable push guard via
BRANCH_GUARD_PUSH_POLICY—strict(default),protected, oroff. - Edit/Write/MultiEdit/NotebookEdit guarding resolved against the file's own repository (
git -C <dir-of-file>), not the session cwd. - Non-interactive fail-safe — in
auto/dontAsk/bypassPermissionsmodes anaskbecomes adeny, since no human can answer. - Stdlib-only Python hook — no third-party dependencies; tested across Python 3.10–3.13 in CI.
See the README for the full behavior tables and activation steps.
Full Changelog: https://github.com/karlkfi/claude-branch-guard/commits/v1.0.0