[BUG] Claude Desktop's worktree creation flow does not fire the WorktreeCreate hook
[BUG] Claude Desktop's worktree creation flow does not fire the WorktreeCreate hook
What's Wrong?
When Claude Desktop creates a git worktree (e.g. via the in-app "new worktree" / cowork flow), the WorktreeCreate hook configured in ~/.claude/settings.json is not invoked. The Desktop app instead creates the worktree directly under <repo>/.claude/worktrees/<name> and records it in ~/Library/Application Support/Claude/git-worktrees.json, bypassing the user's hook entirely.
The same hook fires correctly when invoking claude --worktree <name> from the CLI, so the hook itself and the settings file are wired up correctly — Desktop just doesn't call into the hook dispatch path for this event.
This makes the documented WorktreeCreate override mechanism (https://code.claude.com/docs/en/hooks) ineffective for Desktop users who want worktrees in a non-default location (e.g. a sibling directory <repo>-worktrees/<name> instead of <repo>/.claude/worktrees/<name>).
What Should Happen?
When Desktop creates a worktree, it should dispatch the WorktreeCreate hook the same way the CLI does:
- Send the JSON payload (
cwd,name,hook_event_name, …) to the hook command on stdin. - Use the path the hook prints on stdout as the worktree location.
- Fail worktree creation (with the hook's stderr surfaced) if the hook exits non-zero.
The Desktop's internal git-worktrees.json registry should record whatever path the hook returned, not a hard-coded .claude/worktrees/<name>.
Error Messages/Logs
No error — the hook is silently skipped. /tmp/claude-worktree-create.log (a debug cat in the hook script) gets a new entry on every CLI --worktree invocation but never on a Desktop-initiated worktree.
~/Library/Application Support/Claude/git-worktrees.json shows recent Desktop-created worktrees still under /Users/<me>/projects/<repo>/.claude/worktrees/<name> despite the hook being active.
Steps to Reproduce
- Add a
WorktreeCreatehook to~/.claude/settings.json:
``json``
{
"hooks": {
"WorktreeCreate": [{
"hooks": [{
"type": "command",
"command": "~/.claude/hooks/worktree-create.sh"
}]
}]
}
}
- Create
~/.claude/hooks/worktree-create.sh(chmod +x):
``bash``
#!/usr/bin/env bash
set -euo pipefail
input=$(cat)
{ echo "=== $(date -u +%FT%TZ) ==="; echo "$input"; echo; } >> /tmp/claude-worktree-create.log
cwd=$(jq -r '.cwd' <<<"$input")
name=$(jq -r '.name' <<<"$input")
parent=$(dirname "$cwd"); base=$(basename "$cwd")
target="$parent/${base}-worktrees/$name"
mkdir -p "$parent/${base}-worktrees"
git -C "$cwd" worktree add "$target" >&2
echo "$target"
- From the CLI:
cd <repo> && claude --worktree probe-cli
→ Hook fires; worktree appears at <parent>/<repo>-worktrees/probe-cli. /tmp/claude-worktree-create.log gets a new entry. ✅
- Fully quit Claude Desktop (⌘Q) and relaunch to clear any settings cache.
- In Desktop: start a new Claude Code session for a project, then enable the "Worktree" toggle for that session.
→ Worktree appears at <repo>/.claude/worktrees/<generated-name>. /tmp/claude-worktree-create.log is not updated. ❌
- Inspect
~/Library/Application Support/Claude/git-worktrees.json— the Desktop-created entry'spathfield points inside.claude/worktrees/, confirming the hook was bypassed.
Related Issues
- #36205 —
EnterWorktreetool ignoresWorktreeCreate/WorktreeRemovehooks (similar bypass for the agent-tool path) - #46664 — Plugin-registered
WorktreeCreatehooks never dispatched (different scope; both point at the dispatch table being incomplete) - #42336 — PostToolUse hooks not triggering in Desktop App (closed, but suggests hook plumbing has had gaps before)
Environment
- Claude Desktop: 1.6259.1 (5095e7), build 2026-05-06T03:26:09Z, macOS
- Claude Code CLI: 2.1.117
- macOS: 26.4.1
- Hook configured at user scope in
~/.claude/settings.json
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗