claude-code - 💡(How to fix) Fix Critical: Claude Code worktree auto-cleanup permanently deleted 10 days of uncommitted project work without any warning [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46444Fetched 2026-04-11 06:20:07
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×5unlabeled ×1

Error Message

Claude Code should never silently delete worktrees containing uncommitted work. It must either: (1) auto-commit work to a branch before cleanup, (2) warn the user prominently and require explicit confirmation before removing any worktree with uncommitted changes, or (3) stash the changes safely. Users must never lose work due to Claude Code's internal session management. 160+ hours of near-launch production work was destroyed entirely by Claude Code's behavior, not user error. 6 months is the minimum reasonable compensation. I expect Anthropic to honor this claim and fix this bug immediately.

Code Example



---
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues for similar behavior reports
  • This report does NOT contain sensitive information (API keys, passwords, etc.)

Type of Behavior Issue

Claude modified files I didn't ask it to modify

What You Asked Claude to Do

I asked Claude Code to help me build a Next.js 16 SaaS application called "Ai Generates" — an AI video maker platform. Over approximately 10 days of development sessions (working 16 hours every day), Claude Code autonomously created git worktrees (under .claude/worktrees/) to perform its work during each session. I was never informed that work done inside worktrees would be lost if not explicitly committed. I assumed my work was being saved normally. I was very close to completing and launching the product.

What Claude Actually Did

At the start of each new session, Claude Code silently cleaned up the previous session's worktrees WITHOUT committing or preserving any work. This resulted in ~10 days of development being permanently deleted. When I noticed my project files were missing, Claude searched git history and found only one commit on branch claude/sweet-hamilton from April 2, 2026 — 10 days before the loss was discovered (April 11, 2026). The git root was C:\Users\Admin\.git. ~300+ files across components, pages, API routes, DB migrations, and UI features were all permanently lost.

Expected Behavior

Claude Code should never silently delete worktrees containing uncommitted work. It must either: (1) auto-commit work to a branch before cleanup, (2) warn the user prominently and require explicit confirmation before removing any worktree with uncommitted changes, or (3) stash the changes safely. Users must never lose work due to Claude Code's internal session management.

Files Affected

Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Yes, every time with the same prompt

Steps to Reproduce

  1. Open Claude Code (Windows 11 desktop app), start a dev session on a Next.js project.
  2. Ask Claude to build features over multiple sessions across many days — Claude creates worktrees under .claire/worktrees/.
  3. Do not manually commit at session end (trusting Claude Code handles persistence).
  4. Start a new session the next day — Claude silently removes the previous worktree without committing.
  5. Repeat for ~10 days.
  6. Notice project directory is empty/reverted. All work is permanently gone.

Environment: Windows 11 Pro 10.0.26200, git root C:\Users\Admin.git, Next.js 16.2.1 + Prisma + Supabase, Claude Code Windows desktop app.

Claude Model

Sonnet

Relevant Conversation

Impact

Critical - Data loss or corrupted project

Claude Code Version

sonet 4.6

Platform

Anthropic API

Additional Context

Impact: ~300+ source files lost (components, pages, API routes, DB migrations, UI layouts). 10 days x 16 hours/day = 160+ hours permanently destroyed (April 2-11, 2026). No warning, no confirmation, no auto-commit before cleanup. I was days away from launching my product — this caused extreme stress and financial harm.

COMPENSATION DEMAND: I formally request 6 months free subscription as compensation.

  • Plan: Claude Max 20 — $200/month
  • Amount claimed: 6 x $200 = $1,200 in subscription credits

160+ hours of near-launch production work was destroyed entirely by Claude Code's behavior, not user error. 6 months is the minimum reasonable compensation. I expect Anthropic to honor this claim and fix this bug immediately.

extent analysis

TL;DR

To prevent data loss, ensure that Claude Code is configured to auto-commit changes or warn users before removing worktrees with uncommitted work.

Guidance

  • Review Claude Code's documentation to see if there are any settings or configurations that can be changed to prevent silent cleanup of worktrees with uncommitted changes.
  • Consider using an external version control system to track changes and commits, providing an additional layer of protection against data loss.
  • Reach out to Anthropic support to report this issue and request assistance in recovering lost work, if possible.
  • In future development sessions, manually commit changes regularly to prevent reliance on Claude Code's internal session management.

Example

No code snippet is provided as this issue is related to the usage and configuration of Claude Code rather than a specific coding problem.

Notes

The provided information suggests that this issue is related to the specific behavior of Claude Code's session management and worktree cleanup. It is uncertain whether this behavior is a bug or an intended feature, but it is clear that it caused significant data loss and disruption.

Recommendation

Apply a workaround by manually committing changes regularly and exploring configuration options to prevent silent cleanup of worktrees. This approach can help mitigate the risk of data loss until a more permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING