skip to content
agentmash
get started

git worktrees and agentmash: use both

published · updated

git worktrees, like Claude Code’s and Cursor’s, give each agent its own checkout, so no two agents write the same file on disk. agentmash tells your agent what your teammates’ agents are changing, on any branch and any machine, before it edits. by default it doesn’t warn your own agents about each other: keeping them apart is the worktree’s job.

what worktrees do

a git worktree is a second working directory of the same repository, with its own files and its own branch, sharing one history. git worktree add ../app-feature-a -b feature-a makes one, git worktree list shows them all, and by default git won’t check out a branch that another worktree already has.

Claude Code and Cursor make them too. as their docs read on , Claude Code’s --worktree flag, or -w, starts a session in a worktree of its own under .claude/worktrees/<name>/, on a new branch named worktree-<name>, and Cursor runs an agent’s task in a worktree from its Agents Window, or with /worktree in the editor. either way, agents running side by side on one machine stop editing the same files on disk.

git worktree vs claude code’s --worktree

git worktree add and the flag both make a checkout, and the flag does the bookkeeping around it: it names the folder and the branch, copies the gitignored files a .worktreeinclude lists, keeps its edit tools’ writes out of the main checkout (a shell write such as cp or a redirect isn’t refused, and the repository’s own filter drivers, Git LFS installed with --local among them, are skipped), and, when an interactive session ends, removes the worktree or asks whether to keep it. plain git worktree add is for an existing branch or a folder outside the repository, which is when Claude Code’s worktrees page says to make one with git directly.

how each tool makes a worktree

each tool makes the same kind of checkout and keeps it somewhere of its own, as their docs read on :

toolhow you start onewhere it goes
Claude Codeclaude --worktree <name>, or -w.claude/worktrees/<name>/, on a new branch, worktree-<name>, from the default branch, by default
Codex, in the ChatGPT desktop appWorktree under the composer, then a starting branch$CODEX_HOME/worktrees, in a detached HEAD; the 15 most recent are kept by default
Cursorthe Agents Window, or /worktree and /best-of-n in the editorset up by .cursor/worktrees.json; 25 kept per machine by default
the GitHub Copilot appa new working tree, chosen when a session startsa working tree and a branch of the session’s own; a session can also run in your local repository or in a cloud sandbox

whichever makes it, a worktree keeps that tool’s agents on one machine out of each other’s files. none of them reaches a teammate’s checkout. agentmash’s hooks are the Codex CLI’s and GitHub Copilot’s in VS Code and its CLI; its docs don’t describe what a session in the ChatGPT desktop app or the Copilot app gets.

claude code worktree cleanup

when an interactive session exits and its worktree is clean, Claude Code removes the worktree and branch of a session without a name, and asks first when the session has one (a name given with /rename or --name, not the worktree’s). a worktree with changes, untracked files or new commits always gets the question, keep or remove. a run with -p never cleans up, so git worktree remove takes its worktree out (with --force if it still has changes or untracked files), after git worktree unlock if git says it’s locked. Claude Code’s worktrees page describes all of this, and Cursor’s puts its own default cap at 25 worktrees per machine.

what a worktree leaves out: .env files, ports and databases

what worktrees don’t catch

what agentmash adds, across branches

the edits each developer’s connected agents report go to one room for the repository, and every worktree of it reports to that same room, each on its own branch. a worktree in a detached HEAD reports its commit instead. agentmash compares each developer’s edits with their teammates’, and by default not with their own, so before an edit your agent is told about a teammate’s change to the same file, worded by where that change is:

side by side

what happensgit worktreesagentmashboth
two of your own agents writing one file on diskcan’t happen: each has its own checkoutcan happen, and by default neither is warnedcan’t happen
two of your own agents changing one file on two branchesfound at the mergeby default neither is warned: both report as youfound at the merge
knowing what a teammate’s agent is changingnoyes, before each edityes, before each edit
a teammate’s agent changing the same file on another branchfound at the mergetold before the edittold before the edit
a teammate’s change to a function your file importsfound when something breakstold before the edit, in JavaScript and TypeScript, within the conflict window, when their agent reports the names it changed (Claude Code’s edits do)told before the edit, in JavaScript and TypeScript, within the conflict window, when their agent reports the names it changed
teammates’ agents on other machinesnot seenin the same roomin the same room
a teammate’s agent and yours changed the same file anywaya merge conflict for a personin Claude Code, Codex and GitHub Copilot, by default, you’re told as the session finishes, before either change landsin Claude Code, Codex and GitHub Copilot, by default, you’re told as the session finishes, before either change lands

keep your worktrees

nothing about a worktree flow changes. someone connects the repository once, each developer signs in once on each machine with npx agentmash login, and every worktree of the repository that a connected agent works in reports to its room from then on. the setup page has the steps for Claude Code, Cursor and the other coding agents.

what it doesn’t do

what counts as a conflict →the five levels →claims →reconciliation →known limitations →