CLAUDE LABJP
CHROME — Compliance API session retrieval now covers Claude in Chrome transcripts as well. Enterprise beta, added on September 182.1.278 — Claude Code has not moved past 2.1.278 since September 19. That release made the auto-mode classifier server-side by default, and the classifier itself is not billed11/17 — The undocumented client-certificate fallback setting stops being accepted on November 17, fifty-six days out. An in-app warning starts on November 3TMPDIR — Windows shells do not set TMPDIR. Commands written out of habit with $TMPDIR fail with Permission denied, and the failures are quietly retriedNEW — The morning a deprecation notice appeared: checking the version before rewriting the configTOOLS — How far should approvals be automated? Lining up Claude Code hooks and permissions next to Antigravity's Deny / Ask / Allow makes your own boundary easier to drawCHROME — Compliance API session retrieval now covers Claude in Chrome transcripts as well. Enterprise beta, added on September 182.1.278 — Claude Code has not moved past 2.1.278 since September 19. That release made the auto-mode classifier server-side by default, and the classifier itself is not billed11/17 — The undocumented client-certificate fallback setting stops being accepted on November 17, fifty-six days out. An in-app warning starts on November 3TMPDIR — Windows shells do not set TMPDIR. Commands written out of habit with $TMPDIR fail with Permission denied, and the failures are quietly retriedNEW — The morning a deprecation notice appeared: checking the version before rewriting the configTOOLS — How far should approvals be automated? Lining up Claude Code hooks and permissions next to Antigravity's Deny / Ask / Allow makes your own boundary easier to draw
Articles/Claude Code
Claude Code/2026-09-22Advanced

Taking Inventory of Worktrees That Were Supposed to Be Gone

Isolated worktrees my subagents created were never folded away. Here is what I measured in git 2.34.1 about when remove succeeds, the branches that outlive the trees, the 12 MB per-tree difference, and how I decide who owns cleanup.

Claude Code256subagents10git worktreeparallel workoperations30

Premium Article

I had a week where a client site fix and a small migration in one of my own apps were running side by side on the same machine. On Friday night I glanced at free space and the number was one order of magnitude smaller than I expected.

Looking for the cause, I ran git worktree list and found six entries I did not recognize. None of them carried a name I had chosen. They had been created when I let subagents isolate their work, and they had simply stayed.

I stopped there. Isolation is described as something that cleans itself up when nothing changed, so I had placed cleanup outside my own work entirely.

Cleanup belongs to whoever is left holding the leftovers, not to whoever created them. Since that night, before I decide whether to delegate isolation, I decide who counts the leftovers and how.

Trees That Should Fold Themselves Sometimes Don't

When a subagent isolates its work, a temporary worktree is created and — the description goes — removed afterward if nothing changed. For short research tasks, that is exactly what happens.

Run the same setup long enough, though, and some of them stay. A matching report sits in anthropics/claude-code issue #95644, where six accumulated in a single session and git worktree remove --force turned out to be required even though all of them were clean.

Most of the Japanese-language write-ups on this feature still assume the opposite — that unchanged trees disappear, so no cleanup is needed. What I saw on my own machine looked much closer to the issue than to the write-ups.

As an indie developer running unattended jobs, the part that worried me was not the leftovers themselves. It was that free disk space had become my only notification channel. So I started by measuring, locally, exactly when a tree cannot be folded away.

Where contains modified or untracked files, use --force to delete it Comes From

Cleanup ultimately depends on whether git worktree remove succeeds. I built a throwaway repository and ran the same command against different states. My git is 2.34.1.

# throwaway repository
LAB="$HOME/wtlab"; mkdir -p "$LAB/main"; cd "$LAB/main"
git init -q -b main .
printf 'node_modules/\n.next/\ndist/\n' > .gitignore
echo "hello" > README.md
git add -A && git commit -qm init
 
# case 1: nothing left in the tree
git worktree add -q "$LAB/wt-clean" -b feat-clean
git worktree remove "$LAB/wt-clean"      # succeeds, exit 0
 
# case 2: only gitignored build output
git worktree add -q "$LAB/wt-ignored" -b feat-ignored
mkdir -p "$LAB/wt-ignored/node_modules/pkg"
head -c 200000 /dev/urandom > "$LAB/wt-ignored/node_modules/pkg/blob.bin"
git worktree remove "$LAB/wt-ignored"    # succeeds, exit 0
 
# case 3: one untracked scratch note
git worktree add -q "$LAB/wt-untracked" -b feat-untracked
echo "scratch" > "$LAB/wt-untracked/notes.txt"
git worktree remove "$LAB/wt-untracked"
# fatal: '.../wt-untracked' contains modified or untracked files, use --force to delete it
# exit 128

Here is the whole matrix as I measured it.

State of the worktreegit worktree removeExit codeWhat cleanup needs
Empty of local filesSucceeds0Folds away as is
Only gitignored output (node_modules/ and friends)Succeeds0Folds away as is
One untracked filefatal: contains modified or untracked files128--force
A tracked file modifiedSame as above128--force
Locked with git worktree lockfatal: cannot remove a locked working tree128unlock or remove -f -f
Directory deleted by handNothing to act onprune (metadata only)

If you want the same table for your environment, check git --version first. This boundary lives in git, not in the agent, so it is worth running once on the version you actually have.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
You will be able to list every leftover isolated worktree and orphaned branch in under ten minutes, using a read-only audit that deletes nothing
You will know that a single untracked scratch file is what stops automatic cleanup, so you can prevent the disk-full surprise instead of discovering it on a Friday night
You will be able to choose between worktrees, separate clones, and one serialized clone based on who owns cleanup rather than on the 12 MB each copy costs you
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $15 for lifetime access
View Membership →

Related Articles

Claude Code2026-08-16
Tracking Multi-Step Work in Claude Code Now That the Todo Tools Are Off by Default
Since Claude Code v2.1.233, TodoWrite and the Task tools are left out on the newer models. Here are the three branches to check before you set the opt-in variable, the PostToolUse ledger I put in their place, and the measured point where that ledger quietly corrupts under parallel agents.
Claude Code2026-09-01
Once I passed a dozen MCP servers, I stopped trusting the startup list
Only some of the servers that say connection failed at startup are ones you can actually fix. Here is a probe that separates no-response, launch failure, and protocol rejection, measured across a 14-server fleet where sequential 22.03s became parallel 5.09s, and where trimming the deadline quietly turned healthy servers into failures.
Claude Code2026-08-31
Half of My Scheduled Runs Vanished Without a Single Error
A batch job set to run twice a day was only firing once. No errors, no failure alerts. Here is how to expand your own schedule, count expected runs, and reconcile them against execution records to catch silent misses.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links