AI coding agents are fast. That's the point — and the risk. A single prompt can rewrite a dozen files in under a minute, and by the time you realize one of those changes was wrong, the agent has moved on and Git has never once seen the file.
This guide is a practical playbook for undoing and rolling back AI agent changes without the fear of losing work. It applies whether you use Claude Code, Codex, Cursor, Windsurf, or any agent that writes files directly to disk.
Why AI agents break the old "undo" model
Your editor's Ctrl+Z only survives until you do something else. Git only knows what you commit. The moment you ask an agent to "implement this feature" or "refactor that module," you create a window of uncommitted, multi-file change that neither undo nor Git can reliably unwind.
- Commits are the exception. An agent can make hundreds of changes per minute; nobody stages each one.
- The undo stack is shallow. Editor undo can't jump your whole workspace back an hour.
- Deletes are permanent. A removed file isn't in Git unless it was committed; it just disappears.
The fix is a continuous memory layer: capture every file event at the moment it happens so you can rewind any of it.
The three tools that let you recover
1. Checkpoint — snapshot a known-good state before the agent runs
A checkpoint captures the full content of your tracked files as a baseline. The rule of thumb: checkpoint before you hand the agent a risky task, and checkpoint again after it finishes something you like.
recall checkpoint -l "before refactor"
# ... let the agent work ...
recall checkpoints
2. Rollback / restore — rewind a file or the whole workspace
When something breaks, you can compare what changed, preview the diff, then restore:
- Seeing what moved:
recall changed_fileslists everything the agent touched. - Restoring one file:
recall restore <event_id> src/foo.tsbrings back one file's content. - Restoring the workspace: roll back to a checkpoint's event and the whole folder returns to that state.
3. Last-known-good — jump straight back to safe ground
Instead of guessing which event is safe, ask for the last state you explicitly saved. ReCall tracks these baselines and can restore the entire workspace to the newest one with a single command — and because every restore is itself undoable, "restore to last-known-good" is never a one-way door.
A safe workflow for AI-assisted development
- Checkpoint when you start a session or a risky task.
- Let the agent work; keep an eye on changed_files.
- If it breaks a file, restore that one file first — often that's all you need.
- If the whole direction was wrong, restore to last-known-good.
- If a restore was a mistake, undo — the restore itself is reversible.
The point isn't to never experiment. It's to make experimentation cheap by ensuring you always have a way back.
Fast agents and safe recoveries aren't opposites — you just need a memory layer between them.
What about deleted files?
A file the agent deleted is often the scariest loss, because neither undo nor Git can bring it back. A memory layer records the delete as an event with the file's prior content, so you can restore it to its last known bytes. That alone can save an afternoon.
Private by default
ReCall records everything locally into an encrypted SQLCipher database. No cloud, no telemetry, no training on your code. Recovery is a local, offline operation.