← All articlesGuides3 min read

Which of these worktrees can you delete?

Give every agent its own worktree and they stop overwriting each other. A week later you have a different problem: a dozen folders with names like fix-login-2, and no memory of which ones are finished.

Deleting by guesswork is how work gets lost. A folder can look abandoned and still hold the only copy of a commit nobody merged. Keeping everything has a cost too: every one is a full checkout on your disk, and the list gets harder to read each day.

The question is not how old it is

Age tells you nothing. The questions that matter are whether its work has reached the main line, whether anything in it is uncommitted, and whether a session is still sitting in it. Those can all be answered by a machine, which is what the Worktrees page is for.

Three groups, each with a plain meaning

Select a session, open Source Control, and pick Worktrees on the rail down the left side. It scans that session's repository and sorts every linked worktree:

  • Safe to reap. The work is already on origin/main and the tree is clean, so nothing is lost by removing it.
  • In use by an open session. The work has landed, but a session is still open in the folder. These are held back until you close it, and they are never removed while in use.
  • Needs attention. The worktree carries unmerged commits or uncommitted content, so somebody has to decide. These are never removed for you.

The page carries a red count when a repository has worktrees you can clear away, so the backlog announces itself.

Removing them

Remove orphaned worktrees appears only when the safe group has at least one entry, and it shows you exactly what it is about to remove before it acts. Refresh runs a fetch with prune first, so the merged-or-not verdict is current rather than a memory of last Tuesday. Press it before you trust the list.

The third group is a job for an agent

Needs attention is where the judgment is, and you do not have to do that reading by hand. Copy report puts the whole listing on your clipboard as text. Paste it into a session and ask the agent to work out, folder by folder, what is in each one and whether it should be merged or dropped. You decide. It does the reading.

Make it a habit

Clearing the safe group takes seconds and is worth doing whenever you see the red count. A growing Needs attention group is the more useful signal: it is a list of work that started and never finished landing.

The groups and their rules are on Source control and history. Cutting worktrees and giving each session its own is on repositories and worktrees.