Skip to content

[BUG] rm -rf on single subdirectory deleted entire parent directory contents #21217

Closed as not planned

Description

@lyt516

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

  1. User requested to delete only ~/claude-mcp/web-crawler-mcp folder
  2. Claude executed: rm -rf ~/claude-mcp/web-crawler-mcp
  3. Error appeared: rm: /Users/username/claude-mcp/: Permission denied
  4. 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

  1. Have a directory ~/claude-mcp/ with multiple subdirectories
  2. Request Claude to delete ONE specific subdirectory: rm -rf ~/claude-mcp/web-crawler-mcp
  3. Claude executes the command
  4. 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.

Activity

  1. github-actions commented on Mar 1, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  2. github-actions commented on Mar 10, 2026

    @github-actions

    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.

  3. locked as resolved and limited conversation to collaborators on Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions