
git-hooks
Enforces safe git workflows (no commits to main, branch naming)
- version
- 1.2.2
Install
/plugin install git-hooks@claude-hooksRun it inside Claude Code after adding the marketplace with /plugin marketplace add steeef/claude-hooks.
Contents
Discovered from sourceAgents 1
git-hooks
Git safety hooks for Claude Code that enforce branch workflow, block dangerous commands, and suggest worktrees for feature work.
Hooks
PreToolUse: git_pre_hook.py
Unified entry point that runs all git safety checks:
- git_add_block - Blocks dangerous git add patterns (wildcards, -A, .)
- git_checkout_safety - Warns about checkout commands that could lose work
- git_no_verify_block - Blocks
--no-verify/-nongit commit/push - git_branch_workflow - Enforces Jira-prefixed branch naming and blocks commits on main/master
- git_commit_message - Blocks commit messages with a subject over 50
characters, or that mention Claude/Claude Code/AI (checks
-m/--messagetext and-m "$(cat <<'EOF' ...)"heredoc bodies; can't see messages from-F/editor-based commits) - worktree_suggestion - Suggests using git worktrees for feature branches
PostToolUse: cleanup_hook.py
Detects PR merges and provides worktree cleanup instructions.
Configuration
Protected Branch Allowlist
By default, commits on main/master are blocked. To allow direct commits in
specific repos (e.g., documentation-only repos), add them to
~/.config/claude-hooks/config.json:
{
"protected_branch_allowlist": [
"~/code/work/thoughts"
]
}
Paths support ~ expansion. Matched against the repo root
(git rev-parse --show-toplevel). Allowlisted repos get an approval prompt
instead of a hard block.
Hooks 2
Sponsors
Details
- Marketplace
- steeef/claude-hooks
- Source
- plugins/git-hooks
- Category
- Development