claude-code - 💡(How to fix) Fix Claude Code executed rm -rf on user data folder containing 3,467 files (~7 GB) without confirmation [1 comments, 2 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#46058Fetched 2026-04-11 06:30:05
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×6commented ×1

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing rm -rf on a folder containing the only copies of the files, without asking for user confirmation.

Error Message

Error Messages/Logs

Root Cause

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing rm -rf on a folder containing the only copies of the files, without asking for user confirmation.

Code Example

## Summary

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing 
`rm -rf` on a folder containing the only copies of the files, without asking for 
user confirmation.

## Steps that led to data loss

1. User asked Claude to organize PDF files according to a classification system
2. Claude moved (not copied) all 3,467 original PDFs from their source directories 
   into a new organized folder structure ("Catálogo Organizado ENARMAD")
3. User corrected the classification system to use, so Claude created a second 
   reorganized folder ("Catálogo CENETEC Organizado") and moved the files there again
4. Claude then ran `shutil.rmtree()` on the first folder (now empty) 
5. The second reorganization had issues, so Claude ran `rm -rf` on the second folder 
   — which contained the ONLY copies of all 3,467 PDFs
6. All files were permanently deleted. No confirmation was requested before deletion.

## Expected behavior

- Claude should NEVER run `rm -rf` or `shutil.rmtree()` on folders containing user 
  data without explicit confirmation
- Claude should recognize when files have been moved (not copied) and that the 
  destination folder contains the only copies
- Destructive operations on large amounts of user data should always require user 
  approval, regardless of context

## Environment

- macOS (Darwin 25.4.0)
- Claude Code CLI
- Model: claude-opus-4-6

## Impact

- 3,467 PDF files permanently lost (~7 GB)
- Files were medical study materials (Clinical Practice Guidelines / GPC) 
  that took significant time to collect and organize
- Partial recovery possible via Wayback Machine URLs and Google Drive links 
  stored in metadata files, but not all files are recoverable from these sources
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Summary

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing rm -rf on a folder containing the only copies of the files, without asking for user confirmation.

Steps that led to data loss

  1. User asked Claude to organize PDF files according to a classification system
  2. Claude moved (not copied) all 3,467 original PDFs from their source directories into a new organized folder structure ("Catálogo Organizado ENARMAD")
  3. User corrected the classification system to use, so Claude created a second reorganized folder ("Catálogo CENETEC Organizado") and moved the files there again
  4. Claude then ran shutil.rmtree() on the first folder (now empty)
  5. The second reorganization had issues, so Claude ran rm -rf on the second folder — which contained the ONLY copies of all 3,467 PDFs
  6. All files were permanently deleted. No confirmation was requested before deletion.

Expected behavior

  • Claude should NEVER run rm -rf or shutil.rmtree() on folders containing user data without explicit confirmation
  • Claude should recognize when files have been moved (not copied) and that the destination folder contains the only copies
  • Destructive operations on large amounts of user data should always require user approval, regardless of context

Environment

  • macOS (Darwin 25.4.0)
  • Claude Code CLI
  • Model: claude-opus-4-6

Impact

  • 3,467 PDF files permanently lost (~7 GB)
  • Files were medical study materials (Clinical Practice Guidelines / GPC) that took significant time to collect and organize
  • Partial recovery possible via Wayback Machine URLs and Google Drive links stored in metadata files, but not all files are recoverable from these sources

What Should Happen?

Summary

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing rm -rf on a folder containing the only copies of the files, without asking for user confirmation.

Steps that led to data loss

  1. User asked Claude to organize PDF files according to a classification system
  2. Claude moved (not copied) all 3,467 original PDFs from their source directories into a new organized folder structure ("Catálogo Organizado ENARMAD")
  3. User corrected the classification system to use, so Claude created a second reorganized folder ("Catálogo CENETEC Organizado") and moved the files there again
  4. Claude then ran shutil.rmtree() on the first folder (now empty)
  5. The second reorganization had issues, so Claude ran rm -rf on the second folder — which contained the ONLY copies of all 3,467 PDFs
  6. All files were permanently deleted. No confirmation was requested before deletion.

Expected behavior

  • Claude should NEVER run rm -rf or shutil.rmtree() on folders containing user data without explicit confirmation
  • Claude should recognize when files have been moved (not copied) and that the destination folder contains the only copies
  • Destructive operations on large amounts of user data should always require user approval, regardless of context

Environment

  • macOS (Darwin 25.4.0)
  • Claude Code CLI
  • Model: claude-opus-4-6

Impact

  • 3,467 PDF files permanently lost (~7 GB)
  • Files were medical study materials (Clinical Practice Guidelines / GPC) that took significant time to collect and organize
  • Partial recovery possible via Wayback Machine URLs and Google Drive links stored in metadata files, but not all files are recoverable from these sources

Error Messages/Logs

## Summary

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing 
`rm -rf` on a folder containing the only copies of the files, without asking for 
user confirmation.

## Steps that led to data loss

1. User asked Claude to organize PDF files according to a classification system
2. Claude moved (not copied) all 3,467 original PDFs from their source directories 
   into a new organized folder structure ("Catálogo Organizado ENARMAD")
3. User corrected the classification system to use, so Claude created a second 
   reorganized folder ("Catálogo CENETEC Organizado") and moved the files there again
4. Claude then ran `shutil.rmtree()` on the first folder (now empty) 
5. The second reorganization had issues, so Claude ran `rm -rf` on the second folder 
which contained the ONLY copies of all 3,467 PDFs
6. All files were permanently deleted. No confirmation was requested before deletion.

## Expected behavior

- Claude should NEVER run `rm -rf` or `shutil.rmtree()` on folders containing user 
  data without explicit confirmation
- Claude should recognize when files have been moved (not copied) and that the 
  destination folder contains the only copies
- Destructive operations on large amounts of user data should always require user 
  approval, regardless of context

## Environment

- macOS (Darwin 25.4.0)
- Claude Code CLI
- Model: claude-opus-4-6

## Impact

- 3,467 PDF files permanently lost (~7 GB)
- Files were medical study materials (Clinical Practice Guidelines / GPC) 
  that took significant time to collect and organize
- Partial recovery possible via Wayback Machine URLs and Google Drive links 
  stored in metadata files, but not all files are recoverable from these sources

Steps to Reproduce

Summary

Claude Code permanently deleted ~7 GB of user data (3,467 PDF files) by executing rm -rf on a folder containing the only copies of the files, without asking for user confirmation.

Steps that led to data loss

  1. User asked Claude to organize PDF files according to a classification system
  2. Claude moved (not copied) all 3,467 original PDFs from their source directories into a new organized folder structure ("Catálogo Organizado ENARMAD")
  3. User corrected the classification system to use, so Claude created a second reorganized folder ("Catálogo CENETEC Organizado") and moved the files there again
  4. Claude then ran shutil.rmtree() on the first folder (now empty)
  5. The second reorganization had issues, so Claude ran rm -rf on the second folder — which contained the ONLY copies of all 3,467 PDFs
  6. All files were permanently deleted. No confirmation was requested before deletion.

Expected behavior

  • Claude should NEVER run rm -rf or shutil.rmtree() on folders containing user data without explicit confirmation
  • Claude should recognize when files have been moved (not copied) and that the destination folder contains the only copies
  • Destructive operations on large amounts of user data should always require user approval, regardless of context

Environment

  • macOS (Darwin 25.4.0)
  • Claude Code CLI
  • Model: claude-opus-4-6

Impact

  • 3,467 PDF files permanently lost (~7 GB)
  • Files were medical study materials (Clinical Practice Guidelines / GPC) that took significant time to collect and organize
  • Partial recovery possible via Wayback Machine URLs and Google Drive links stored in metadata files, but not all files are recoverable from these sources

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

1

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

To prevent similar data loss incidents, modify Claude Code to always request user confirmation before executing rm -rf or shutil.rmtree() on folders containing user data.

Guidance

  • Identify and modify the code sections where rm -rf and shutil.rmtree() are executed without user confirmation to add a confirmation prompt.
  • Implement a check to recognize when files have been moved (not copied) and ensure the destination folder contains the only copies, requiring user approval for destructive operations in such cases.
  • Review the code for any other potential destructive operations that may not require user approval and modify them accordingly.
  • Consider adding a backup or versioning system to prevent permanent data loss in the future.

Example

import shutil
import os

# Before executing rm -rf or shutil.rmtree()
def confirm_deletion(folder_path):
    response = input(f"Are you sure you want to delete {folder_path}? (y/n): ")
    if response.lower() != 'y':
        return False
    return True

# Example usage
folder_path = "path/to/folder"
if confirm_deletion(folder_path):
    shutil.rmtree(folder_path)
else:
    print("Deletion cancelled.")

Notes

The provided issue lacks specific code snippets, making it challenging to provide a precise fix. However, the general guidance and example should help in modifying the Claude Code to prevent similar incidents.

Recommendation

Apply the workaround by modifying the Claude Code to request user confirmation before executing destructive operations on user data. This will prevent similar data loss incidents until a more permanent fix can be implemented.

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…

FAQ

Expected behavior

  • Claude should NEVER run rm -rf or shutil.rmtree() on folders containing user data without explicit confirmation
  • Claude should recognize when files have been moved (not copied) and that the destination folder contains the only copies
  • Destructive operations on large amounts of user data should always require user approval, regardless of context

Still need to ship something?

×6

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

Back to top recommendations

TRENDING