Feature
A worktree for every thread
Two agents editing the same checkout will trip over each other. A Git worktree gives a thread its own folder and branch from the same repository, so you can run several agents on one project at the same time and merge what works.
Starting a thread in a new worktree
Under the composer of a new project thread is a strip that says where the thread runs and on which branch. Before you send the first message:
- Click the workspace button (it says Current checkout) and choose New Worktree.
- Optionally click the branch button (“From main”, say) to pick the branch the worktree starts from. By default it’s the repository’s default branch, or the checked-out branch if there’s no default.
- Send your message. The first turn already runs in the worktree.
Coincide creates the worktree right away on a temporary branch such as coincide/1a2b3c4d, then renames the branch after what your first message asks for. Settings › General › “Worktree branch prefix” changes the coincide/ prefix, or removes it.
You can also choose Previous Worktree to put a new thread in the worktree another thread of the project used most recently, or Current Checkout to go back. Once the thread has sent a message, its folder is fixed.
Where worktrees live
Worktrees Coincide creates go in ~/.coincide/worktrees (or a worktrees folder inside COINCIDE_DATA_DIR when that’s set), in a folder named after the repository and branch. The folder is readable only by your Mac user, since it holds checkouts of possibly private repositories. They’re ordinary Git worktrees, so git worktree list in the project shows them.
Working in a worktree
- Agents, the terminal, Go to File and Search in Project and the diff panel all use the thread’s worktree.
- Setup scripts. A project script marked “Run when a thread gets a new worktree” runs in the new worktree’s terminal, for steps like installing dependencies or copying
.env. Scripts getCOINCIDE_PROJECT_ROOTandCOINCIDE_WORKTREE_PATH; the T3 Code names (T3CODE_PROJECT_ROOT,T3CODE_WORKTREE_PATH) are set too, and scripts in a project’st3.jsoncan be imported. - Reveal in Finder and Copy Path in the workspace menu take you to the folder.
- When the work is done, commit, push and open a pull request from the diff panel; see Commits and pull requests.
- The GitHub pull request workspace can check out a pull request into a worktree of its own and open a thread there.
Cleaning up
Coincide removes a worktree it created only when the thread never sent a message, for example when you switch back to the checkout or delete the new thread, and only if the worktree has no changes and its temporary branch has no commits. A worktree that a thread used stays on disk, with its branch, so nothing you or an agent did is lost. Remove it with Git when you’re done:
git worktree list
git worktree remove ~/.coincide/worktrees/<folder>
git branch -d coincide/<branch> # after merging
Things to know
- Git checks a branch out in only one folder at a time, so a branch that’s checked out in the project folder or another worktree can’t be used for a new one.
- Threads in a worktree stay with their project; they can’t be moved to another project.
- A worktree has its own working files. Ignored files from the main checkout, such as
node_modulesor.env, aren’t there until a setup script or the agent creates them. - Worktrees need the project to be a Git repository.