AI Project Guardian AI Project Guardianby VoxCaption
Guide · AI coding

An AI agent broke my code: 5 ways to get it back

By the VoxCaption team · updated · 6 min read

Short answer: if the change is not committed, run git checkout -- file. If the agent already committed, find the good state with git reflog. If you have no git, use your editor's local history. The surest way is a tool that saves your whole project every few minutes outside git, so you can press Restore on the last version that worked.

Windows 10 & 11 · 14 days free · then $20 a year

AI Project Guardian Versions: every saved version with Check it, Pick files and Restore

Fastest way back, step by step

  1. Stop the agent. Do not let it "fix" the damage on your only copy.
  2. Save the broken state first (a commit or a saved version), so a failed repair cannot make it worse.
  3. Find the last version that worked: git reflog, your editor's Timeline, or the History list in AI Project Guardian.
  4. Restore only the damaged files, and keep the good changes the agent made.
  5. Run the project and test the part that broke before you go on.

1. Git: works if you committed

Not committed yet: git checkout -- path/to/file brings one file back. Everything: git stash (can be undone) or git reset --hard (cannot).

Agent already committed: git reflog lists every earlier state; reset to the one before the damage. The hard part is finding it among many "update files" commits the agent wrote.

2. Your editor's local history

VS Code has Timeline (right-click a file) and JetBrains has Local History. They keep older copies of each file even without git. Limits: one file at a time, short history, and edits made from a terminal may be missing.

3. Ask the AI to undo it, carefully

Tell it exactly what broke: "Login worked before your last change to auth.js. Compare and restore it." This works while the same chat is open. A new chat does not know what "before" was, so it guesses. Save the broken state first.

4. Windows File History or cloud version history

If File History, OneDrive or Google Drive version history was on, you can pull back older copies file by file. It is slow and covers only synced folders. Keep it as the last resort.

5. Automatic saved versions made for AI coding

AI Project Guardian saves your whole project every 5 minutes and on changes, kept private on your own PC and apart from your project, so an agent cannot rewrite it. Compare any two versions, and restore one file or the whole project in one click. How to undo Claude Code, Codex or Cursor changes →

AI Project Guardian main screen: your project is saved, Go back one version, Save a version now

Questions

Can I get back files the AI deleted?

Yes: from git if they were committed, from your editor's local history, or from a saved version in AI Project Guardian, which brings deleted files back with a normal Restore.

Does saving every 5 minutes slow the computer down?

No. It saves only when something changed, and you can change the timing in Settings.

Do I need to know git?

No. AI Project Guardian works without git: you see a list of versions and press Restore.

Does my code leave my computer?

No. Saved versions stay private on your own PC.

More guides

Never lose working code to an AI again

Automatic saved versions of your project and a one-click Restore. 14 days free, no card.

⬇ Download free