# Review and merge an agent's work

When an agent finishes, its ticket moves to **In Review** and waits for you: the branch is not
merged until you say so. This page takes you from reading the work to merging it, sending it
back, or undoing a merge you regret.

![A ticket in In Review: the bar under the header reads Ready for your review, with Request changes, Review diff and the Merge button on the right](img/in-review-merge.png)

## Before you begin

- A ticket in **In Review** that ran in a git repo. A ticket with no repo (a scratch ticket)
  has nothing to merge: its work is its artifacts and comments.

## What In Review shows

Open the ticket. The bar under the header says where it stands (**Ready for your review.**),
how many files the branch changed, whether its checks passed, and the next step: **Request
changes**, **Review** and **Merge**, which shows the branch it lands in. On a phone the bar keeps **Merge**, and the two
others are behind the three dots beside it (**More**).

Everything the ticket produced is on its **Changes** tab, whose badge counts the files changed.
From the top:

| Part | What it tells you |
| --- | --- |
| The first line | The branch and its base, how many files and lines it changed, how many commits, and **Merged** or **Not merged**. |
| **Verification checks** | The checks the agent had to pass and how each one ran, with the board's quality gate ([Hold agents to a quality bar](quality-gate.md)). The **Plan** tab keeps the list you signed off. |
| **Artifacts** | Files the agent produced: reports, screenshots, models, pages. |
| **Files** | Every file the branch changed, with its line counts. Click a file to read its diff, or **Review diff** to open them all and comment on lines. |
| **Agent review** | What the review agent found, once one has run ([below](#the-review-agent)). |
| **Commits** | Every commit on the branch, each with its own diff and stats. |
| **Diagram** | A diagram of what the change touches, coloured by added, modified and removed. Click **Generate**: it is drawn from the branch diff on request, and **Regenerate** draws it again after new commits. |

The branch, its base, the worktree and the merge status are on the **Details** tab, under
**Workspace**.

**Result:** you know what changed, what was checked, and what the agent left behind.

## Comment on lines of the diff

![The Files card of the Changes tab with a suggestion comment under a changed line, and Submit review at the bottom](img/diff-review.png)

1. Open **Review** on the bar under the header and pick **Review diff**: it opens the **Changes** tab on
   **Files**, with every file open. Switch between **Diff** and **Tree** at the top.
2. Hover a line and click the comment icon (**Comment on this line**).
3. Pick a label. Labels follow Conventional Comments:

   | Label | Use it for |
   | --- | --- |
   | `praise` | Something done well. |
   | `nitpick` | A trivial, taste-based point. Non-blocking. |
   | `suggestion` | A proposed improvement (the default). |
   | `issue` | A specific problem. |
   | `todo` | A small, necessary change. |
   | `question` | A concern that needs an answer. |
   | `thought` | A non-blocking idea. |
   | `chore` | A simple task to do. |
   | `note` | Something to highlight. Non-blocking. |

   Add a decoration if you want to be explicit: **blocking**, **non-blocking** or
   **if-minor**.
4. Write the comment and click **Add comment**. Repeat for other lines.
5. Click **Submit review (N)** in the bar at the bottom.

**Result:** the comments go to the agent as its next turn and the ticket moves to To Do (if
the agent is still running, they are queued until it finishes). The agent must fix every
blocking item and marks each comment resolved; the timeline shows the review with how many
comments are still open.

## Send the work back

To send the agent back with a plain message instead:

1. Click **Request changes** on the bar under the header. The reply box opens.
2. Write what you want changed.
3. Click **Send**.

**Result:** the ticket moves to To Do and the agent resumes its session with your message, on
the same branch. **Comment only** posts without waking the agent. The status at the start of
the bar (**In Review**) opens a menu that moves the ticket to any column by hand.

## The review agent

A review agent is a second agent that reads the branch diff and posts findings graded P0 (must
fix before this lands), P1 (should fix) and P2 (nit). Findings never block a merge: they warn.

1. Open **Settings > Features > Automatic review lane**.
2. Set **Automatic review lane**:
   - **off**: no review agent, and no review banner. The setup wizard sets this unless you pick
     otherwise, because every review is an extra agent run.
   - **manual**: a reviewer runs only when you ask for one.
   - **auto**: a reviewer runs on every ticket that reaches In Review, after its verification
     checks pass. **Auto-review rounds** caps how many times.
3. Pick the **Reviewer skill** (`/code-review` or `/security-review`) and, if you want a
   different model from the ticket's, the **Reviewer model**.

On a ticket:

- **Have an agent review it first**, under **Review** on the bar, starts a reviewer with
  the board's **Reviewer skill**. It is offered on a branch that is ready to merge.
- To review with another skill, file a Command ticket for it: see
  [Review a branch before you merge it](recipes.md#review-a-branch-before-you-merge-it).
- **Fix from review**, in the review banner, sends the open findings to the ticket's own agent,
  which fixes them on the same branch. You can also tick a finding off as resolved on its card
  in the timeline.

**Result:** the review banner shows **Code review finished** with how many findings are still
open, and **Show the full report** lists them.

## Merge the branch

1. On a ticket in In Review, click **Merge** on the bar under the header. One click lands it
   into the branch shown beside it (**into main**, the branch the ticket was cut from).
2. To land another way, open the arrow beside **Merge** and pick **Merge and push** or **Open
   PR** (offered only where they apply), then click the button. To land somewhere else, pick
   another branch in the **into** chip; a warning counts the extra commits that branch brings.

**Result:** the branch merges into its base locally and the ticket **stays in In Review**, so
you can try the change before you decide it is done. The bar now reads **Merged into** and the
base branch, with **Mark done**. The worktree is kept, so you can reply to
the agent and merge again.

Merge can ask first:

- **A quality gate is still running**: **Merge without verifying** stops the check and merges,
  **Wait for verification** queues the merge behind it.
- **Review findings are still open**: **Merge anyway**, or **Show findings** to read them.

## Mark it Done

1. On a merged ticket, click **Mark done** on the bar. On one that is not merged yet, open
   the arrow beside **Merge** and pick **Merge and mark done**, or drag the card to Done.
2. If the branch has work to land, choose:
   - **Merge** (with its arrow and **into** branch, as on the bar): merge, then move to Done.
   - **Mark Done without merging**: finish the ticket and leave the branch unmerged.
   - **Cancel**.

**Result:** the ticket is in Done. Its worktree is removed once it is Done; the branch stays.
**Reopen** on the bar brings it back to In Review.

## Open a GitHub pull request instead

By default the board merges locally and never opens a pull request. To go through GitHub:

1. When you land the ticket, choose **Open PR** on the land control.

**Result:** the board pushes the branch and opens a pull request (the
repo must have a GitHub `origin` and `gh` signed in). The bar reads **A pull request is open.**
with **Open pull request**, **Workspace** on the **Details** tab shows a **Pull request** row with the link, and
the card on the board says **PR #** and the number, a link to it. With auto-merge on for the board, the agent merges the
PR itself; otherwise you review and merge it on GitHub, then click **Mark done** here: the board
does not see a merge made on GitHub. To send the pull request the commits made since, pick
**Update the pull request** under **More**. If the pull request cannot be opened, the board
falls back to a local merge. See
[Bring in work from GitHub, Jira or Slack](integrations.md) for importing issues.

## Resolve a merge conflict

When the base branch moved and the merge conflicts, you do not have to do anything at first:

1. The ticket moves to In Progress (**resolving conflict...**) and an agent merges the base
   into the branch and resolves the conflict, then the ticket returns to In Review and the
   merge runs again. It tries twice by default.
2. If it still conflicts, the ticket parks in Your turn with the conflicted files listed,
   and **State** under **Workspace** on the **Details** tab reads **Needs attention**. The branch and worktree are kept.
3. Click **Reply** on the bar and send how you want it resolved, or pick **Requeue without a
   message** under its arrow to have the agent try again.

**Result:** the ticket returns to In Review with the conflict resolved on its branch; click
**Merge** again.

## Waiting to merge

**Waiting to merge** means the base branch's own checkout has uncommitted changes, so merging
into it would not be safe. The board never stashes or overwrites them.

1. Commit or discard the changes in the base checkout (the path in the **Repository** row of
   **Workspace**, on the ticket's **Details** tab).

**Result:** the merge retries by itself on the next pass. After ten tries it parks the ticket
in Your turn with the files that are in the way.

## Cancel a queued merge

A merge or revert you asked for waits in a queue until the runner picks it up. To take it back:

1. On the ticket's **Details** tab, under **Workspace**, click **Cancel queued merge** (or **Cancel queued revert**).
2. Confirm **Cancel request**.

**Result:** nothing is merged, the branch is untouched and **Merge** comes back. A request that
never runs is rolled back by itself after ten minutes.

## Merge again after the branch moved

After a merge you can keep working on the ticket: reply to the agent, and it commits more on
the same branch. The status then reads **Merged · new commits**, the card says **Merged · new
commits to merge**, and **Merge** comes back on the bar. While any ticket is in that state, the
In Review column shows a **New commits** tab that cuts the column down to them.

1. Click **Merge** again.

**Result:** only the new commits land.

## Undo a merge

1. On the merged ticket (still In Review), open **More** on the bar under the header and pick
   **Revert the merge**.
2. Confirm **Revert merge**.

**Result:** a revert commit on the base branch backs out every merge of this branch, and the
ticket is unmerged again, so you can fix it and merge again. If the revert itself conflicts,
nothing changes on the base and the ticket parks in Your turn. A pull request merged on
GitHub is reverted on GitHub, not here.

## Move idle In Review tickets to Done

1. Open **Settings > Features > Automatic review lane**.
2. Set **Move idle In Review tickets to Done** to a delay, from **after 1 day** to **after 30
   days**. It is off by default.

**Result:** a ticket with no activity for that long moves to Done, but only when its work is
already merged or it has nothing to merge. Unmerged branches, Loop runs, plans waiting for you
and children a lead agent has not reviewed yet never move. Any comment restarts the clock.

## If something goes wrong

### nothing to merge: the base already contains every commit on the branch

The branch has nothing the base lacks: it was merged already, or the agent committed nothing.
The bar says **Nothing to merge.** and offers **Mark done** in place of **Merge**. Reply to the
agent if you expected changes.

### The Merge button is missing

A merge or revert is already queued: cancel it ([above](#cancel-a-queued-merge)), or wait.
The ticket must also be in In Review, on a git repo, not a scratch ticket.

### a reviewer only runs on work that is ready to merge

Move the ticket to In Review first and let any merge or revert in flight finish.

## Related

- [Hold agents to a quality bar](quality-gate.md), for the checks that run before a ticket
  reaches you.
- [Worktrees and branches](../explanation/worktrees.md), for where the branch lives and how to
  rename it.
- [Answer what the board asks you](pending-action.md), for a ticket parked on a conflict.
