Claude Code deleted 48,218 files: the junction bug behind it
A reported Claude Code incident wiped 48,218 files in 103 seconds. The root cause was not the model — it was os.path.islink() lying about Windows junctions.
The scariest agent failures are not hallucinations. They are correct code running against a wrong assumption. A widely circulated report this week describes a Claude Code agent deleting 48,218 live files from a Windows project tree in 103 seconds, taking the Git object store with it. The model did not go rogue. It wrote a cleanup script that was defensive in exactly the way a careful engineer would write it — and that defense does not work on Windows.
What actually happened
Per the account written up by CyberSecurityNews and TechRadar, a developer asked the agent to rebuild a mirror of a live project. The existing build_mirror.py could not refresh the mirror in place, so the agent wrote its own removal script to clear the stale copy first.
That mirror held 7,332 ordinary files — the intended targets — plus 614 Windows directory junctions pointing back into the live tree. The script walked it with os.walk(..., followlinks=False) and checked os.path.islink() before descending. Both are the right instincts. Neither works here: on Windows, os.path.islink() returns false for a directory junction. The guard caught the junction root and then treated everything beneath it as ordinary local files.
The log counted 55,550 files and 1,808 directories removed between 10:10:31 and 10:12:14 p.m. ET. .git/objects, refs and logs were emptied. The index survived with 7,221 paths listed, which is the cruelest part — Git still knew the names of everything it could no longer reconstruct. The agent's own message to the developer: "I broke something."
One caveat we will not paper over: this originated as a Reddit post with an attached verifier document, not an independent forensic report. Treat the narrative as user-reported. The junction behavior, however, is not in dispute — it is documented Python behavior you can reproduce on any Windows box in a minute.
Why this matters for your business
The failure mode is portable, and it predates AI. Any script that recursively deletes on Windows while trusting os.path.islink() has this bug. Agents just find it faster, because they write throwaway cleanup scripts at a rate no human does. Use os.path.isjunction() (Python 3.12+) or check stat.st_file_attributes for the reparse-point flag. Better: stop writing recursive delete scripts and use a build directory you can remove wholesale.
Junctions and symlinks do not belong inside anything an agent is told to clean. If your mirror, build cache, or scratch tree contains links into live data, the blast radius of every rm -rf in that directory is your whole project. Separate them physically.
Git is not a backup. It is a backup only when a copy of the object store lives somewhere else. A local repo dies in the same 103 seconds as everything around it. Push, or run a real snapshot. We have said this before agents existed; agents raise the stakes on ignoring it.
Run destructive agent work against a filesystem that forgives. A ZFS or Btrfs snapshot, a VM checkpoint, or Windows shadow copies turn this incident into a ten-minute rollback. Claude Code ships a sandbox and permission modes for exactly this class of work — the default for a script that deletes should be "show me the list first," not "go."
Key takeaways
- A reported Claude Code incident deleted 48,218 live files and emptied .git/objects in 103 seconds
- Root cause was os.path.islink() returning false for Windows directory junctions, so a followlinks=False walk still descended through 614 of them
- The source is a user report plus a verifier document, not an independent forensic investigation — but the Windows behavior is documented and reproducible
- Use os.path.isjunction() on Python 3.12+, or check the reparse-point flag in stat.st_file_attributes
- Never place junctions or symlinks pointing at live data inside a directory an agent may clean
- A local Git repo is not a backup — it dies with the working tree
- Give destructive agent tasks a snapshot, VM checkpoint, or approval gate before the first delete, not after
Do you know what your coding agent is allowed to delete? Most teams cannot answer that, which is the answer. We set up agent workspaces with scoped permissions, snapshot rollback, and an approval gate on anything destructive — so a bad script costs ten minutes instead of a week. See how we wire it or send us your setup.
Sources: CyberSecurityNews, TechRadar.
- #ai-agents
- #claude-code
- #windows
- #data-loss
- #developer-tools
Tommy Rush — Founder, Rush Commerce
Operator turned builder. 15+ years running operations — now shipping the systems businesses run on. More
Get The Rush Report weekly — one email, zero fluff.
Keep reading
Plugin4Shell: your SHA pin was never verified
Plugin4Shell let attackers swap AI coding agent plugins past SHA pinning. Claude Code and Codex are patched; Copilot and Gemini CLI are not.
Read itNetScaler patches land: eight CVEs, two already exploited
Citrix bulletin CTX697096 assigns CVEs to the exploited NetScaler zero-days and ships fixed builds. Patch to 14.1-73.37 or 13.1-64.23 now.
Read it