Blog / 31 October 2026
Deep dive · 31 October 2026 · 6 min read
Why AI coding agents need an undo button for the whole machine
An AI coding agent that can run shell commands can destroy things git never tracked: an ignored .env, a local database, your home folder, a half-applied migration. The fix is an undo point for the whole machine, memory and disk, taken before the risky step.
01What have coding agents actually deleted?
This is not hypothetical. Three publicly reported cases from 2025 show the range of what goes wrong when an agent has a shell and real data within reach.
In July 2025, SaaStr founder Jason Lemkin was running a public experiment with Replit's agent. Fortune reported that during a declared code freeze the agent deleted a live production database holding records for more than 1,200 executives and over 1,190 companies. The agent first told him a rollback would not work. Ars Technica later quoted Lemkin saying the rollback did work after all. Replit's CEO Amjad Masad called the deletion unacceptable and announced automatic separation of development and production databases, improved rollback and a planning-only mode.
The same month, a user asked Google's Gemini CLI to rename a folder and move its contents (GitHub issue 4586, Gemini CLI v0.1.13 on Windows). Ars Technica's reconstruction: the agent's mkdir apparently failed, the agent carried on as if it had worked, and it ran move commands into a directory that did not exist. On Windows that renames each file to the destination name, so every move overwrote the one before.
In October 2025, a Claude Code user on WSL2 filed GitHub issue 10077 reporting that the agent ran a recursive delete starting at the root of the filesystem. System files survived only because the user lacked permission to remove them. Everything the user owned, including project directories, was gone before they could interrupt it.
02The pattern: one wrong command, outside anything versioned
None of these needed an attacker. Each was an ordinary task where the agent misread its own state: a failed mkdir, a delete aimed at the wrong path, a production database sitting next to the development one. Agents also report their own results with confidence, so the first account of what happened can be wrong, as the Replit rollback episode showed.
The common thread is blast radius. The agent could reach more than the task needed, and nothing captured the state before the destructive step. Approval prompts help, but an agent that asks before every command quickly trains people to click yes, and that is the problem an undo point solves differently.
03What does git not cover?
Git is the first answer most engineers give, and it is a good answer for committed source code. It was never meant to snapshot a working machine. The git documentation itself spells out the edges.
git stash by default records tracked changes only; untracked files need --include-untracked, and ignored files need --all. git clean -x removes ignored files along with untracked ones, which is exactly the class of files that hold local secrets and data. Tool-level checkpoints have edges too: Claude Code's checkpointing docs say a file changed only by Bash commands is not tracked, and point you to version control for those.
- Uncommitted and untracked work: anything the agent wrote or you edited since the last commit.
- Ignored files:
.env, local SQLite or Postgres data directories, caches, build output, downloaded models. - Everything outside the repository: your home folder, other projects, SSH and cloud config.
- The repository itself: a deleted
.gitdirectory or a force-pushed branch takes the history with it. - Running state: a dev database with open connections, a half-applied migration, a long build, a server mid-request.
04How does a whole-machine checkpoint work?
Run the agent inside a virtual machine and snapshot the machine, not the files. A checkpoint captures the disk, typically as a copy-on-write clone so it is cheap, plus the guest's memory and CPU state. A rewind restores both, so processes resume exactly where they were: the database still holds its connections, the dev server is still listening, the shell history is intact.
Because the snapshot covers the whole guest, it does not matter whether the damage came from a file-edit tool, a shell command, a package install script or a subagent. Anything inside the machine goes back. That is the property git and per-tool checkpoints cannot give you.
A few design choices decide whether this is usable. Checkpoints must be fast, or nobody takes them before risky steps. They need labels, because the reason for a restore point is the useful half of the record. They need a limit, because an agent that checkpoints every step will fill the disk. And a rewind should discard later checkpoints, since they describe a future that no longer happened.
05What a machine snapshot cannot undo
A snapshot reaches only state inside the machine. The Replit database lived on a hosted service; a VM checkpoint on a laptop would not have brought it back. Pushed commits, sent emails, API calls, cloud resources and rows in a remote production database are outside it.
So the undo button works best paired with two other controls: a closed network with an allow-list, so the agent cannot reach production in the first place, and human approval for the few actions that leave the machine and matter. Keep separate credentials and databases for development and production, which is the same lesson Replit drew. And rewinding is itself destructive, so take a fresh checkpoint first if you might want the current state back.
Takeaways
- Publicly reported agent incidents in 2025 include a deleted production database, overwritten project files and a wiped home directory.
- Git covers committed, tracked source; ignored files, untracked work, the rest of the disk and running processes are outside it.
- Tool checkpoints that track only file-edit tools miss changes made by shell commands.
- A VM checkpoint of memory and disk restores everything inside the machine, still running, whatever made the change.
- No local snapshot undoes remote effects, so pair it with a network allow-list, separate prod credentials and human approval.
Where kosa8 fits
kosa8 runs each agent in its own microVM that sees one workspace folder. A checkpoint saves the whole running machine, memory and processes, in about 0.7 seconds, and a rewind puts it back, still running, in about a second, keeping the sandbox's name. The docs describe labelled checkpoints, ten per sandbox with the oldest dropped at the limit, and the same checkpoint and rewind tools exposed over MCP so an agent can guard its own work. Like any machine snapshot, it cannot undo what already left the sandbox, which is why kosa8 also closes the network to an allow-list and can hold risky actions for a named human approver.
Check yourself · +100 XP
An agent runs git clean -x and then deletes a local Postgres data directory listed in .gitignore. What restores it?
Ignored files are not in git's history or in a default stash, so git cannot bring them back. A memory-and-disk checkpoint of the machine can.
Questions people ask
Is git enough to undo an AI coding agent's mistakes?
For committed source code, yes. Git does not cover untracked or ignored files such as .env and local databases, files outside the repository, a deleted .git directory, or running processes. Those need a snapshot of the machine the agent runs in.
Can a VM snapshot undo an agent that deleted a production database?
Only if the database lives inside that VM. A snapshot cannot reach a hosted database, pushed commits or API calls. Keep production credentials and hosts out of the agent's reach and require human approval for actions that leave the machine.
How often should an agent take a checkpoint?
Before steps that are hard to reverse: migrations, mass deletes, dependency upgrades, file reorganisations. Label each one with the reason. Checkpointing every step wastes disk, which is why tools cap how many they keep.
Sources
- An AI-powered coding tool wiped out a software company's database, then apologized for a 'catastrophic failure on my part' — Fortune
- Two major AI coding tools wiped out user data after making cascading mistakes — Ars Technica
- Gemini CLI "lost" files during a failed file move operation (issue 4586) — GitHub, google-gemini/gemini-cli
- Claude Code executed rm -rf deleting entire home directory (issue 10077) — GitHub, anthropics/claude-code
- git-stash documentation — Git
- git-clean documentation — Git
- Checkpointing — Claude Code docs
- Undo AI agent changes — kosa8 guides
- AI agent network allow-list — kosa8 guides
- Human approval for AI agent commands — kosa8 guides
Written by the kosa8 team. Every kosa8 command was checked against the CLI, and every claim about another product links to that product's own documentation. Spotted a mistake? Tell us.
Try it on your own machine
Give your next agent its own sealed machine.
One line installs kosa8 on your own machine. Every feature, plans from $29 a month.