WorktreeCreate hook disables worktree cleanup prompt on exit

Resolved 💬 3 comments Opened Mar 23, 2026 by TheRayFitzgerald Closed Mar 26, 2026

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

  1. Add a WorktreeCreate hook to .claude/settings.json — even a minimal one that just does git worktree add and 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\"'"
}]
}]
``

  1. Run claude -w test
  2. Make a change and/or commit
  3. Exit with Ctrl+D
  4. Observe: No keep/remove prompt appears. Worktree is left on disk.
  1. Remove the WorktreeCreate hook from settings
  2. Repeat steps 2-4
  3. 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)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗