{"version":"2.1.286","anchor":"worktree-removal-signal-handling-state-on-exit","canonical_anchor":"worktree-removal-signal-handling-state-on-exit","heading":"Worktree removal on exit now runs after the session ends","tier":"notice","area":"Worktrees","url":"https:\/\/changelogs.core-directive.com\/v\/2.1.286\/e\/worktree-removal-signal-handling-state-on-exit","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.286","markdown":"### Worktree removal on exit now runs after the session ends\n\nChoosing to remove a worktree when you exit now runs the removal during shutdown, can be interrupted, and reports if it was skipped\n\n**Unclear.** When removal ignores a lost terminal and when the resume hint leaves out the worktree is not clear.\n\n**What**\n\nA worktree is a separate working copy of your git repository that a Claude Code session can work in. When you leave a worktree session you can remove it, and a clean worktree can be removed automatically. That removal now runs during Claude Code's shutdown instead of inside the exit dialog.\n\n- Choosing 'Remove worktree', or the automatic removal of a clean worktree, no longer holds up the dialog for worktrees not created by a hook. The removal is handed off as a `removeWorktree` step that runs after the session ends. Before, the dialog waited for the removal and then showed the result.\n\n- Worktrees created by a hook are still removed right away, inside the dialog.\n\n- During shutdown, `removeWorktreeAtExit` prints \"Removing worktree\u2026\" and runs with a time budget of at least 5 seconds.\n\n- Pressing Ctrl+C or receiving a stop or hang-up signal (SIGINT, SIGTERM, SIGHUP) interrupts the removal, and a message warns that the folder may be partly deleted.\n\n- When a tmux session is being closed and `TMUX` and `CLAUDE_CODE_TMUX_SESSION` match, the removal ignores the hang-up signal.\n\n- If the session had switched away from that worktree, removal is refused with \"Worktree not removed: this session had switched away from it before Claude Code exited\".\n\n- If a shutdown is already under way and a second request asks to remove a different worktree, a warning is logged that the worktree was kept. Before, this was silently dropped.\n\n- The hint for resuming the session can now leave out the worktree once it has been removed (`resumeHintOmitsWorktree`).\n\n**Why**\n\nExiting is quicker, but the result of the removal now appears after the dialog closes. If a worktree is left behind, the new messages say why, and an interrupted removal can leave a partly deleted folder to clean up.\n\n- Area: Worktrees\n- Tier: You'll notice\n- Useful: 3\/5\n- Signal: 1\/5"}