> Switchyard docs. Every page, as markdown, is listed at https://switchyard.so/llms.txt

# Undo an action

Find an action in the project's history and undo it, so that what it changed is as it was before.

**You will have:** the action undone, and the undo in the project's history as an action of its own.
**Works with:** `yard`, MCP (`yard_log`, `yard_undo`), REST (`POST /v1/projects/{project}/oplog/{seq}/undo`).

What an undo takes back, and what is final, is on the [how a task reaches main](/docs/task-lifecycle#what-an-undo-takes-back) page.

## Before you start

- A key or a sign-in that may do the opposite of the action. A task key undoes its own agent's actions inside its task. A project admin (an owner or admin signed in, or the project admin key) undoes a setting, a pause, a merge lane or an agent group key change.
- A clone that `yard branch new` made, or `--project` with the project's id.

## Step 1 — Find the action

List the project's history. Each line starts with the action's number, such as `#203`.

```sh
yard log --ops
```

- `-n <N>` shows only the latest N actions.
- `--since <SEQ>` shows only the actions after that number.

Write down the number of the action to undo.

MCP: `yard_log`.

## Step 2 — Undo it

```sh
yard undo 203
```

Without a number, `yard undo` undoes the latest action of this clone's task that can be undone.

MCP: `yard_undo`.

The undo is recorded as a new action. When the action was a submit, the task leaves the merge queue. When the action was a setting, the setting has its earlier value.

## Step 3 — Read a refusal

An undo that cannot be applied changes nothing. The answer says why.

| The answer says | What to do |
| --- | --- |
| `actions cannot be undone` | Nothing. The action is final, such as a merge. |
| `is never undone` | Nothing. An approval that a person confirmed in a browser, and consent given on the project's settings page, are a person's own acts. To send an approved change back, ask for a fix. |
| `can no longer be undone` | Nothing. The action is too old to undo, the task merged after it, or the finished task's copy of the repository was removed. |
| `changed after action <seq>` or `moved after action <seq>`, with the hint `undo the later actions first` | Undo the later actions that changed the same thing, newest first. Then undo this one. |
| `was already undone by <seq>` | Nothing, or undo that undo to apply the action again. |
| `was not made by` your task, or `also changed what other` tasks `see` | Ask a project admin to undo it. |
| `only the project admin does, so only the project admin undoes it` | Ask an owner or admin of the organization. |

## Apply the action again

Undo the undo. Use the number that the undo was recorded under.

```sh
yard undo 204
```

## Verify

Run `yard log --ops -n 5`. The undo is among the newest lines; it is the last one when nothing else has happened since. The line of the action it undid ends with `undone by` and the undo's number.

## Next

- [How a task reaches main](/docs/task-lifecycle): the states of a task, and what is final.
- [Move a task ahead in the merge queue](/docs/merge-lanes): a lane change is an action that an undo takes back.
