TL;DR Settings → Desktop → Storage → Manage → the Code sessions and worktrees tab shows what your inactive sessions' worktrees take up, and Free up space clears them. To stop it happening again, Settings → Claude Code → Auto-archive after PR merge.
Starting a session in Desktop is one click, and that click creates an isolated worktree with no flags and no extra terminals. It's the app's best idea: every session works on its own branch without stepping on the others. What sits in a different settings screen is the bill. A worktree is a full checkout of your repository, and the session stays in the sidebar until you archive it.
The terminal handles this on its own. When you exit a worktree session, Claude Code inspects it: clean and unnamed, it removes the worktree and its branch; clean but named, it asks first; with changed files, untracked files or new commits in there, it lets you keep it or remove it along with everything inside. Desktop has no exit moment. You close the tab and the session is still in the sidebar, folder and all.
The panel that tells you what it costs
It lives in the app's own settings rather than Claude Code's: Settings → Desktop → Storage, then Manage. It opens a breakdown of the space Claude uses on this computer, split by area, with a tab for Code sessions and worktrees.
Storage Manage
Space Claude uses on this computer
Code storage by kind
├─ Conversation history
├─ Worktrees in use or with changes
└─ Worktrees kept ready for new sessions
[ Free up space… ]
Inactive for at least [ N ] days
→ 7 worktrees from inactive sessions · 4.2 GB
(Illustrative preview: it's a GUI, so I can't capture it from here.)
Those three rows are different things, which is why the panel keeps them apart. Conversation history is small. Worktrees in use or with changes are the live ones. Worktrees kept ready for new sessions are the ones the app keeps ready for the next session, so that slice isn't leftovers.
Free up space works on inactive sessions and lets you set the cutoff, Inactive for at least N days. What it deletes is the folder of every worktree that no longer holds work. Anything with uncommitted changes is left out by default, behind a separate checkbox that counts them, sizes them, and says outright that those changes are lost. It's the one checkbox in the panel worth reading twice.
Keeping it empty
Clearing the panel once fixes today. Two switches keep it clear, both in Settings → Claude Code:
1. Auto-archive after PR merge
Archives the session when its pull request merges or closes. Archiving takes the worktree with it, and deletes the branch once the pull request has merged. Anything you hadn't pushed is kept. It only applies to local sessions that have finished running.
2. Archive inactive sessions
Archives local sessions after a stretch with no activity. It never touches a session that's running or has background work, and if its worktree has uncommitted changes, that worktree stays on disk. A pinned session isn't archived automatically either.
Archiving isn't deleting the conversation: unarchive it and you pick up where you were, only without the worktree.
And if your problem is where they live rather than how much they hold, the same section has Worktree location (empty means inside the project, under .claude/worktrees; point it at a folder in your home directory and the app creates one subfolder per project) and Branch prefix, which prepends whatever you choose to every branch Desktop creates, so you can tell them from your own at a glance.
Reference
| Where | What it controls |
|---|---|
| Settings → Desktop → Storage → Manage | The space breakdown and the Free up space button |
| Settings → Claude Code → Auto-archive after PR merge | Archives the session when its PR merges or closes, worktree included |
| Settings → Claude Code → Archive inactive sessions | Archives idle local sessions, sparing the ones with changes |
| Settings → Claude Code → Worktree location | Where worktrees get created (empty = the project's .claude/worktrees) |
| Settings → Claude Code → Branch prefix | The prefix on branches Desktop creates |
The same job in the terminal, with different tools
On the CLI there is no panel. Cleanup on exit does most of the work, and on top of it a periodic sweep removes the worktrees of subagents and background sessions once they are older than your cleanupPeriodDays, the same setting that decides how long your conversations sit on disk. That sweep leaves alone anything holding work, and anything you created yourself with git worktree add. For one background session, claude rm <id> deletes it and its worktree when that is safe; for the rest, git worktree list and git worktree remove.
On my machine, which lives in the terminal, those .claude/worktrees folders are empty. That is the whole point: the automatic cleanup exists, but in Desktop it rides on archiving the session, and archiving the session is the step you forget.
Worktrees have more than one trap in them. The classic is the .env that doesn't travel, and if you aren't using them at all yet, start with three parallel tasks from one command.
Official docs: Run parallel sessions with worktrees · Desktop: work in parallel with sessions
Requirements
- Claude Code Desktop on macOS or Windows (settings and panel read from build 1.46388.4).
- Git installed: without it there is no per-session isolation, and on Windows the Code tab won't start.
- On the CLI,
claude rmand thecleanupPeriodDayssweep verified on v2.1.263.