# Undo coding agent changes with Crew checkpoints

> Undo coding agent changes with Crew checkpoints: revert a turn from its diff, rewind the conversation, and list, diff and restore checkpoints.

- Canonical URL: https://getedith.pro/docs/agents/tutorials/undo-agent-changes-with-checkpoints
- Updated: 2026-12-03

By the end of this tutorial you will know how to find the snapshot the agents engine took around an agent's turn, see exactly what that turn changed, and put your files back, all without touching your branches. You need Crew running and an agent working in a git repository. See [Get Crew](https://getedith.pro/docs/agents/crew/get-crew).

> **Beta:** Crew is a beta extension and can change between releases.

## Work in a git repository

When an agent in a git repository starts working, and again when it stops, the engine records a checkpoint of the whole working tree, untracked files included. Checkpoints live in the same repository but never touch your index, your branches or your stash, so `git status` and `git log` look the same as before.

Start an agent in the repository from the Crew page with **New agent** (⌘N), or start a thread there from **Threads**.

### Turn on checkpoints for threads

Threads save a checkpoint each turn when **Save a checkpoint each turn** is on:

1. On the Crew page, open **Filter** (⇧⌘F) and choose **Edit launch settings**.
2. In the **Thread engine** section, turn on **Save a checkpoint each turn**.

## Revert a thread's turn

For a thread, you undo from the thread itself:

1. Open the thread and press **Diff** (⌘D) in the thread toolbar. It shows the thread's changes, turn by turn.
2. Pick the turn that went wrong and read what it changed.
3. Press **Revert** to restore files to the checkpoint before that turn.

## Rewind the conversation

To take the conversation back too, choose **Edit from here** on a message, then:

- **Revert and keep changes** removes that message and everything after it from the conversation, and leaves your files alone.
- **Revert files too** also puts the worktree back to the checkpoint from before that message, including edits you made yourself.

### From the terminal

```terminal
$ ed crew thread rollback th_01 run_03
$ ed crew thread rollback th_01 run_03 --keep-files
```

`--keep-files` only undoes the conversation and leaves your files alone.

## Undo a terminal agent's turn

Checkpoints for agents in terminal panes are listed, compared and restored from a terminal. Run these in the repository folder, or pass `--cwd`.

### Take a checkpoint before you start

Before you hand an agent something risky, or before you edit files yourself, take a checkpoint of your own. Your files and branches stay as they are:

```terminal
$ ed crew checkpoints create --label "before the refactor"
```

### List the checkpoints

Let the agent take a turn, then list what the engine recorded:

```terminal
$ ed crew checkpoints ls --cwd ~/code/app
$ ed crew checkpoints ls --pane w1:p2 --limit 10
$ ed crew checkpoints ls --thread th_01
$ ed crew checkpoints show cp_01
```

The newest come first, 50 by default. `--pane` and `--thread` narrow the list to one agent. Each checkpoint has an id such as `cp_01` and belongs to an agent pane or a thread. `show` prints one checkpoint's repository, commit, owner, status and changed files.

### See what a turn changed

By default `diff` compares a checkpoint with the next one, which is exactly what that turn changed. Start with `--stat` for the list of files and line counts, then read the full diff:

```terminal
$ ed crew checkpoints diff cp_01 --stat
$ ed crew checkpoints diff cp_01
```

| Command                                                     | What it compares                                          |
| ----------------------------------------------------------- | --------------------------------------------------------- |
| `ed crew checkpoints diff cp_01 --to worktree`              | The checkpoint with your files as they are now            |
| `ed crew checkpoints diff cp_01 --to cp_05`                 | Two checkpoints                                           |
| `ed crew checkpoints diff cp_01 --path src/app.ts`          | Only this path. Repeat for more                           |
| `ed crew checkpoints diff cp_01 --authored-only`            | Only the changes the agent made, not edits made around it |
| `ed crew checkpoints diff --thread th_01 --from-run run_02` | A thread's changes between runs                           |

`--ignore-whitespace` hides whitespace changes in any of them.

### Restore one file

When only one file went wrong, restore just that path. Everything else stays:

```terminal
$ ed crew checkpoints restore cp_01 --path Sources/App.swift
```

### Restore the whole repository

To roll back a whole turn, restore the checkpoint from before it:

```terminal
$ ed crew checkpoints restore cp_01
```

Restoring puts the repository back the way the checkpoint had it:

- Tracked files are rewritten.
- Untracked files that did not exist in the checkpoint are removed.
- Ignored files are left alone.

> **Warning:** A restore removes untracked files that were not in the checkpoint, including files you made yourself. Restore a single `--path` when you only want one file back.

The engine refuses to restore while another agent works in the repository. Stop or wait for that agent, or pass `--force` if you are sure.

### Undo a restore

The engine takes a safety checkpoint before every restore, so a restore can itself be undone. List the checkpoints again, find the one the restore took, and restore it:

```terminal
$ ed crew checkpoints ls --cwd ~/code/app --limit 5
```

## Clean up old checkpoints

Checkpoints pile up in busy repositories. Deleting a thread also deletes its checkpoints. From a terminal, delete ones you no longer need, or keep only the newest:

```terminal
$ ed crew checkpoints rm cp_01 cp_02
$ ed crew checkpoints prune --keep 200
```

`prune` keeps 2000 unless `--keep` says otherwise.

On a machine you added in Machines, add `--machine` to any of these commands and pass that machine's paths:

```terminal
$ ed crew checkpoints ls --machine box --cwd /srv/app
```

## Next steps

- [Review an agent plan in a thread](https://getedith.pro/docs/agents/tutorials/review-an-agent-plan-in-a-thread)
- [One git worktree per agent](https://getedith.pro/docs/agents/tutorials/one-git-worktree-per-agent)
- [Checkpoints](https://getedith.pro/docs/agents/crew/checkpoints)
- [`ed crew checkpoints`](https://getedith.pro/docs/agents/crew/cli/checkpoints)

## Get Edith

Edith is a native Mac app for macOS 14 or later on Apple silicon with 100+ extensions, the `ed` command line and an MCP server. $35 once for one Mac, plus $7 for each additional Mac, with no subscription and a 30-day refund.

- [Buy Edith](https://getedith.pro/pricing): $35 once for one Mac, plus $7 for each additional Mac
- [Download Edith](https://getedith.pro/download): the installer, or Homebrew
