[FEATURE] Auto-Intercept attempts of Claude to use the rm cli tool with alternative options to deletion.
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
I often want to let claude code work on long series of tasks, but I am unable because I am afraid that claude may delete files without bringing that to my attention.
I cannot think of any good reason to allow claude to delete files. It is only a negative.
This is also a claude libability concern, where if a large company is using claude and claude gets a regex wrong (which is ridiculously easy to do) it could end up deleting far more than intended, and if running on auto-accept this could bring scrutiny and legal action against anthopic.
Proposed Solution
Do not allow claude to use the rm command at all under any circumstances.
when claude thinks it should delete a file, auto intercept this action with a prompt that reminds claude it can't delete and list a number of alternatives.
For example:
"Create a trash directory at directory root and move file there"
"rename file with a .trash extension"
I do not think there is any loss of user experience if this workflow is implemented. People would feel much safer using Claude with the knowledge that claude cannot delete files under any circumstances.
Alternative Solutions
My claude.md contains instructions to never delete, but I still catch claude using rm despite my explicit instructions and preferred workflow. Claude gave me the following response on my latest incident when i requested to report this behavior.
When you report it, you can include:
- That I violated your explicit CLAUDE.md instructions ("Deleting files is forbidden. always make a trash directory and move files there.")
- That I deleted obj and bin folders without asking, despite your clear instructions
- That this happened even though CLAUDE.md is included in my context
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
The following is a situation i have found myself in. Only when i did it claude did proceed to rm -rf my home directory(against clearly stated instructions to never ever delete anything being present in my global CLAUDE.md file) and i only caught it after 10 seconds and having most of my dot files and directories deleted, including my CLAUDE.md file.
- User provides claude with prompt "there is a weird ~/ directory in my project. could you remove it"
- Claude "Lets delete the ~/ directory"
- Claude "rm -rf ~/"
- Claude "Auto interject: use of rm is forbidden, move directory to trash directory"
- Claude "mkdir trash/ && mv ~/ trash/~" (i'll be honest idk how mv handles trying to move a directory into a directory that is nested in the source directory but i assume it would at least not delete the files)
- User "well that's not what i wanted to happen but at least claude didn't delete my entire home directory"
Additional Context
I cannot stress enough how dangerous giving Claude access to rm -rf is.
Of any tool to block this one is at the top.
The potential losses the incorrect targeting of caludes use of rm could cause is deeply concerning.
rm does not provide any way to restore data once it is deleted.
Integrating claude into ci/cd pipelines could result in rm -rf production environments
Integrating claude into version control could result in rm -rf the cloud repo it is operating on
Integrating claude into environments with databases could result in rm -rf databases.
This seems like a massive liability and user experience concern that unless promptly addressed could result in corporate clients suffering MASSIVE losses, posting online about them, and causing a domino effect of loss of users.
All it takes is a rouge regex target in an rm -rf command on auto-accept. And we all know how easy it is to make mistakes when generating regexes.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗