Fix: Cursor Broke Code That Was Working Fine
Quick Answer
Press Cmd+Z (undo) repeatedly in each affected file to revert the changes. If that doesn't work, use git diff to see what changed and git checkout -- <file> to restore specific files.
Quick Fix Summary
| Issue | AI broke my working code |
| Fastest fix | Undo immediately |
| Use this page if | A feature that was working now throws errors after Cursor edited it |
Symptoms
- !A feature that was working now throws errors after Cursor edited it
- !Cursor changed files you didn't ask it to modify
- !Styling broke after an unrelated AI edit
- !Database queries stopped working after Cursor refactored
Step-by-Step Fix
Undo immediately
Press Cmd+Z (Mac) or Ctrl+Z (Windows) in each file Cursor modified. Keep pressing until the file returns to its working state. Check each file Cursor listed as changed.
Use Git to restore files
Run git diff to see all changes. To restore a specific file: git checkout -- src/app/page.tsx. To restore everything: git checkout -- . (careful — this reverts ALL uncommitted changes).
Commit before every AI edit
Before asking Cursor to make changes, commit your working code: git add -A && git commit -m 'working state before AI edit'. This gives you a safe restore point.
Use Cursor's edit review
After Composer makes changes, review every file in the diff view before accepting. Reject changes to files that shouldn't have been modified.
Frequently Asked Questions
Commit before every AI edit, review all changes before accepting, and use @file to limit which files Cursor can modify. Never let it edit files you didn't explicitly include.
Yes. In your prompt, add: 'Do NOT modify any files except [specific file]. Leave everything else unchanged.' Cursor follows these instructions most of the time.
Related
Weekly Signals
Get the next fix, switch, or warning before it hits your build.
Join builders getting the community signals, fix patterns, and tool shifts that matter before they show up everywhere else.
Follow the signals →