How to race several coding agents on one prompt
Write the prompt once, give every attempt its own git worktree and branch cut from the same commit, start one agent in each with that same prompt, then compare the diffs and merge the one you like. Delete the rest. Because the starting point and the prompt are identical, the only thing that differs is the agent, or the model it runs on.
This is how you compare agents on your own code instead of on someone else's benchmark. You can do it by hand with git, and this page shows how. Further down it shows what Agency's race does for you. Disclosure: Agency is ours, and this site is its home.
Why race instead of picking one agent
Two agents given the same task rarely produce the same change. One edits three files and one edits eight; one adds a test and one does not. You find that out only by reading both. A race makes the comparison cheap enough to do on a real task: you pay for a few attempts in parallel and read the diffs side by side, instead of running one attempt, disliking it, and starting over.
Race agents by hand
The commands assume a repository called myapp with a
main branch, and three attempts: Claude Code, Codex and Gemini CLI.
-
Cut one worktree per attempt from the same commit
Run these from inside
myapp. Naming the same start point for all three is what makes the race fair.git worktree add -b race/claude ../myapp-claude main git worktree add -b race/codex ../myapp-codex main git worktree add -b race/gemini ../myapp-gemini main -
Set each one up the same way
A worktree is a fresh checkout, so install dependencies and copy untracked files such as
.envinto each. If one attempt starts with a working environment and another does not, you are comparing setup, not agents. -
Send the same prompt to each agent
Save the prompt to a file so every attempt gets exactly the same words. In tmux, each agent gets a window, and you paste the prompt into each:
tmux new-session -d -s race -c "$PWD/../myapp-claude" claude tmux new-window -t race -c "$PWD/../myapp-codex" codex tmux new-window -t race -c "$PWD/../myapp-gemini" gemini tmux attach -t raceMost agent CLIs also accept the prompt as an argument when they start, which removes the pasting. Check each CLI's own help, because the flag differs.
-
Compare what each one changed
When an agent says it is done, read its change against the commit it started from. Start with the size, then read the diffs:
git diff --stat main...race/claude git diff --stat main...race/codex git diff main...race/claudeRun the same test command in each worktree too. A diff that reads well and fails the tests has not won.
-
Merge the winner and delete the others
git merge race/claude git worktree remove --force ../myapp-codex git worktree remove --force ../myapp-gemini git worktree remove ../myapp-claude git branch -D race/codex race/gemini git branch -d race/claude--forceand-Dare there because the losing attempts have uncommitted or unmerged work that git will not discard otherwise. That is the point of the step, but check the diffs first.
What to look at when you pick a winner
- Whether the tests pass in that worktree, not whether the agent says they do
- How much it changed: a smaller diff that does the job is easier to review and to revert
- Whether it touched files the task never needed
- Whether it followed the conventions around the code it edited
You can also take pieces from more than one attempt. Merge the best one, then
git cherry-pick a commit or copy a hunk from another.
What gets hard by hand
- Three worktrees, three installs and three windows for one question
- Pasting the same prompt three times without it drifting
- Telling which attempt has finished and which is waiting on you
- Remembering which branch belongs to which agent when you come back to it
- Removing the losing worktrees and branches without removing the winner's
Doing the same with Agency's race
Agency is a free, open-source desktop app for macOS and Linux that runs agent CLIs in real terminals, each in its own worktree. Its race is the steps above behind one dialog. Open the add-agent menu in a project and choose Race agents.
| Step | By hand | In Agency |
|---|---|---|
| Same prompt | Paste it into each agent | Type it once; it is sent to every attempt at launch |
| Same start point | git worktree add from one commit | Pick the branch to start from; each attempt gets its own worktree and an agent/ branch |
| Which agents | One window per CLI | Tick two or more agents; the first two are preselected |
| Models | Each CLI's own flag | A model per attempt, and + model adds a second attempt for the same agent on another model |
| Watch | Check each tmux window | The attempts open side by side in the agents grid, each marked with a race badge |
| Compare | git diff per branch | Each attempt is an ordinary run with its own diff |
| Keep one | Merge, then remove worktrees and branches | Merge the winner; the dialog offers to archive and delete the losing attempts with it, or to keep them |
A race needs at least two attempts, and it needs a git repository, because every attempt is a branch. For a project that is a plain folder, the race option is hidden. You can also start a race from an issue, so the issue's text is the prompt.
An honest note on evidence: as of 8 October 2026 this page has no
race from our own history to show you. Agency's own repository has merged more than 200
agent/ branches, but a merge commit names only the winning branch, and the
losing attempts are usually deleted after it. Nothing left in the history says which
merges came out of a race. We would rather say that than invent a scoreboard.
Who should not use it: anyone on Windows or an Intel Mac, which Agency does not support yet, and anyone who only ever needs one agent on a task. Racing multiplies usage, since every attempt spends its own plan or API tokens, so reserve it for work where the choice matters. The by-hand steps above are enough if you race twice a month.
Questions
Does racing cost more?
Yes, roughly in proportion to the number of attempts, because each agent does the full task and bills against its own plan or API key. Race the tasks that are hard to specify or costly to get wrong, not the ones you could review in a minute.
Can I race one agent against itself?
Yes, on different models, as long as the agent's CLI can be told a model at launch. In Agency this is the + model button on an agent that is ticked in the race dialog. By hand, pass each CLI's own model flag in its window.
Can I race on top of work I have not merged?
Start the attempts from whichever branch holds that work. By hand, replace
main in the git worktree add commands; in Agency, change the
branch the dialog starts from.
New to worktrees? Start with the guide to running coding agents in parallel.