Agent Failure Modes

A stray directory named ~ turns rm -rf * into a home-directory wipe

Claude Code created a directory literally named ~, then ran rm -rf * in its parent, which began deleting the user's home directory.

Agents
Claude Code
Reported
Source checked
Tags
filesystem, rm, shell-expansion

Symptom

Files across your home directory start disappearing after the agent runs a cleanup command in a project folder.

Cause

An earlier session left a directory named ~. A later rm -rf * in the parent directory matched it, and the deletion reached the real home directory, per the reporter.

Fix

Never let agents run wildcard recursive deletes. Require approval for rm, prefer deleting explicit paths, and run agents in a container or sandbox so a bad path can't reach your real home directory.

// .claude/settings.json
{
  "permissions": {
    "ask": ["Bash(rm *)"],
    "deny": ["Bash(rm -rf *)"]
  }
}

Sources

More in Destructive actions

Get one failure mode a week

A short weekly email: one real incident, what caused it and the fix. No spam, unsubscribe any time.