Claude Code's checkpoints don't cover shell commands. So I built undo for them
DEV Community

Claude Code's checkpoints don't cover shell commands. So I built undo for them

AI coding agents are fast. They're also fast at breaking things.

Claude Code has checkpoints, and they're great for edits made through its file tools. But they don't track files changed by shell commands. When the agent runs rm -rf, a sed -i, a codegen script or a formatter, those changes are outside what rewind can bring back.

So I built undoagent: a small CLI that turns every prompt into a checkpoint, whatever the agent used to change your files.

What it looks like

I asked Claude Code to "remove the notes folder using rm -rf and convert app.js to ES modules". It did exactly that. Then:

$ undoagent list
# time files what
1 17:44 4 Clean up this project: remove the notes folder using rm -rf…
$ undoagent diff --stat
app.js | 2 +-
notes/decisions.md | 1 -
notes/todo.md | 2 --
package.json | 3 +++
$ undoagent undo
βœ“ Undid #1: Clean up this project: remove the notes folder using rm -rf…
~ app.js + notes/decisions.md + notes/todo.md - package.json

The deleted folder is back, app.js is restored, and the package.json the agent added is gone.

What I wanted from it

  • Undo per prompt, not per file or per commit.
  • Undo an older turn and keep the later ones. undoagent undo 3 reverts only turn 3.
  • Rewind the whole project to before any turn: undoagent rewind 3.
  • Never touch my git history. No commits, no stashes, nothing staged.
  • Never overwrite my own edits. If I changed a file after the agent did, undo stops and tells me which files.

How it works

you submit a prompt β†’ snapshot A
the agent works β†’ edits, shell commands, scripts…
the agent finishes β†’ snapshot B
one turn = the difference between A and B

  • Claude Code hooks run undoagent when you submit a prompt and when the agent stops.
  • Snapshots go into a separate, hidden git repository in ~/.undoagent, pointed at your project folder. Your own .git is never read or written, and it works in folders that aren't git repos at all.
  • Because it snapshots the folder, not the agent's tool calls, it catches everything: file edits, shell commands, generated files.
  • Before undoing, it compares the files with how the agent left them. If you edited one since, it refuses unless you pass --force.
  • It respects .gitignore, skips node_modules, and has zero npm dependencies. Everything stays local.

Try it

Inside Claude Code, as a plugin:

/plugin install undoagent --marketplace Ahmed-Manai/undoagent

That adds /undoagent:list, /undoagent:undo, /undoagent:redo, /undoagent:diff and /undoagent:rewind.

Or from a terminal:

npm install -g undoagent
cd your-project
undoagent init

Then use Claude Code (or Codex, or Gemini CLI) as usual, and run undoagent list whenever you want to see or undo what it did.

What it doesn't do yet

  • It supports Claude Code, plus Codex and Gemini CLI in beta. Cursor and Copilot don't have the same hooks, so they need a file-watcher mode.
  • No VS Code UI yet; it's a CLI.
  • Files inside nested git repos (submodules) aren't snapshotted.

The code is MIT-licensed on GitHub. Issues and ideas are very welcome.

Has an AI agent ever destroyed work you couldn't get back? What happened, and what would have saved you? I'd love to hear the stories in the comments, because they shape what undoagent handles next.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.