Question

Cursor deleted my utils file and I never set up git

Solved · 245 viewsasked by nightowl_nina

Asked the agent to "clean up unused code". It deleted lib/utils.ts which was NOT unused, now 20 imports are broken. I don't use git (I know, I know). Ctrl+Z in the editor does nothing because the file is gone.

Is there any way to get it back??

What I’ve tried

Checked the Mac trash, not there. Asked Cursor to restore it and it wrote a new utils.ts from memory which is missing half the functions.

Comment
Don't close the chat! The checkpoint lives in that conversation. elif_y

3 answers

Marked as helpful by the asker
elif_y

Two places to look, in this order:

  1. Cursor checkpoints. Scroll up in the chat to the message where you asked for the cleanup. There's a "Restore checkpoint" option on it; that rolls files back to before that agent run.
  2. Local History / Timeline. Recreate an empty lib/utils.ts, open it, and look at the Timeline panel at the bottom of the explorer. VS Code-based editors keep local history of saved files, often including the old contents.

Then, today: git init, commit, and push to a private GitHub repo. It's the undo button for everything an agent does.

Comment
RESTORE CHECKPOINT WORKED. I could cry. git init done, first commit done. nightowl_nina
Welcome to the club of people who learned git the hard way. elif_y
ximena_c

For next time add to your rules: "Never delete files. If something looks unused, list it and ask me." Deletions are the one thing I never let an agent decide.

Comment
Added that exact line to my rules. Also a second one: 'run git status before and after every change'. nightowl_nina
old_school_raj

If you're on a Mac and Time Machine is on, check that too. And after this: git plus a remote, every day. Not optional once an agent can delete things.

Comment