← Back to catalog
HookGit↓ 191

Validate Branch Name

Ensures new branches follow the Git Flow naming convention before checkout.

Installation
npx claude-code-templates@latest --hook git/validate-branch-name --yes

This hook fires on the PreToolUse event, before Claude Code runs a branch checkout through Bash. It reads the name of the branch about to be created.

If the name does not match patterns like feature/, release/v.. or hotfix/*, creation is refused, keeping the repository naming consistent.

When to use

  • When the team standardizes branch names and wants to avoid exceptions.
  • When CI automation depends on the branch prefix.

How to use

After installing, it validates each new branch automatically. Use the expected prefixes and the checkout goes through without friction.