Skip to content

WorktreeCreate hook causes indefinite hang regardless of hook command #41614

Description

@jackordman

Bug Description

claude -w hangs indefinitely when any WorktreeCreate hook is configured in project settings. The hook script itself completes successfully (confirmed via debug logging to a file), but Claude Code never proceeds after the hook returns.

Even a trivial hook like echo ok < /dev/null reproduces the hang. Removing the WorktreeCreate hook config resolves the hang immediately.

Reproduction Steps

  1. Add to .claude/settings.local.json:
{
  "hooks": {
    "WorktreeCreate": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "echo ok < /dev/null"
          }
        ]
      }
    ]
  }
}
  1. Run claude -w
  2. Claude Code hangs indefinitely

Expected Behavior

The hook should run and Claude Code should proceed with the worktree session.

Actual Behavior

Claude Code hangs indefinitely after the hook completes. The hook command itself finishes (verified by writing debug output to /tmp), but Claude Code never moves on.

Debugging Done

  • Confirmed the hook script runs to completion via file-based debug logging
  • Tested with the actual setup script, a minimal cat > /dev/null; echo ok, and echo ok < /dev/null -- all hang
  • Removing the WorktreeCreate hook config entirely resolves the hang
  • No other hook types (PreToolUse, PostToolUse, SessionStart) exhibit this behavior

Workaround

Use a SessionStart hook that detects if it's running inside a worktree:

"SessionStart": [
  {
    "hooks": [
      {
        "type": "command",
        "command": "/path/to/worktree-setup.sh < /dev/null"
      }
    ]
  }
]

Environment

  • Claude Code version: 2.1.87
  • OS: macOS (Darwin 25.3.0)
  • Shell: bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:hooksbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions