[BUG] rm -rf on single subdirectory deleted entire parent directory contents
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?
Summary
When executing rm -rf ~/claude-mcp/web-crawler-mcp to delete a single subdirectory, almost all contents of the parent directory ~/claude-mcp/ were deleted instead.
Environment
- Claude Code Version: 2.1.3
- Platform: macOS (Darwin 24.1.0)
- Date: 2026-01-27
Steps to Reproduce
- User requested to delete only
~/claude-mcp/web-crawler-mcpfolder - Claude executed:
rm -rf ~/claude-mcp/web-crawler-mcp - Error appeared:
rm: /Users/username/claude-mcp/: Permission denied - Result: Nearly all contents of
~/claude-mcp/were deleted, not just the target subdirectory
Expected Behavior
Only web-crawler-mcp folder should be deleted.
Actual Behavior
- "Permission denied" error on parent directory
- Almost all folders inside
~/claude-mcp/were deleted - Only one unrelated folder remained
Impact
- 6 months of project files were lost
- Required full day of recovery work
Log Evidence
Session log shows the exact command was rm -rf ~/claude-mcp/web-crawler-mcp but the deletion affected the entire parent directory contents.
What Should Happen?
Only the specified subdirectory web-crawler-mcp should be deleted. Parent directory and sibling folders should remain intact.
Error Messages/Logs
rm: /Users/username/claude-mcp/: Permission denied
Steps to Reproduce
- Have a directory
~/claude-mcp/with multiple subdirectories - Request Claude to delete ONE specific subdirectory:
rm -rf ~/claude-mcp/web-crawler-mcp - Claude executes the command
- Result: Almost all contents of parent directory deleted, not just target folder
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.3
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Session ID: 997249f6-0edd-442c-a9ba-25d278244e7e
The command syntax was correct but execution affected wrong scope.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗