Skip to main content

Worktree Close

StopworktreeEnabled by default

Prints a /ship prompt at turn end when the current worktree has unshipped changes, so nothing gets forgotten.

Why use this

Unreviewed worktree branches pile up silently. This hook makes every turn end an explicit checkpoint — either ship the work or toss it — so nothing rots on a forgotten branch.

Lifecycle

Where in the Claude Code session this hook fires.

SessionStart
PreToolUse
PostToolUse
Stop
Notification
Stop

Fires when Claude finishes its turn and hands back control.

How it works

At every Stop event, checks whether the current worktree has commits ahead of the default branch or uncommitted changes. If so, prints guidance to /ship or discard. Clean worktrees are left in place — pruning happens at SessionStart, not here, because Stop fires after every assistant turn. Silent-fails on any error.

settings.json

What the hook configuration looks like in ~/.claude/settings.json after install.

~/.claude/settings.json
{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node ~/.claude/plugins/tonone-ai/tonone/tonone-worktree-close.js"
          }
        ]
      }
    ]
  }
}

Install

This hook

Install Worktree Close

1. Add to marketplace

$ claude plugin marketplace add tonone-ai/tonone

2. Install this hook

$ claude plugin install worktree-close@tonone-ai

More worktree hooks

All hooks

Ready to use Worktree Close?