[BUG] Resumed worktree session does not trigger WorktreeRemove on exit
Resolved 💬 4 comments Opened Mar 16, 2026 by avemeva Closed Apr 14, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using Claude Code 2.1.76
What's Wrong?
Fresh --worktree sessions clean up correctly on /exit. However, when a session is resumed after the terminal was closed, WorktreeRemove hook is not invoked on exit. The worktree and branch are orphaned.
Reproduction
# 1. Start a worktree session
claude --worktree my-feature # WorktreeCreate fires, worktree created
# ... work, commit, push to main
# 2. Close terminal window — session killed without /exit
# 3. Resume and exit
cd <worktree-path>
claude --resume # Resume the interrupted session
/exit # WorktreeRemove does NOT fire
Worktree directory and branch persist after exit. git worktree list still shows the orphaned worktree.
Expected
/exit on a resumed worktree session should invoke WorktreeRemove and clean up the worktree, same as a non-interrupted session.
Environment
- Claude Code 2.1.76
- macOS 15.5, Ghostty 1.3.0
- Custom
WorktreeCreate/WorktreeRemovehooks in.claude/settings.json
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗