# Review and undo what an AI agent changed on your laptop

> Stop the agent, read the diff, then undo with Git, Claude Code’s /rewind or Cursor’s checkpoints. What each undo does not cover, and what to check outside the repo.

Stop the agent first. Then review before you undo: run `git status` and `git diff` to see every change in the repository. To undo, use Git for anything committed or tracked, and the agent’s own checkpoint for edits it made itself. Claude Code’s `/rewind` and Cursor’s Restore Checkpoint cover file edits only, not changes a shell command made, anything outside the project, or what the agent sent to a website or a server.

## Step 1: stop and save the record

Stop the session, and pause any other agent in the same folder. Note the session ID so you can read the transcript later. [See everything your agents did today](https://www.excellent.so/guides/see-everything-your-ai-agents-did-today)

## Step 2: review in Git

```bash
git status --short
git diff --stat
git diff
git log --since=midnight --stat
```

`git diff` shows unstaged edits, `git diff --staged` shows staged ones, and `git log` shows commits. Untracked files appear in `git status`. Read the diff before you reset anything, because a reset throws away edits you may want.

## Step 3: undo with the right tool

| Situation | Undo | Limit |
| --- | --- | --- |
| Edits Claude Code made with its file tools | `/rewind` or `/undo`, or Esc twice on an empty prompt. Choose Restore code, or Restore code and conversation. | Bash changes to a file it never edited, subagent edits, other sessions and symlinked files are not restored |
| Edits Cursor’s agent made | Click a checkpoint in the chat timeline, then Restore Checkpoint | Reverts files only, stored locally and separate from Git |
| Codex edits in a Git repo | `git restore <file>` for one file, or `git checkout -p` to pick hunks | No documented checkpoint restore in the pages we read |
| A commit you do not want | `git revert <sha>` keeps history. `git reset` rewrites it. | Reset on a shared branch needs a force push |
| A file deleted outside Git | Time Machine or iCloud | See [deleted files on a Mac](https://www.excellent.so/guides/ai-agent-deleted-files-on-mac) |
| A force push | Recover from the host’s before ID | See [force-pushed main](https://www.excellent.so/guides/ai-agent-force-pushed-main) |

Claude Code keeps file snapshots for the 100 most recent checkpoints in a session and sweeps them about 30 days after the session last saved one, so an old rewind can fail with “No files were restored”. Set `cleanupPeriodDays` to keep them longer. Both vendors say checkpoints are not version control. Cursor’s docs say to use Git for permanent history. [Claude Code checkpointing](https://code.claude.com/docs/en/checkpointing) · [Cursor Agent](https://cursor.com/docs/agent/overview)

To keep a safety net, commit or stash before each agent task. Then every undo is one command.

## Step 4: check what a rewind cannot reach

- **Outside the repo.** Config files, `~/.zshrc`, installed packages and global tools. Search by modified time: `find ~ -maxdepth 3 -mtime -1 -type f -not -path '*/Library/*' 2>/dev/null | head -50`.
- **Pushes and deploys.** Check the Git host and your deploy tool. A push cannot be rewound locally.
- **Requests to other services.** A transcript shows the call. The remote side keeps what it received, so rotate any key that was sent.
- **Credentials.** If the agent read or printed a key, replace it. [Keys and logs](https://www.excellent.so/guides/keep-keys-and-email-out-of-agent-logs)

## Where Excellent fits

Excellent does not revert an agent’s file changes. Its free scan reads supported logs on your Mac and lists what happened that you may want to review: force pushes, deleted never-delete folders, keys in logs, published packages. Use it to find the action, then undo with the tools above. With Pro, a live check can block or ask before some of those actions next time. Excellent backs up a settings file before it changes it, but removing keys from logs cannot be undone. Pro is US-only for now. [Run the free scan](https://www.excellent.so/scan) · [See a sample report](https://www.excellent.so/r/sample) · [Get the Mac app](https://www.excellent.so/download)

## Checklist

- [ ] Agent stopped and session ID saved.
- [ ] `git status` and `git diff` read before any reset.
- [ ] Undo done with `/rewind`, a Cursor checkpoint or Git, as fits.
- [ ] Shell and subagent changes checked separately.
- [ ] Pushes, deploys and outside-the-repo files checked.
- [ ] Exposed keys rotated.

Checked against vendor documentation on November 25, 2026. [Claude Code checkpointing](https://code.claude.com/docs/en/checkpointing) · [Cursor Agent overview](https://cursor.com/docs/agent/overview) · [Git restore](https://git-scm.com/docs/git-restore)

Source: https://www.excellent.so/guides/review-and-undo-what-an-ai-agent-changed
