Skip to main content

Git Gate

PreToolUse:BashgitEnabled by default

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.

SessionStart
PreToolUse
PostToolUse
Stop
Notification
Pre Tool Use

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.

~/.claude/settings.json
{
  "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

$ claude plugin marketplace add tonone-ai/tonone

2. Install this hook

$ claude plugin install git-gate@tonone-ai

Ready to use Git Gate?