git reset --hard in Cursor — agent safety guide
Cursor agents frequently attempt git reset --hard during autonomous sessions.
git reset --hard
Blast radius
Uncommitted edits, staged changes, and any commits since the target ref are detached. The reflog can recover commits for ~30 days, but uncommitted file edits are irretrievable unless the IDE's local history extension caught them.
Why agents reach for it
Agents reach for it during merge-conflict resolution, mid-rebase 'clean slate' resets, and after botched stash operations when the simplest path looks like 'just match origin/main'.
Recovery options
`git reflog` lists detached commits for the configured retention window — re-attach with `git branch <name> <sha>`. Uncommitted file edits are gone unless captured by VS Code Local History, JetBrains Local History, or a Time-Machine-style filesystem snapshot.
Real-world incident
A Cursor agent ran `git reset --hard origin/main` while resolving a rebase conflict, discarding ~4 hours of uncommitted refactor work the operator hadn't yet staged. IDE Local History saved two of the five affected files.
Block it with DestructGuard's default tier
DestructGuard's default rules tier includes git reset --hard by default — the call is intercepted at the shell or process boundary before execution. Approvals are logged to JSONL with timestamp, caller, command, and decision. Pair with git pre-commit and pre-push hooks from the Pro Pack so destructive patterns are blocked at multiple points in the agent pipeline.
From guidance to an enforceable agent loop
Preflight this command before an agent executes it
Start with the one-cent Action Safety Quick Gate. Low risk can proceed, medium risk routes to full DestructGuard evidence, and high or critical risk routes to the complete workflow for ReviewQueue triage, a signed receipt, and a privacy-preserving status record. Triage never implies human approval.