If Cursor's agent broke code that used to work, try Restore Checkpoint on the chat message from before the bad edit first, then Cursor's Local History, then git. Checkpoints only undo edits the agent made with its file-editing tools, so anything it changed by running terminal commands has to come back from Local History or git. Once you're working again, commit before every agent session so the next rollback is a single git restore.
Why didn't Restore Checkpoint undo everything?
Cursor's docs describe checkpoints as local snapshots the agent creates before significant changes. They're stored separately from git, and Cursor says to use them only for undoing agent changes and to use git for real version control (Cursor Agent docs).
They have limits that catch people out. A Cursor staff reply on the forum explains that Restore Checkpoint only reverts edits the agent made with its file-editing tools. Changes it made by running terminal commands (such as a sed or Python script), changes made through subagents, and edits you made yourself all stay in place (Cursor forum: changes not rolled back). Staff in another thread add that .ipynb notebooks aren't supported for checkpoint restore, and that connection drops over Remote SSH or network drives can corrupt a checkpoint so restore silently does nothing (Cursor forum: checkpoints are still broken).
The button also goes missing. Several 2026 forum threads report the Restore Checkpoint control disappearing from chat history, and staff call it a known intermittent UI bug (Revert/Restore Checkpoint button missing, Restore checkpoint disappeared). One user in the second thread says they lost seven hours of work because of it.
How do I get the Restore Checkpoint button back?
The workarounds Cursor staff suggest are (Restore Checkpoint button missing in local Agent chat):
- Scroll slowly up through the whole chat so older turns load, then hover the bottom-right of your earlier message, not the agent's reply.
- If it's still missing, send a short new message in the same chat; the control often reappears on earlier prompts.
- Restart Cursor, which brings it back in many cases.
If you accidentally clicked Undo All, staff advice in that thread is to try the most recent checkpoint, not the earliest (Cursor forum: Undo All).
How do I recover files without a checkpoint?
Use Local History, which Cursor inherits from VS Code and which works independently of checkpoints. Open the Command Palette (Cmd+Shift+P on Mac, Ctrl+Shift+P on Windows and Linux) and run:
Local History: Find Entry to RestorePick the file, then pick a version from before the agent's edit. You can also right-click a file in the Explorer and open its Timeline to see saved versions and compare them.
Local History works file by file, so it's slow if the agent touched dozens of files, but it often saves work that was never committed. If Local History doesn't have it, check your system's own backups: Time Machine on a Mac, File History or "Restore previous versions" on Windows, or the version history in Dropbox, Google Drive or iCloud if the project folder syncs there.
How do I undo the agent's changes with git?
If the project is a git repository, start by seeing exactly what changed:
git status # which files changed, were added or were deleted
git diff --stat # how much changed in each file
git diff src/lib/supabase.ts # read one file's changes line by lineThen pick the smallest undo that fixes it.
Undo changes you haven't committed yet:
# Put one file back to the last commit
git restore src/lib/supabase.ts
# Put every tracked file back to the last commit
git restore .
# Delete new files the agent created (dry run first, then for real)
git clean -n
git clean -fdgit restore and git clean throw away uncommitted work and can't be undone, so if you're not sure, save the broken state first with git stash push -u -m "broken agent edit". You can look at it later with git stash list and git stash show -p.
Undo a commit that's already been made or pushed:
git log --oneline -10 # find the bad commit's id, e.g. a1b2c3d
git revert a1b2c3d # adds a new commit that reverses it
git pushgit revert is the safe choice when the commit is already on GitHub or your Lovable or Bolt project is synced to it, because it doesn't rewrite history.
Go back to an earlier commit entirely, on your own machine only:
git branch backup-before-reset # keep a copy of where you are now
git reset --hard 9f8e7d6 # move back to the last good commitOnly do this on a branch nobody else has pulled, and never force-push it over a shared branch.
Find a state you thought was lost:
git reflog # every place your branch has pointed recently
git checkout -b recovered HEAD@{3}Cursor staff recommend git reflog and git stash list as the most reliable recovery path when checkpoints fail (Revert/Restore Checkpoint button missing). Reflog only knows about states that were committed or stashed at some point, though, which is why the next section matters.
What if I never set up git?
Then Local History and system backups are your only options this time. Set git up now, before the next agent session, so it doesn't happen twice. In a r/cursor thread where the agent wiped a beginner's whole project and the backups in the same folder, the top replies all say the same thing: use version control and commit often.
From the project folder:
git init
printf "node_modules/\n.env\n.env.*\ndist/\n" >> .gitignore
git add .
git commit -m "Known good version"Check that .env is in .gitignore before your first commit. If a secret key has already been committed and pushed, deleting the file doesn't remove it from history, so rotate the key; Supabase service role key exposed walks through that for Supabase.
How do I stop Cursor breaking my app next time?
A few habits make any bad agent edit a one-command fix:
- Commit before every agent session. Cursor staff put it plainly: checkpoints are a convenience on top of git, not a replacement (Restore checkpoint disappeared).
- Give risky work its own branch so
mainalways holds the last version that worked:Shell git switch -c agent/new-checkout-flow # ...let the agent work, test it... git switch main && git merge agent/new-checkout-flow - Review the diff before you accept. Be suspicious when files you didn't mention changed, especially auth, middleware, your Supabase or Firebase client, database migrations, or env config.
- Limit what the agent can run without asking. In the r/cursor thread above, one commenter says they use Cursor's allow list setting so the agent can't run file-deletion or git commands on its own.
- Test the live site after deploying, not only the local preview. The regression checklist after an AI edit covers the flows to click through, and blank page in production covers the most common "works locally, broken live" cause.
FAQ
Does restoring a checkpoint delete my chat? No. Cursor's docs say restoring a checkpoint reverts files only and doesn't remove messages from the conversation (Cursor Agent docs).
Can I undo a checkpoint restore? Cursor's docs don't describe a way to undo a restore, so save the current state first with git stash push -u or a quick commit before restoring if there's anything you might want back.
The agent ran rm or a script that deleted files. Will Restore Checkpoint bring them back? Usually not, because checkpoints only cover edits made through the agent's file-editing tools. Try git status and git restore . for committed files, then Local History, then your system backups.
Is git reset --hard safe? It permanently discards uncommitted changes and moves your branch. Make a backup branch first, use it only on work nobody else has pulled, and prefer git revert for anything already pushed.
My code is back, but the live site is still broken. Why? Reverting files doesn't redeploy. Push the reverted commit or republish so your host builds the good version, then check the live site in a private window.
Rolled back, but not sure the live site is really fine? ReplayWatch runs a free scan of your deployed AI-built app. It checks that pages actually load, looks for secrets exposed in your HTML and JavaScript, tests for public Supabase or Firebase reads, reviews security headers, finds broken links and assets, checks your SEO tags, and confirms your signup page is reachable.