[BUG] ## CRITICAL: Claude Code executed rm -rf deleting entire home directory
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
Claude Code executed a destructive recursive delete command that successfully deleted all user files in my home directory. The command attempted to delete from root (/) and only failed on system files due to permission restrictions, but successfully deleted all user-owned files.
Environment
- Claude Code Version: 2.0.22
- OS: Ubuntu on WSL2 (Windows Subsystem for Linux)
- Date of Incident: October 21, 2025 at approximately 18:05 UTC
- Session ID:
112841a4-0d5d-4554-b4df-d7eaf0c1fead
What Happened
- I was working on a project in
/home/mwolak/slip/olimex-ice40hx8k-picorv32/firmware - Claude Code executed what appears to be an
rm -rfcommand starting from root - I saw the command executing and interrupted it
- Despite interruption, all my user files were already deleted
- Only system files protected by permissions survived
Evidence
Error output pattern (from conversation log):
rm: cannot remove '/bin': Permission denied
rm: cannot remove '/boot': Permission denied
rm: cannot remove '/dev/kvm': Permission denied
rm: cannot remove '/etc/[files]': Permission denied
rm: cannot remove '/home/mwolak': Permission denied
rm: cannot remove '/lib': Permission denied
[... thousands more permission denied errors ...]
Confirmed data loss:
- All project directories deleted:
autotest/,0.11/,tags/,slip/ - All source code files deleted (13+ tracked files in active session)
- Only dotfiles (
.cache,.config,.claude, etc.) remain
Critical issue: The conversation log file contains only the tool output (tool_result) but NOT the actual command (tool_use), making it impossible to see exactly what command was executed.
Current State
$ ls -la /home/mwolak
# Only hidden dotfiles remain - all project directories gone
drwxr-x--- 9 mwolak mwolak 4096 Oct 21 18:19 .
drwxr-xr-x 3 root root 4096 Jan 6 2024 ..
-rw------- 1 mwolak mwolak 7 Oct 21 18:08 .bash_history
drwx------ 3 mwolak mwolak 4096 Oct 21 18:13 .cache
drwx------ 9 mwolak mwolak 4096 Oct 21 18:19 .claude
[... only dotfiles ...]
Impact
- Complete loss of active development projects
- Weeks/months of work lost
- No recovery mechanism available
- Had to reinstall Claude Code
- Severe safety concern for all users
What Should Have Prevented This
- Command validation: Block dangerous patterns like
rm -rf /,rm -rf /* - User confirmation: Require explicit approval for any
rm -rfcommand - Sandboxing: Restrict operations to project directory
- Complete audit logging: Log the actual commands, not just outputs
- File snapshots: Create backups before destructive operations
Attached Files
I'm attaching the following evidence files:
112841a4-0d5d-4554-b4df-d7eaf0c1fead.jsonl- Conversation log (shows output but not command)112841a4-0d5d-4554-b4df-d7eaf0c1fead.txt- Debug log for this session0fa816a0-1b16-4a21-b0e1-f56642c7d781.txt- Debug log showing tracked files now missinghistory.jsonl- Command historyCRITICAL_BUG_REPORT.md- Detailed incident report
Reproduction
UNKNOWN - The exact prompt/context is not visible in logs because the command itself wasn't logged, only the output.
Expected Behavior
Claude Code should NEVER execute commands that can delete entire directory trees without:
- Explicit user confirmation
- Safety validation
- Sandboxing restrictions
- Complete audit trail
Actual Behavior
Claude Code executed a recursive delete from root with no confirmation, no safety checks, and incomplete logging.
---
This is a critical safety incident that puts all Claude Code users at risk of data loss.
cc: @anthropics-team
What Should Happen?
Claude should execute safe commands in-line with the operations requested from him, in this case , rebuilding a project.
Error Messages/Logs
Steps to Reproduce
Ask Claude to rebuild a Makefile project from a fresh checkout.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
4.5
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
15 Comments
https://dangerously-skip-permissions.com/
RIP. Sorry for your loss.
Sorry to hear about your files. This happened to me once but luckily I noticed the errors and hit Escape before anything important went. Pushing to git helps me sleep at night.
I had some stern words with Claude afterward and we did a blameless post mortem later to find root causes:
~/IIRC.--dangerously-skip-permissionsto save effort reviewing tool use.Regarding your recommendations:
Command validation: Block dangerous patterns like rm -rf /, rm -rf /*
--dangerously-skip-permissions)/or~/I guess)User confirmation: Require explicit approval for any rm -rf command
--dangerously-skip-permissionsSandboxing: Restrict operations to project directory
Complete audit logging: Log the actual commands, not just outputs
~/.claude/projects/?File snapshots: Create backups before destructive operations
AI Agents can be a bit like dogs sometimes.
<img width="640" height="480" alt="Image" src="https://github.com/user-attachments/assets/a56eddcc-cc83-4577-a36f-8ea6630c251a" />
It should be noted that I did not run the agent with "--dangerously-skip-permissions "
Then what is the problem? It cannot execute commands without your explicit permission
In this case it did, I'd never let it do that. It had permission to make file modifications in my project directory, not in / or even one directory down .
I just encountered Claude code running rm -rf without my permission. This seems like a critical bug in permission validation.
Can you provide more context? Do you have logs?
Environment
Claude Code Version:
OS:
Date of Incident:
Session ID:
I stumbled upon this as well. Claude Code running
rm -rfwithout my permission.I was really surprised when I saw it running the command straight away.
Luckily I have Time Machine running and it was only a few changes since my last commit, but still. Could have been a lot worse.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I've just encountered this on one of my systems.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.
General recommendation, if, for any reason you (or an LLM) accidentally delete files from your system by
rm -rfthat doesn't necessarily mean you cannot recover them.You should immediately turn off your system (by force if necessary), to avoid any possible writes in the disk and then with a live USB attempt to do data recovery. I have recovered my whole system this way before.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.