Race
A race gives the same task to two or three agents at once, each in its own git worktree branched from the same commit, so you can compare what each one did and merge the one you like. Your main folder is not touched until you pick a winner.
The record and the rules live in Sources/EntermCore/Race.swift (no git, no UI, unit-tested in Tests/EntermCoreTests/RaceTests.swift); the app side that runs git, opens the boxes and draws the lanes is Sources/EntermApp/Race.swift.
On this page
- Overview
- Starting a race
- Branches and folders
- The prompt
- While the race runs
- How a finish is detected
- Results and tests
- Picking a winner (merge)
- Dropping a race
- Sharing the result
- Files written
- Limitations
Overview
Starting a race
Open Start a Race from the command palette or the action menu. The setup page asks for:
| Field | Notes |
|---|---|
| Task | Required. The same text goes to every agent. |
| Racers | At least two of Claude Code, Codex and Gemini (RaceCenter.programs). A program that is not installed is greyed out and cannot be chosen; Claude Code and Codex are preselected. |
| Test Command | Prefilled from the folder's files (detection); leave it empty to skip tests. |
| Folder | The folder of the focused box, or your home folder if none is focused. |
RaceCenter.start then:
- Runs
git rev-parse --show-toplevelin the folder. Not a repository: "This folder is not a git repository." - Runs
git rev-parse HEADat the repository root. No commit yet: "The repository has no commits yet. A race starts from a commit." That commit is the race's base. - Lists existing branches, picks a unique branch name per program, and runs
git worktree add <folder> -b <branch> <base>for each. If any of them fails, the worktrees already made are removed again and the error is shown ("Couldn't open worktree: …"). - Saves the race to
races.json, then starts each program in its worktree with the race prompt. - Puts the racers in a group and a project tab of their own (named after the task), side by side, and fits them in view once all boxes are open.
Starting the agents goes through the normal launcher, so the power limit applies: a racer may wait in the queue. Each racer's clock starts when its box opens, not when the race was created.
Branches and folders
Branch: yaris/<slug>-<program>. Yarış is Turkish for race; like other identifiers in Enterm it is kept in Turkish.
<slug>is made from the task (RacePlan.slug): Turkish dotlessı/İare spelledi/I, the text is transliterated to Latin and stripped of accents, lowercased, every run of characters other than ASCII letters and digits becomes one-, and it is cut at 28 characters with trailing dashes removed. A task with no usable characters givesgorev("task").<program>is the program's identifier:claude,codexorgemini.- If the branch already exists in the repository,
-2,-3, … is appended.
Example: the task "Fix the coupon refund" with Claude Code and Codex gives yaris/fix-the-coupon-refund-claude and yaris/fix-the-coupon-refund-codex.
Folder: next to the repository, like every worktree Enterm opens (RacePlan.folder):
<parent of repo>/<repo name>.worktrees/<branch with "/" replaced by "-">
For a repository at ~/code/shop this is ~/code/shop.worktrees/yaris-fix-the-coupon-refund-claude.
The prompt
Every agent receives exactly the same text (RacePlan.prompt), as its first message on the command line:
<task>
This folder is a git worktree made for you alone; other agents are doing the same task in their own folders. Work only here. When you are done, commit your work on this branch with a short message and stop.
Claude Code and Codex get it as their positional prompt argument; Gemini gets it with -i, which starts an interactive session with that first prompt.
While the race runs
Each racing box shows a lane under its terminal: elapsed time, files changed, lines added and removed (+N −M), and a runner on a track toward a flag. Click the lane to open the results.
Measuring. Every 6 seconds (only while some racer has not finished and the Enterm window is visible), and once more when a racer goes quiet, Enterm runs in that racer's worktree:
git add -A --intent-to-add # new files count too: marked, not staged git diff --shortstat <base>and parses files, insertions and deletions. The intent-to-add step changes the worktree's index; it does not touch your main folder.
Progress. The runner's position is the racer's changed lines (insertions + deletions) relative to the racer with the most, scaled to stay short of the flag (4% to 90% of the track). A finished racer is at the flag. Lines are a sign of life, not of quality; the results page says so too.
Medals. When a racer finishes, its place (1, 2, 3) pops in where the runner stopped, in gold, silver or bronze, and the box border flashes once (only when motion is allowed).
Transcript. While measuring, Enterm saves the racer's transcript path into the race, so the replay still works after the boxes are gone.
How a finish is detected
A racer has crossed the line the first time all of these are true (RaceCenter.watch, measure):
- Its session was seen in status Running at least once since the race started. Codex is the exception: it gets its task on the command line and, until its hooks are trusted in its own
/hooksscreen, reports only the end of a turn (notify), so it may never be seen running. - Its session is now Idle. Claude Code and Codex say so themselves, and so does Gemini through the hooks Enterm gives it; once a program's hooks have spoken, its screen is no longer used to guess its state. A program read only from its screen goes idle after three silent seconds, which may be thinking, so it must stay idle for 20 more seconds (
RaceRules.finishGrace); its finish is still dated to the moment it went quiet. - The measurement taken at that moment shows at least one changed file against the base.
Going quiet with no changes is treated as a question to you, not a finish, and the racer stays unfinished. Finishing order is the order of these moments; racers still working are listed after, in the order they started. When every racer has finished, Enterm shows "Race Over · Results Ready", posts a Mac notification if the window is in the background, and opens the results page unless you are in another page or dialog.
After a racer has finished, its numbers are no longer updated. If it keeps working (for example you ask it for more), the lane keeps the numbers from its finish; the merge still takes everything in its worktree (below).
Results and tests
The Race Results page lists the racers in finishing order with place, time, files and +/− lines, and offers:
| Action | Effect |
|---|---|
| View Diff | Focuses the racer's box and opens the Changes page for its worktree |
| Test / Test All | Runs the race's test command in one or every worktree |
| Pick Winner | Merges that racer (below) |
| Replay the Race | Opens the timeline with one lane per racer |
| Drop Race | Ends the race without a winner (below) |
Running tests. Each test runs in the background as $SHELL -lc 'cd <worktree> && <command>', so it sees the same PATH as your terminal. Output is discarded; the result is Tests Passed for exit status 0 and Tests Failed for anything else, including a command that could not start. A test still running after 10 minutes is killed and counts as failed. Tests of different racers run on the same background queue, one after another.
Test command detection
RacePlan.testCommand looks at the files in the race folder, in this order; the first match wins:
| File present | Test command |
|---|---|
Package.swift | swift test |
Cargo.toml | cargo test |
go.mod | go test ./... |
package.json + pnpm-lock.yaml | pnpm test |
package.json + yarn.lock | yarn test |
package.json + bun.lockb or bun.lock | bun test |
package.json | npm test |
pyproject.toml, pytest.ini or setup.py | python3 -m pytest |
Gemfile | bundle exec rake test |
Makefile | make test |
| none of these | empty: no tests unless you type a command |
Only the top level of the folder is looked at.
Picking a winner (merge)
Pick Winner asks for confirmation, then RaceCenter.merge:
Checks the main folder.
git status --porcelain --untracked-files=noat the repository root must be empty. If tracked files have uncommitted changes, the merge is refused: "The main folder has uncommitted changes. Commit or stash them first." Untracked files do not block it.Commits leftovers in the winner's worktree.
git add -A; if anything is staged,git commit -m "<task> (<program>)". This catches work the agent did not commit itself.Merges in the repository root, into whatever branch is checked out there:
git merge --no-ff -m "Yarış: <task> · Kazanan <program>" yaris/<slug>-<program>The merge commit message is in Turkish ("Race: … · Winner …"). If the merge fails (for example on a conflict), Enterm runs
git merge --abortand shows "Couldn't merge: …" with git's output; the race stays open and nothing is removed.Cleans up. The race is marked closed with its winner. The boxes close one after another, losers first. Then, for every racer,
git worktree remove --force <folder>andgit branch -dfor the winner (safe, it is merged) orgit branch -Dfor the others, and finallygit worktree prune. The race's group is removed and Enterm returns to the project tab you started from.
--force on worktree removal means uncommitted work in a losing worktree is discarded. Look at the diffs before you pick.
Dropping a race
Drop Race asks for confirmation, then closes every racer's box, removes every worktree with --force, deletes every race branch with -D, prunes worktrees, and marks the race closed without a winner. Your main folder is not changed.
Sharing the result
Once at least one racer has finished, the results page shows Share Result. It opens a preview of a 1200×630 card (RaceCard in Sources/EntermApp/RaceShare.swift): the task, and per racer its place, name, time, files and lines changed, test result and a winner mark. You can reword the task before anything leaves the Mac.
- Copy Image puts the card on the clipboard as PNG, to paste into a post. Nothing is sent.
- Share as Page sends the card and the numbers to
POST /api/race/shareon enterm.enmeraapps.com, which answers with a page address (/race/<id>) that has the card as its link preview. The address is copied and kept on the race; Take Page Down deletes the page again (only the Mac that shared it can).
What is sent is exactly what the card shows (RaceShare in Sources/EntermCore/RaceShare.swift): the task as you left it, the test command, and per racer the program, place, seconds, files, lines added and removed, test result and winner flag, plus the card image and the random id of this Mac that the Library also uses. Folder names, branches, diffs and transcripts are never sent. Share pages are not indexed by search engines.
Files written
| Location | What |
|---|---|
~/Library/Application Support/Enterm/races.json | Every race, open and closed: task, repository root, base commit, test command, and per racer the program, branch, folder, session ID, start and finish times, diff stats, test result and transcript path; plus the winner and whether it is closed. Closed races stay as history (they feed the replay), with the shared page's address if there is one. |
<repo>.worktrees/<branch>/ | One worktree per racer, removed when the race ends |
yaris/<slug>-<program> branches | One per racer, deleted when the race ends (the winner's after it is merged) |
| Commits | Leftover commit in the winner's branch, and the --no-ff merge commit in the main folder's current branch |
Limitations
- Programs. Only Claude Code, Codex and Gemini can race: the programs that take a first instruction on the command line and stay open to talk.
- Local only. A race runs on a repository on this Mac; remote (SSH) projects are not supported.
- Finish detection is a heuristic. It relies on the session status:
- Claude Code, Codex and Gemini report the end of a turn themselves, so "idle" means the turn ended.
- Codex without trusted hooks (troubleshooting) reports only that end, which is enough to finish; it just shows no "running" state on the way.
- If Gemini's hooks cannot run (an administrator's system settings file is in charge), it is read from its screen and must stay quiet 20 seconds before it counts as finished; a longer silence after changing files can still be counted as a finish.
- An agent that stops to ask you something without changing a file is not finished; one that asks after changing files may be.
- An agent that finishes but is waiting for approval is not idle, so it has not finished.
- Stats freeze at the finish, as described above.
- Lines are not quality. The progress bar and stats count lines, nothing more. Use the diffs and tests.
- Test results are pass/fail only; the output is not kept. Run the command in the worktree's box to see it.
- Merging does not resolve conflicts. A conflicting merge is aborted; resolve it yourself in the main folder (the race branches remain until you drop the race).
- Commit messages are Turkish for the merge commit.
Last changed 25 November 2026. View or edit on GitHub