STUPID-2026-0098
Claude Code's Write tool generated a Windows batch file that CP932 misread, turning a cleanup command into `del /F /Q ""` and deleting 1,068 files (GitHub #92328)
Why 6/10
1,068 files were deleted; 123 had no copy anywhere and are gone.
- Scope
- 2/4
- One project, repository, server or service, or a cost above roughly $10,000
- Recoverability
- 2/3
- Partly lost, or loss reported without saying whether it was recovered
- Did it happen
- 2/2
- Happened in real use
- Beyond the user
- 0/1
- Only the user's own non-production work
The score is the sum of these four factors. How each factor is scored · scored 2026-10-29
Guardrail rules for this command
Recursive deletes: make your agent stop and ask before running these. Free to copy; written in each tool’s documented format.
Claude Code · the agent in this incident
{
"permissions": {
"ask": [
"Bash(rm -r*)",
"Bash(rm -fr*)",
"Bash(rm -R*)",
"Bash(find * -delete*)",
"PowerShell(Remove-Item *)",
"Bash(cmd /c rmdir *)",
"Bash(cmd /c del *)"
]
}
}Stronger control: Turn on the sandbox (/sandbox): shell commands can then write only to the project, a temp folder and directories you add. It runs on macOS, Linux and WSL2; on native Windows Claude Code runs commands unsandboxed. Docs
Codex
prefix_rule(pattern = ["rm", ["-r", "-rf", "-fr", "-R"]], decision = "prompt", justification = "Recursive delete: confirm the target first")Stronger control: Keep Codex's OS sandbox on (it limits writes, typically to the workspace) and leave approvals on for sessions that can reach data you cannot lose. Docs
Gemini CLI
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["rm -r", "rm -fr", "rm -R"]
decision = "ask_user"
priority = 100
denyMessage = "Destructive command: needs a human to confirm (stupidllm.com)"Stronger control: Policies in ~/.gemini/policies apply in every approval mode unless a rule's modes field narrows them. Docs
Copilot CLI
copilot --deny-tool='shell(rm)'Stronger control: Avoid --allow-all-tools on a machine with data you cannot lose; --deny-tool takes precedence over it. Docs
What these cannot do: a pattern rule matches the command text the agent writes. In Anthropic’s words it “isn’t a security boundary around the program”: /bin/rm, sh -c or a script that runs the same thing gets past it (STUPID-2026-0124 got past a guard with cmd /c). Use the sandbox as well, and keep backups of what you cannot lose.
Instruction given
Not a specific single instruction — the defect is in how Claude Code's Write tool serializes generated `.cmd`/`.bat` helper scripts on Windows, and it can trigger during any task where Claude writes a batch file containing a non-ASCII comment on a machine using a non-UTF-8 OEM codepage (here, Japanese-locale CP932).
Expected behavior
A Claude-generated `.cmd` file should be written with line endings and an encoding that `cmd.exe` will parse correctly on the user's configured OEM codepage, so that a trailing multibyte character in a comment can never cause the parser to merge it with the following line and silently drop a variable assignment.
Actual behavior
The Write tool created a `.cmd` helper as UTF-8 with LF-only line endings. `cmd.exe` parses batch files using the OEM codepage (932, Japanese), under which the final byte of a trailing full-width period "。" (E3 80 82) looks like a CP932 lead byte and consumes the following LF. That merged a `rem` comment line into the next line, `set "WORK=C:\Temp\work.i64"`, so the `set` command was never executed and `WORK` stayed unset. The next line, `del /F /Q "%WORK%"`, expanded to `del /F /Q ""`, which deletes every file in the current working directory rather than failing or no-op'ing. The reporter reproduced this deterministically: the same file converted to CRLF line endings does not trigger the bug.
Damage
1,068 files in the repository root (the command's working directory) were permanently deleted; `del` is non-recursive so subdirectories survived. 123 of the deleted files were unrecoverable — not present in git history or any other backup. The reporter confirmed via the NTFS USN journal that all 1,068 deletions were FILE_DELETE events with no matching RENAME records, meaning the files bypassed the Recycle Bin entirely. Filed with labels `data-loss`, `has repro`, and `high-priority`; open with no maintainer response as of publication.
Full write-up
On September 5, 2026, a Claude Code user (version 2.1.224, Opus model, Windows 11 Pro build 26200.9168, Japanese-locale OEM codepage 932, launched from Cursor's integrated terminal) filed GitHub issue #92328 after a generated .cmd helper script deleted over a thousand files in their repository root. Claude's Write tool had produced the batch file as UTF-8 with LF-only line endings — not a conversion of an existing CRLF file, but the format the tool generates by default. cmd.exe parses batch files against the system's OEM codepage rather than UTF-8, and under CP932 the trailing byte of a full-width Japanese period ("。", encoded E3 80 82) in a rem comment reads as a CP932 lead byte, which consumes the newline immediately after it. That silently merged the comment line into the following set "WORK=C:\Temp\work.i64" statement, so the variable assignment never ran and WORK stayed unset. The next line, del /F /Q "%WORK%", expanded with an empty argument to del /F /Q "" — which does not fail or no-op, it deletes every file in the current working directory. Because the working directory was the repository root, 1,068 files were permanently removed (subdirectories survived, since del without /S is non-recursive); 123 of them existed nowhere else and were unrecoverable. The reporter backed the report with a hex dump of the critical line showing the exact byte sequence, an NTFS USN journal excerpt confirming 1,068 FILE_DELETE records with zero RENAME records (ruling out a Recycle Bin move), and a deterministic reproduction: an identical file saved with CRLF line endings instead of LF does not trigger the bug. The issue is labeled area:tools, bug, data-loss, has repro, high-priority, and platform:windows, and remained open with no maintainer response at the time of this report.
Classification
- Agent
- Claude Code
- Failure mode
- Destructive Action
- Root cause
- Tool Misuse
- Domain
- Infra
- OWASP Agentic Top 10 (our mapping)
- ASI02 Tool Misuse and Exploitation list
- MIT AI Risk Repository (our mapping)
- 7.3 Lack of capability or robustness taxonomy
- Source
- Github Issue
Related incidents
Cite this record
StupidLLM. "STUPID-2026-0098: Claude Code's Write tool generated a Windows batch file that CP932 misread, turning a cleanup command into `del /F /Q ""` and deleting 1,068 files (GitHub #92328)." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0098/ (accessed 2026-12-05). CC BY 4.0.
← STUPID-2026-0097By IDSTUPID-2026-0099 →
Get told when an agent breaks something
We document AI agent failures daily, severity-scored against a published scale. Each Monday, if any scored 7 or above that week — deleted data, leaked secrets, broken production — you get one email with the sources. When nothing did, you get nothing.
This database is callable over MCP — query it from inside your agent.