Git Gate
Blocks `git commit` and `git push` on main, redirecting Claude to the session worktree first.
Why use this
Even with the worktree gate on edits, a determined (or confused) Claude can still reach for `git commit` directly on main. Git Gate is the hard stop — it blocks the commit at the tool-call level before any damage is done.
Lifecycle
Where in the Claude Code session this hook fires.
Fires before each tool call. Can block or modify the action.
Fires only when the tool matches: Bash
How it works
Intercepts any git commit or git push Bash command and blocks it when running outside a worktree. Provides an escape hatch: creating .claude/skip-worktree bypasses the gate for two hours for intentional main-branch operations such as docs or changelogs.
settings.json
What the hook configuration looks like in ~/.claude/settings.json after install.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/plugins/tonone-ai/tonone/tonone-git-gate.js"
}
]
}
]
}
}Install
This hook
Install Git Gate
1. Add to marketplace
2. Install this hook
Ready to use Git Gate?