[BUG] ## CRITICAL: Claude Code executed rm -rf deleting entire home directory

Status Closed — not planned
Maintainer reply None cached
Activity 15 comments · opened Oct 21, 2025 · closed Feb 8, 2026

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

  1. I was working on a project in /home/mwolak/slip/olimex-ice40hx8k-picorv32/firmware
  2. Claude Code executed what appears to be an rm -rf command starting from root
  3. I saw the command executing and interrupted it
  4. Despite interruption, all my user files were already deleted
  5. 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

  1. Command validation: Block dangerous patterns like rm -rf /, rm -rf /*
  2. User confirmation: Require explicit approval for any rm -rf command
  3. Sandboxing: Restrict operations to project directory
  4. Complete audit logging: Log the actual commands, not just outputs
  5. File snapshots: Create backups before destructive operations

Attached Files

I'm attaching the following evidence files:

  1. 112841a4-0d5d-4554-b4df-d7eaf0c1fead.jsonl - Conversation log (shows output but not command)
  2. 112841a4-0d5d-4554-b4df-d7eaf0c1fead.txt - Debug log for this session
  3. 0fa816a0-1b16-4a21-b0e1-f56642c7d781.txt - Debug log showing tracked files now missing
  4. history.jsonl - Command history
  5. CRITICAL_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:

  1. Explicit user confirmation
  2. Safety validation
  3. Sandboxing restrictions
  4. 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)

Additional Information

claude_code_bug_report.tar.gz

View original on GitHub ↗

15 Comments

ZacheryGlass · 10 months ago
hd24-jspoerer · 10 months ago

RIP. Sorry for your loss.

mbailey · 10 months ago

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:

  • Claude was trying to delete a directory called literal ~/ IIRC.
  • I had run with --dangerously-skip-permissions to save effort reviewing tool use.
  • We weren't running in a sandbox: I started one months ago but wasn't using it in anger yet.

Regarding your recommendations:

Command validation: Block dangerous patterns like rm -rf /, rm -rf /*

  • Claude Code requires user confirmation (unless started with --dangerously-skip-permissions)
  • You can block them with Hooks
  • You can effectively stop them with Claude Code Sandboxing (as long as you don't sandbox / or ~/ I guess)

User confirmation: Require explicit approval for any rm -rf command

  • These require user confirmation (unless --dangerously-skip-permissions

Sandboxing: Restrict operations to project directory

Complete audit logging: Log the actual commands, not just outputs

  • Is this not in ~/.claude/projects/?

File snapshots: Create backups before destructive operations

  • You can do this with Hooks. If it's useful, create a plugin and share.

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" />

mikewolak · 10 months ago

It should be noted that I did not run the agent with "--dangerously-skip-permissions "

ZacheryGlass · 10 months ago
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

mikewolak · 10 months ago

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 .

meouwu-dev · 10 months ago

I just encountered Claude code running rm -rf without my permission. This seems like a critical bug in permission validation.

mbailey · 10 months ago
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:

simtrax · 9 months ago

I stumbled upon this as well. Claude Code running rm -rf without 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.

If you need to implement something new, then do It and clean up that old code please. 

⏺ Got it. Let me clean up the old code and implement contours properly with the new cache architecture.

⏺ Bash(rm -rf /Users/me/code/rust/zarr-reader)
github-actions[bot] · 8 months ago

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.

fivelidz · 7 months ago

I've just encountered this on one of my systems.

github-actions[bot] · 6 months ago

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.

marcindulak · 6 months ago

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.

vabenil · 6 months ago

General recommendation, if, for any reason you (or an LLM) accidentally delete files from your system by rm -rf that 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.

github-actions[bot] · 6 months ago

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.