I lost 3 hours of work because Claude Code refactored my auth module into oblivion
I was in the zone. Claude Code was crushing it — added OAuth, hooked up the database, wired the routes. Then I said: "refactor auth.ts to use middleware instead of inline checks."
Fifteen files changed. TypeScript errors everywhere. The app wouldn't build. And I realized I hadn't committed in over an hour.
git diff showed me 400 lines of changes across 15 files. I had no idea which version of auth.ts actually worked. I spent 3 hours manually reconstructing the last working state.
That was the moment I built snaprevert.
The problem nobody talks about
Every AI coding tool — Claude Code, Cursor, Copilot, Aider — shares the same fundamental issue: there's no undo between prompts.
Each prompt touches 5-20 files. You review, prompt again, review, prompt again. You're in flow state. Nobody stops to git commit -m "checkpoint before risky refactor" between each prompt. By the time something breaks, you're 5-10 prompts deep with no checkpoint.
Git requires intent. But when you're pair-programming with an AI at 100mph, intent is the first thing that goes.
snaprevert: the undo button for AI coding
npx snaprevert watch
That's the entire setup. One command. Zero config. It silently snapshots your project every time files change. When the AI breaks something:
snaprevert list # see all snapshots with timestamps
snaprevert diff 5 # see exactly what changed in snapshot #5
snaprevert back 3 # roll back to before snapshot #3
Your project is restored in under 1 second.
How it works (it's dumber than you think)
No git. No branches. No staging area. It's filesystem-level:
- Watch — chokidar monitors your project for file changes
- Debounce — waits 3 seconds for changes to settle (groups a single AI prompt's changes)
- Diff — computes unified diffs for modified files, stores full content for new files
-
Store — saves to
.snaprevert/snapshots/{timestamp}-{id}/
That's it. Snapshots are diffs, not full copies. A full day of heavy AI coding uses <10MB.
Rollbacks are non-destructive — rolled-back snapshots are preserved. You can re-apply any of them with snaprevert restore.
The features I didn't expect to need
Per-file selective rollback — Claude broke auth.ts but user.ts is fine? Only undo what's broken:
snaprevert back 3 --only auth.ts,routes.ts
Interactive review — Walk through each file change before committing:
snaprevert review 5
# For each file: [a]ccept [r]eject [s]kip [v]iew diff
AI tool detection — Snapshots auto-detect which AI tool made the changes. You see claude: modified auth.ts or cursor: added 3 files in the labels.
Snapshot branching — Try two different AI approaches from the same checkpoint:
snaprevert fork 3 --name "approach-a"
# ... try one approach ...
snaprevert fork --switch main
# ... try another approach ...
MCP server — AI agents can create named checkpoints programmatically:
snaprevert mcp # starts JSON-RPC server
Compatible with Claude Code and any MCP client. The AI itself can checkpoint before risky operations.
Why not just use git?
I get this question every time. Here's the honest answer:
| Git | snaprevert | |
|---|---|---|
| When it saves | When you remember | Automatically |
| Granularity | Whatever you staged | Every AI prompt |
| Cognitive cost | Decide what + write message | Zero |
| Rollback | git reflog, reset, stash... | snaprevert back 3 |
They're complementary, not competing. Git is for meaningful, curated history you push to a team. snaprevert is the continuous autosave between commits — like how Google Docs saves every keystroke but you still "publish" versions.
The stack
- 3 dependencies: commander, chalk, chokidar
- 221 tests across unit, integration, and UAT
- Zero config — works with any project, any AI tool
- <100ms snapshot creation, <1s rollback
It watches your filesystem, not your AI tool. Works with Claude Code, Cursor, Copilot, Aider, Windsurf, or anything that writes files.
Try it
npm install -g snaprevert
snaprevert watch
Then use your AI tool normally. When things break: snaprevert list then snaprevert back 3.
The repo is at github.com/HadiFrt20/snaprevert. MIT licensed, 221 tests, actively maintained.
If you've ever lost work to an AI coding tool, you know why this exists.
If this helps you, a star on the repo means a lot. And if you have feature ideas, issues are open.
![[Boost]](/_next/image?url=https%3A%2F%2Fmedia2.dev.to%2Fdynamic%2Fimage%2Fwidth%3D800%252Cheight%3D%252Cfit%3Dscale-down%252Cgravity%3Dauto%252Cformat%3Dauto%2Fhttps%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Fuser%252Fprofile_image%252F3618325%252F470cf6d0-e54c-4ddf-8d83-e3db9f829f2b.jpg&w=3840&q=75)
