WorktreeCreate hook causes indefinite hang regardless of hook command
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
- Add to
.claude/settings.local.json:
{
"hooks": {
"WorktreeCreate": [
{
"hooks": [
{
"type": "command",
"command": "echo ok < /dev/null"
}
]
}
]
}
}
- Run
claude -w - 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, andecho ok < /dev/null-- all hang - Removing the
WorktreeCreatehook 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
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗