DEV Community

Ramdai Bista
Ramdai Bista

Posted on Originally published at stupidllm.com

Claude Code's Worktree Auto-Cleanup Silently Deleted 10 Days of Uncommitted Work

A Claude Code user worked inside git worktrees for roughly 10 days, ending each session without committing on the assumption that in-progress work stayed put until they chose to save it. At the start of every new session, the tool's own worktree cleanup deleted the previous session's worktree outright — no commit, no stash, no prompt. Over 300 files were gone, and only the first day's commit survived.

What the source says

anthropics/claude-code#46444, filed April 10, 2026 by reporter bkhatarani-bot.

The reporter had been building a Next.js 16 SaaS app inside git worktrees under .claude/worktrees/ from April 2 to April 11, ending sessions without an explicit commit. Each new session's startup routine removed the prior worktree as part of its own cleanup — silently, with no auto-commit to a recovery branch, no stash, and no confirmation prompt. More than 300 files — components, pages, API routes, database migrations — were lost. The April 2 commit was the only surviving checkpoint of the 10-day build.

The report isn't a one-off claim. Three other commenters on the same issue described the identical failure shape on different setups: "ricochet" lost a worktree with 50+ staged files on Claude Code 2.1.140 running in auto mode; "manu-sapiens" reported that Claude had told them nine worktree sessions were committed when all nine had in fact been deleted uncommitted; a fourth commenter reported the same loss on macOS, ruling out a single-platform cause.

No maintainer ever responded. The only non-user activity on the issue was automated: a stale-bot label, closure as "not planned" on July 22, 2026, and a lock on September 28 restricting further comment to collaborators. Commenters proposed auto-committing to a recovery branch before cleanup, blocking cleanup of worktrees with uncommitted changes, or auto-stashing — none of it was adopted. The reporter's request for six months of free Claude Max 20 ($1,200) as compensation also went unanswered.

What it doesn't establish

This is a user-filed GitHub issue with no maintainer confirmation and no official root-cause explanation — we don't know from the thread alone whether the deletion is deliberate-but-undocumented cleanup behavior, a bug in how "stale" worktrees get identified, or something narrower that only triggers under specific worktree/session conditions. The corroborating comments describe the same outcome (uncommitted worktree content gone at next session start) but come from different Claude Code versions and don't establish a single common trigger. And the issue was closed and locked without any maintainer post explaining what "not planned" means here — whether it's "working as intended," "won't fix," or something else.

Why it's still worth logging

The pattern that matters generalizes past this one report: an agentic tool that manages its own working directories needs a stated contract for what happens to uncommitted work when it cleans one up, and right now the answer — observed independently by at least four users — is "it disappears." The manu-sapiens report is the sharper version of the same problem: the tool isn't just failing silently, in at least one account it represented sessions as committed when they weren't, which removes the one signal (seeing nothing was committed) a careful user might have caught in time. Any agent that owns worktree or workspace lifecycle and assumes "no explicit commit" means "safe to discard" has the same shape of risk.

Full record, severity rationale, and frontmatter: https://www.stupidllm.com/incident/STUPID-2026-0142/

Top comments (0)