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
- Add a
WorktreeCreatehook to.claude/settings.local.json:
{
"hooks": {
"WorktreeCreate": [
{
"hooks": [
{
"type": "command",
"command": "/path/to/any-script.sh",
"timeout": 10,
"statusMessage": "Setting up worktree..."
}
]
}
]
}
}
- Run
claude --worktree(orclaude --enable-auto-mode --worktree) - Observe: the CLI hangs with no output. The hook script is never invoked (verified with logging at the very first line of the script).
- Remove the
WorktreeCreatehook →claude --worktreeworks normally.
Investigation done
- Verified
git worktree additself works fine (~2 seconds). - Running
claudewithout--worktreeworks fine (even with the hook configured). - Tried multiple approaches in the hook script:
cat,read -t 2,timeout 5 cat, and evenexec 0</dev/nullto drain stdin — none helped. The script is never reached. - Creating the worktree manually and then running
claudeinside 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-modeThis issue has 3 comments on GitHub. Read the full discussion on GitHub ↗