Skip to content

Check an agent's work before it lands (the merge queue)

An agent says it is done. But “done” is the agent’s word. Do the tests pass once its work is combined with what has changed on main meanwhile? Did it get the tests to pass by skipping them? Merging first and finding out later puts the problem in your branch.

Check the work before it lands, on a copy, and merge only what you checked.

When you add a branch to the queue, the app test-merges it into your branch on the side: a merge made in memory with git merge-tree, without touching any working folder. Your test command runs on that result, and Claude can review it at the same time. One branch is tested at a time, so the others wait their turn.

  1. Set a test command: the button at the top of the Worktrees view says No test command until you do. It is the command you would run yourself, such as npm test or go test ./.... It is optional, but without it the queue only makes the trial merge and checks for conflicts; no tests run.

  2. Select an agent and press Add to merge queue. The branch needs at least one commit.

  3. Watch its card. It goes through:

    State Meaning
    Waiting Waits for its turn: one branch is tested at a time
    Testing… The trial merge is being tested and reviewed
    Ready to merge The trial merge is clean and its tests passed
    Conflicts The branch conflicts with your branch
    Failed The tests failed, or the trial merge could not be made
  4. Read the card. It shows the tests, the review, and the agent smells.

  5. When it says Ready to merge and you are happy, press Merge into main.

If it failed, press Send to agent. The failure goes to the agent in its terminal in the app, or is copied to the clipboard for its own session, so it can fix its mistake.

Tired of pressing that button? Choose Auto-send in the toolbar of the Worktrees page and set a number of attempts (the field suggests 2; 0 turns it off). When the tests fail or the branch conflicts, the queue then does what Send to agent does, by itself, as long as the agent runs in a terminal in the app. It sends only once per time the agent reports done, and stops after the number of attempts you chose, so an agent cannot go round in circles. The card shows how many times it sent. Retry starts the count again.

It is only for tests and conflicts. A review finding or an agent smell is a judgement call, so those stay with you. The setting is per repository and is stored in the app, not in the repository.

Some changes often mean a test was made green by lowering the bar rather than by fixing the code. The card flags these in the trial merge, with the file and line:

  • skipped or deleted tests,
  • silenced linters and type checkers,
  • loosened configuration,
  • emptied catch blocks,
  • a possible secret: a line the branch added that looks like a key, a token or a password.

They are a signal to look, not a verdict: they never block the merge. Sometimes a deleted test is exactly right. A possible secret is shown with the file, the line, the kind and only the first characters, never the whole value. When you send the branch back, the agent is told the kind and the place and not the value. A line that only looks like an example (in documentation or a test) gives no smell. If it is real, rotate the key first; see A warning before you commit a secret. The dossier also has a button Scan this branch for secrets, which checks everything the branch added on demand.

Before you merge, the merge dossier tells the whole story of the branch in one place: what the agent was asked, what it reported, which commits it made, the tests, the review and the smells. It marks files that sit inside one of your boundaries, and suggests a merge commit message that says why, which you can use or change.

The dossier is also where you read the work. Below the story it has sections that help you review: Request and diff (files outside what was asked, with Compare with Claude), Tests that touch this diff with Run these, Check the tests and Try to break it to see whether the tests mean anything, Compare with previous round, Reading order, and Your review for comments you send back to the agent. They are explained in Review an agent’s work.

If you will not merge a branch, press Reject… on its card: it leaves the queue, the branch and its worktree stay, and you write down why. Note… writes down what went wrong in a repair round. After a few notes the app can suggest rules for CLAUDE.md; see Learn from what agents get wrong.

Merging puts in your branch exactly the commit that was tested, with a merge commit, so History shows what came from the agent. If your branch or the agent’s branch has moved since the test, what is ready is no longer what would land. The app then refuses to merge, and the card starts over and tests again. The same goes for the other branches in the queue after you merge one: they were tested against the old main. A merge can be undone with Ctrl+Shift+Z.

If your team reviews on a forge instead, skip the merge and create a pull request from the cockpit. The dossier is then the request’s description.

The trial merge is made with git merge-tree and checked out in a temporary worktree in your system’s temp folder (git-client-mx-trials), where your test command runs. Merging fast-forwards your branch to the tested merge commit, which is why what lands is the same commit that was tested.

Two branches can merge without a conflict and still not build together: one renames a function, the other still calls the old name. The queue only sees that when the second one lands. To see it earlier, press No build check in the cockpit toolbar and give a fast command that only builds or type-checks, such as go build ./.... No tests: they are too slow to run in the background.

With a command set, the app makes a trial merge of each pair of open agent branches in the background and runs the command on it in a temporary checkout. If the merge is clean but the command fails, both agents show a warning, A and B cannot build together, with the output. Send to both agents gives each of them the output and asks them to sort it out. It stays a warning: nothing is blocked or merged.

To keep it light, it checks at most ten pairs, one at a time, and a pair again only after a new commit on one of its branches. Stop check cancels a running check. Two attempts of the same task are never a pair (you pick one), and if the command already fails on one branch alone, there is no warning, since the combination is not the cause.

  • Failed, and it works for you. Press Show output on the card to read what the command printed. The command runs in a temporary checkout of the merge, not in your working folder, so a command that depends on files that are not in git (a .env file, or installed packages) can fail there.
  • Conflicts. The agent’s work and your branch changed the same lines. Resolve it in the merge editor after merging, or send the agent back to rebase.
  • A smell you can’t explain. The card lists the file and line of each one (five at first, Show all for the rest). Read that part of the diff before you merge.

The agent cockpit is where you start agents and add them to the queue.