When the AI agent is allowed to run terminal commands, it can execute destructive git commands (e.g., git restore Biblio/ref.bib) that silently discard uncommitted local changes in tracked files, even when the user explicitly intended to avoid touching those files.
In my case, the agent restored Biblio/ref.bib, permanently losing several new bibliography entries that were never committed and not recoverable from git history or Cursor history.
Steps to Reproduce
Open a git repo in Cursor.
Edit 10 tracked files (e.g., Biblio/ref.bib) and add non-trivial changes without committing.
Ask the AI something like: “(the result of git status). Don’t commit (some files).”
Let the AI run tools/terminal commands autonomously.
Observe that the agent may run git restore (some files), reverting the file to HEAD and discarding uncommitted changes with no confirmation dialog or safety check.
Expected Behavior
The AI should never run destructive VCS commands (git restore, git reset --hard, git clean, etc.) on my working directory without explicit confirmation.
At minimum, it should:
Ask for confirmation when a command would discard uncommitted changes.
Prefer non-destructive actions (e.g., avoid staging/unstaging or just skip files) instead of restoring.
Provide a clear explanation of what it plans to do before executing such commands.
For AI issues: which model did you use?
Model name (e.g., Sonnet 4, Tab…)
For AI issues: add Request ID with privacy disabled
Request ID: f9a7046a-279b-47e5-ab48-6e8dc12daba1
For Background Agent issues, also post the ID: bc-…
Additional Information
Add any other context about the problem here.
Does this stop you from using Cursor?
Yes - Cursor is unusable
Sometimes - I can sometimes use Cursor
No - Cursor works, but with this issue
The more details you provide, the easier it is for us to reproduce and fix the issue. Thanks!
Hey, thanks for the detailed report. I can see the screenshot, and yeah, the agent did run git restore and removed your uncommitted changes.
This is a known issue. The team is aware that the agent can sometimes run destructive git commands. Your report helps us prioritize the fix.
For now, here are a couple of workarounds:
Turn off auto-run for terminal commands: Cursor Settings > Agents > disable Auto-Run Mode. Then the agent will ask for confirmation before each terminal command, and you can reject destructive ones like git restore.
Commit or stash your changes before giving the agent any git-related tasks. It’s not ideal, but it helps prevent data loss.
You can also add a rule in .cursor/rules like Never run destructive git commands like git restore, git reset --hard, git clean without explicit user confirmation. It’s not a guarantee, but it should reduce the chance.
Sorry your changes got lost. Let me know if you have any questions.