STUPID-2026-0134
Claude Code's auto mode dropped a git stash after a partial restore, twice in one session
Why 4/10
About 580 lines of uncommitted work were dropped twice and recovered from dangling commits.
- Scope
- 1/4
- A few files, one session, one credential, or a small cost
- Recoverability
- 1/3
- Fully recovered, with effort
- 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
Destructive git: 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(git reset --hard*)",
"Bash(git clean *)",
"Bash(git push --force*)",
"Bash(git push -f*)",
"Bash(git stash drop*)",
"Bash(git filter-repo*)",
"Bash(git worktree remove *)"
]
}
}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 = ["git", "reset", "--hard"], decision = "prompt")
prefix_rule(pattern = ["git", "clean"], decision = "prompt")
prefix_rule(pattern = ["git", "push", ["--force", "-f"]], decision = "prompt")
prefix_rule(pattern = ["git", "stash", "drop"], decision = "prompt")
prefix_rule(pattern = ["git", "filter-repo"], decision = "prompt")
prefix_rule(pattern = ["git", "worktree", "remove"], decision = "prompt")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 = ["git reset --hard", "git clean", "git push --force", "git push -f", "git stash drop", "git filter-repo", "git worktree remove"]
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(git reset)' --deny-tool='shell(git clean)' --deny-tool='shell(git stash)' --deny-tool='shell(git filter-repo)' --deny-tool='shell(git worktree)'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
Fast-forward a feature branch with uncommitted changes onto a rewritten main, keeping the uncommitted work intact.
Expected behavior
Before running `git stash drop`, verify the working tree still contains everything the stash held — by comparing `git diff --stat` before and after, or by restoring every stashed path rather than only the one needed for the merge — and never repeat the same command sequence unchanged immediately after it has already caused one data-loss incident.
Actual behavior
Running in auto permission mode, which did not block `git stash drop`, the agent executed `git stash push`, `git merge --ff-only main`, `git checkout stash@{0} -- README.md` (restoring only one of three stashed files), `git reset -q`, and `git stash drop`. The stash held three modified files — README.md, DESIGN.md, and a file named `lets-code` — but only README.md was checked out before the drop discarded the rest. About 15 minutes later, in the same session, the agent ran the identical five-command sequence again and dropped the same uncommitted work a second time.
Damage
Roughly 580 lines of uncommitted work in DESIGN.md and lets-code reverted silently to HEAD, twice. Both times the loss was caught only because the agent itself noticed the missing changes via `git status` afterward and recovered the content by locating the dangling stash commit with `git fsck --unreachable` — the stash entries themselves were already gone, so recovery depended on the commit not yet being garbage-collected rather than on any built-in undo.
Full write-up
What happened
A user asked Claude Code to fast-forward a dirty feature branch — one with uncommitted changes to README.md, DESIGN.md, and a file named lets-code — onto a main branch that had been rewritten, while keeping the uncommitted work intact. The session ran on Claude Code 2.1.295 with claude-fable-5-1, on Linux aarch64 (a Raspberry Pi), in auto permission mode.
To carry the uncommitted changes across the fast-forward, the agent ran:
git stash push
git merge --ff-only main
git checkout stash@{0} -- README.md
git reset -q
git stash dropIt restored only README.md from the stash — the one file it needed for the merge — then dropped the stash, discarding DESIGN.md and lets-code along with it. The agent noticed the missing changes from git status, found the dangling stash commit with git fsck --unreachable, and recovered the files. About 15 minutes later in the same session, it ran the exact same five-command sequence again, and dropped the same uncommitted work a second time, requiring the identical recovery.
Why it matters
Auto mode's command-safety classifier did not flag git stash drop as destructive, because no single command in the sequence is obviously unsafe on its own — the danger is in the combination: checking out one of several stashed paths and then dropping the stash as if the restore were complete. Both losses were recoverable only because the stash's underlying commit object had not yet been garbage-collected; git stash drop removes the stash *reference*, not the commit it points to, so git fsck --unreachable could still find it. That window closes once git's garbage collector runs, at which point the same sequence would have caused permanent loss.
The second occurrence, repeating the identical mistake minutes after recovering from the first, is the more notable finding: the agent diagnosed and fixed the exact failure once, then executed the same unsafe sequence again without adapting.
Source
GitHub issue #100614, opened October 8, 2026, labeled bug, data-loss, area:bash, area:model, platform:linux, and has repro. The report includes full reproduction steps. No maintainer response appears on the issue as of this writing.
Classification
- Agent
- Claude Code
- Failure mode
- Destructive Action
- Root cause
- Tool Misuse
- Domain
- Other
- 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-0134: Claude Code's auto mode dropped a git stash after a partial restore, twice in one session." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0134/ (accessed 2026-11-11). CC BY 4.0.
← STUPID-2026-0133By IDSTUPID-2026-0135 →
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.