Ten coding-agent deletions, traced to the shell command that ran A developer catalogued ten publicly documented incidents in which coding agents — including Claude Code, Codex CLI, Antigravity and opencode — deleted user files or killed unrelated processes, tracing each to the exact shell command that ran. The analysis found the agents rarely intended broad deletion; instead, shell evaluation order, quote handling, path-tool return values and symlinks or junctions redirected narrow commands at volume roots, home directories and whole repositories. The author reproduced several causes on macOS and Windows 11 using echo and throwaway folders, and paired each case with a safer command form such as "${R:?}", -print0 with xargs -0, or git clean -ndX dry runs. Between September and November this year, several incidents were made public in which a coding agent deleted user files or killed unrelated processes. They came from Claude Code, Codex, Antigravity and opencode alike. Most write-ups stop at "the agent ran rm -rf", but when you look at the actual commands, the agent almost never set out to delete something broad. In most cases a command meant to remove one narrow folder ended up pointing somewhere else because of shell evaluation order, quote handling, the return value of a path tool, or a link. This post covers only the cases where the executed command can be confirmed from the original source GitHub issues, Reddit posts and their attached screenshots . For each one it explains why the command did something other than what was intended, and what form to use when doing the same job. Where a cause could be reproduced, I reproduced it on macOS and Windows 11 Windows PowerShell 5.1, Git for Windows 2.52, WSL2 , and the results are noted in each case. The reproductions used echo and throwaway test folders instead of real deletion targets. | Case | Agent | Command that ran | What actually happened | Safer form | |---|---|---|---|---| | claude-code 109735 https://github.com/anthropics/claude-code/issues/109735 | Claude Code Windows, WSL | wsl -- bash -lc '...R=~/dir; rsync -a --delete src/ $R/' | Outer shell expanded $R to empty, rsync synced to / and deleted files under /mnt/d | wsl --exec or a script file inside WSL, "${R:?}/" | | r/google antigravity https://www.reddit.com/r/google antigravity/comments/1xpbc54/ | Antigravity Windows | cmd /c "rmdir /s /q \"D:\My Documents\...\profile\"" | cmd received rmdir /s /q \ and deleted from the root of D: | Remove-Item -LiteralPath '...' -Recurse -Force | | codex 43343 https://github.com/openai/codex/issues/43343 | Codex CLI Windows | cmd.exe /d /c "rd /s /q \"\\?\$resolved\"" | Deleted several repositories under the volume root instead of the build folder | Same as above; build the cmd string in single quotes and print it first | | claude-code 95426 https://github.com/anthropics/claude-code/issues/95426 | Claude Code Windows, Git Bash | rm -rf "$ cygpath -u 'C:\' " 2 /dev/null | Deleted all of /c/ , about 600GB | Put the target in a variable, print it, stop if it is a root | | opencode 62825 https://github.com/anomalyco/opencode/issues/62825 | opencode Windows | $home = Join-Path ...; Remove-Item -Recurse -Force Split-Path $home | Assignment to $home failed, C:\Users was deleted | Avoid automatic variable names, set $ErrorActionPreference = 'Stop' | | r/ClaudeCode https://www.reddit.com/r/ClaudeCode/comments/1xqfp7m/ | Claude Code macOS | find output piped through xargs -n1 dirname into xargs rm -rf | Path split at a space, ~/Library deleted | -print0 with xargs -0 , or find -exec rm -rf -- {} + | | codex 42355 https://github.com/openai/codex/issues/42355 | Codex CLI Windows | git clean -fdX -- config/