Skip to content

v1.0.0

Choose a tag to compare

@karlkfi karlkfi released this 07 Jun 04:39

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 (tokenizecommand_segmentsparse_invocation) instead of substring matching, so a non-git segment can never ride along into an allow (git status && rm -rf foo is not auto-approved). Shell command/process substitution downgrades a would-be allow to defer.
  • Configurable push guard via BRANCH_GUARD_PUSH_POLICYstrict (default), protected, or off.
  • 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/bypassPermissions modes an ask becomes a deny, 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