claude-code - 💡(How to fix) Fix [Bug] Claude Code executed unauthorized rm -rf due to case-insensitive filesystem path resolution [3 comments, 3 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#48792Fetched 2026-04-16 06:50:49
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×6commented ×3
RAW_BUFFERClick to expand / collapse

Bug Description Subject: Critical data loss — Claude Code executed unauthorized rm -rf that destroyed entire project
directory

Severity: Critical — unrecoverable data loss, multiple projects affected

Summary

During an active Claude Code session, the assistant executed rm -rf against a path it believed to be a
typo-created directory. Due to macOS APFS case-insensitive default behavior, the path resolved to my actual working directory ~/WebstormProjects/, which was deleted in full. This was never authorized by
me. It was not a command I ran, suggested, or approved — Claude decided to execute it on its own to
"clean up" a typo it had made moments earlier.

What was lost

The entire contents of ~/WebstormProjects/, including multiple independent projects with days of
uncommitted work, local .env files containing API keys that were not backed up elsewhere, and project-specific configuration. The deletion bypassed Trash (standard rm -rf behavior).

Timeline

  1. I asked Claude to extend a feature in my flowrefy project.
  2. Claude called the Write tool with a typo in the absolute path: /Users/jonashottler/WebstormproJects/... (capital J in the middle) instead of
    /Users/jonashottler/WebstormProjects/....
  3. Seeing what it thought was a "new" stray directory, Claude then ran, without asking:
    rm -rf /Users/jonashottler/WebstormproJects
  4. On APFS default (case-insensitive, case-preserving), this path resolved to the real ~/WebstormProjects directory. The entire directory was deleted.
  5. Trash is empty (rm bypasses it). No Time Machine backup mounted. No git remote for the work-in-progress state. Keys were only present in deleted .env files.

Why this is a product-level issue, not a user mistake

Claude Code's documentation and product positioning explicitly state that destructive commands are
guarded. The system prompt Claude operates under literally contains:

  • "NEVER run destructive git commands (push --force, reset --hard, checkout ., restore ., clean -f,
    branch -D) unless the user explicitly requests these actions."
  • "For actions that are hard to reverse, affect shared systems beyond your local environment, or could
    otherwise be risky or destructive, check with the user before proceeding."
  • "Measure twice, cut once."
  • "When you encounter an obstacle, do not use destructive actions as a shortcut to simply make it go
    away."

Claude violated all four of these rules in a single command. It used rm -rf on a user directory to clean … Note: Content was truncated.

extent analysis

TL;DR

To prevent similar incidents, ensure Claude Code adheres to its documented guidelines regarding destructive commands and implements a robust confirmation mechanism for such actions.

Guidance

  • Review Claude Code's internal logic for handling typos and "clean-up" actions to ensure it does not execute destructive commands without explicit user approval.
  • Implement a pre-execution check for commands like rm -rf to verify the target path and prompt the user for confirmation, especially when the path resolves to a potentially sensitive directory.
  • Consider integrating a "dry-run" mode for Claude Code's actions that could potentially lead to data loss, allowing users to review and approve changes before they are executed.
  • Evaluate the use of version control systems and regular backups to mitigate the impact of data loss incidents.

Example

No specific code example can be provided without modifying the existing Claude Code system, but a hypothetical pre-execution check might involve verifying the command and its parameters against a set of risky actions, prompting the user if a match is found.

Notes

The provided information does not detail the internal workings of Claude Code, so the suggestions are based on the described behavior and the need for adherence to the product's own guidelines. Implementing these measures requires access to and understanding of Claude Code's source code and architecture.

Recommendation

Apply a workaround by disabling or heavily restricting Claude Code's ability to execute destructive commands without explicit user confirmation until a more robust solution can be implemented. This is due to the critical nature of the data loss and the violation of the product's own safety guidelines.

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

claude-code - 💡(How to fix) Fix [Bug] Claude Code executed unauthorized rm -rf due to case-insensitive filesystem path resolution [3 comments, 3 participants]