WorktreeCreate hook causes --worktree flag to hang indefinitely

Resolved 💬 3 comments Opened Apr 2, 2026 by Eduaugust Closed Apr 2, 2026

Description

When a WorktreeCreate hook is configured in .claude/settings.local.json, running claude --worktree hangs indefinitely. The hook script is never executed — the hang occurs before the hook runs.

Removing the hook from settings makes --worktree work normally.

Steps to reproduce

  1. Add a WorktreeCreate hook to .claude/settings.local.json:
{
  "hooks": {
    "WorktreeCreate": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/any-script.sh",
            "timeout": 10,
            "statusMessage": "Setting up worktree..."
          }
        ]
      }
    ]
  }
}
  1. Run claude --worktree (or claude --enable-auto-mode --worktree)
  2. Observe: the CLI hangs with no output. The hook script is never invoked (verified with logging at the very first line of the script).
  3. Remove the WorktreeCreate hook → claude --worktree works normally.

Investigation done

  • Verified git worktree add itself works fine (~2 seconds).
  • Running claude without --worktree works fine (even with the hook configured).
  • Tried multiple approaches in the hook script: cat, read -t 2, timeout 5 cat, and even exec 0</dev/null to drain stdin — none helped. The script is never reached.
  • Creating the worktree manually and then running claude inside it works perfectly.
  • Tested with 3+ attempts, consistent behavior.

Expected behavior

claude --worktree should create the worktree and execute the WorktreeCreate hook, or at minimum not hang.

Environment

  • Claude Code v2.1.90
  • macOS (Darwin 25.3.0, arm64)
  • Shell: zsh

Workaround

Create the worktree manually:

git worktree add .claude/worktrees/<name> <branch>
cd .claude/worktrees/<name>
claude --enable-auto-mode

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗