WorktreeCreate hook disables worktree cleanup prompt on exit
Description
When a WorktreeCreate hook is defined in .claude/settings.json, the worktree cleanup prompt on session exit is completely skipped — even when the hook uses git and creates a standard git worktree. The worktree is left on disk with no prompt and no auto-deletion.
Without the hook, the documented behavior works correctly: CC prompts to keep or remove the worktree when changes/commits exist, and auto-removes when there are no changes.
Steps to reproduce
- Add a
WorktreeCreatehook to.claude/settings.json— even a minimal one that just doesgit worktree addand prints the path:
``json``
"WorktreeCreate": [{
"hooks": [{
"type": "command",
"command": "bash -c 'NAME=$(jq -r .name); DIR=\"$CLAUDE_PROJECT_DIR/.claude/worktrees/$NAME\"; git worktree add \"$DIR\" -b \"feature/$NAME\" main >&2 && echo \"$DIR\"'"
}]
}]
- Run
claude -w test - Make a change and/or commit
- Exit with
Ctrl+D - Observe: No keep/remove prompt appears. Worktree is left on disk.
- Remove the
WorktreeCreatehook from settings - Repeat steps 2-4
- Observe: Cleanup prompt appears as expected.
Expected behavior
The cleanup prompt should still fire when a WorktreeCreate hook is defined, since the hook is documented as a way to customize worktree creation (e.g., copying env files, symlinking dependencies) — not to opt out of the cleanup lifecycle.
A paired WorktreeRemove hook was also tested and is never called either — the entire cleanup flow is skipped.
Environment
- Claude Code 2.1.81
- macOS (terminal CLI, not VS Code extension)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗