# Claude Code 2.1.330 Fixed Shared Worktree Cleanup: What to Check Before Exit

Check whether two Claude Code sessions are using the same checkout, what the fix protects, and how to save work before closing a session.

By Paras Madan | 2026-11-22


Claude Code 2.1.330 fixes a bug where the exit dialog or the `ExitWorktree` tool could delete a Git worktree that another Claude Code session was still using. If you run parallel sessions, check their actual checkout paths before closing one. Two terminal tabs can be working in the same directory.

## Check the version and the checkout path

Run `claude --version` in the same environment you use to launch Claude. A local terminal, a container and a remote dev box may each have their own installation. [Anthropic’s v2.1.330 release notes](https://github.com/anthropics/claude-code/releases/tag/v2.1.330) name both exit paths that were fixed. If you are still on an earlier version, update through your normal installation channel and restart the sessions you want to run on the new build.

To check for overlap, run these commands from the working directory of each session:

```bash
git rev-parse --show-toplevel
git status --short --branch
```

The first command gives you the checkout path; the second shows its branch and any changes Git can see. If two sessions report the same checkout path, treat them as sharing files. From the main checkout, `git worktree list --porcelain` gives you the paths and branches Git has registered. It does not tell you which Claude sessions are still running.

## Why separate tabs can share a worktree

Suppose you start `claude --worktree invoice-fix` to change an invoice calculation, then use the same command in a second terminal to review the change. [Anthropic’s worktree guide](https://code.claude.com/docs/en/worktrees) says an existing name reopens that worktree. Both tabs can see and edit the same files, even though the chat histories are separate.

The fix protects the checkout during Claude's cleanup when it detects another session there. **It does not make the shared checkout safe for two writers.** If the second session needs to apply its own changes, give it a different worktree name and choose the branch or commits it should start from. Keep one writer in the original worktree until you have saved the edits you want.

## What to choose when Claude asks to remove it

If there is anything you might need in the checkout, choose **Keep**. Review the diff and any untracked files before closing the last session. Save the intended changes in a commit or another durable copy you control. A clean status alone does not tell you whether your commits exist on any other branch or remote.

The worktree guide says that when Claude detects another session in the checkout, it keeps the worktree and branch even if you choose removal. Look for the `Worktree kept at` message. Once no other session is detected, the usual cleanup rules apply. For example, Claude can remove a clean checkout and its branch automatically for an unnamed interactive session. The published fix addresses Claude’s own exit and `ExitWorktree` behavior; it does not change a cleanup command you run separately or a custom worktree removal hook.

## If the worktree is already gone

Stop the affected session before asking it to continue from a different folder. From a surviving checkout, look for the old branch in `git branch --list` or a commit you recognize in `git reflog --all`. If you find the right commit, inspect it and save it to a new branch before doing cleanup. [Git’s worktree reference](https://git-scm.com/docs/git-worktree) explains how to inspect linked checkouts and their metadata.

A commit can still exist when its checkout is gone. An untracked file that was never committed or backed up is a different case: a reflog will not bring it back.

I’m Paras. I help AI product teams turn changes like this into practical guides developers can use during an upgrade.

[Book a 30-minute call](https://cal.com/paras-madan/30min)
