Agent Failure Modes

Agent runs git reset --hard and destroys unpushed work

A Claude Code user reported the agent running git reset --hard origin/main on session startup twice, wiping unpushed commits and uncommitted files.

Agents
Claude Code
Reported
Source checked
Tags
git, data-loss, destructive-command

Symptom

You start a session and your local commits and uncommitted edits are gone. The branch now matches origin/main.

Cause

The agent ran a destructive git command without asking. Uncommitted changes aren't in the reflog, so they can't be recovered. Commits can be, but only if you act quickly.

Fix

Block destructive git commands for agents and push work-in-progress often. If it happens, stop and check git reflog right away to recover commits.

// .claude/settings.json
{
  "permissions": {
    "deny": [
      "Bash(git reset --hard *)",
      "Bash(git clean *)",
      "Bash(git checkout -- *)",
      "Bash(git push --force *)"
    ]
  }
}
// Recovery for commits: git reflog && git branch rescue <sha>

Sources

More in Git and worktrees

Get one failure mode a week

A short weekly email: one real incident, what caused it and the fix. No spam, unsubscribe any time.