The practical answer
Use one worktree per editing task, start every task from the same integration branch, and merge reviewed changes one at a time. Separate folders stop agents overwriting each other’s files; they do not prevent merge conflicts or shared-resource clashes.
Why two agents need separate working folders
Two agents can work on the same project without working in the same folder. That distinction matters. In a shared checkout, one agent can change a file while the other is reading it, run tests against a half-finished edit, or include someone else’s changes in its commit. Separate branches alone do not fix this if both agents still use the same checkout.
A Git worktree is another working folder attached to the same repository. Each folder has its own checked-out branch and working files, while the commit history is shared. You can give one agent a login bug and another a documentation task without asking them to share uncommitted changes.
Git allows a given branch to be checked out in only one worktree at a time, which is a useful guard rail: two agents cannot both be “on” the same branch by accident.
Two agents, one repository
One shared checkout
Both agents in the same folder
- One changes a file while the other reads it
- Tests run against a half-finished edit
- A commit picks up the other agent’s changes
A worktree per agent
Same repository, separate folders
- Its own folder and checked-out branch
- Its own uncommitted changes
- Commit history is shared
Git checks out a branch in only one worktree at a time.
The best first parallel task is a pair of small, independent jobs. If both jobs change the same authentication flow, splitting them may create more review work than it saves. Decide who owns each file or feature before you launch.
Create a branch and folder for each task
This example uses PowerShell and an existing repository at C:\Projects\my-app. Replace that path with your project. The repository must already have an origin remote and a dev-preview branch; otherwise use your team’s actual integration branch.
cd C:\Projects\my-app
git status --short
git fetch origin
git worktree add -b agent/login-fix C:\Projects\worktrees\my-app\login-fix origin/dev-preview
git worktree add -b agent/docs-update C:\Projects\worktrees\my-app\docs-update origin/dev-preview
git worktree list
git worktree list shows once both folders exist. The hashes are illustrative. Each line is one working folder with its own branch.Check the first status output before continuing: save unrelated work rather than letting it become part of the task. Start each agent in its assigned folder. Tell it the branch it should integrate into, the task’s scope, and how to verify the result.
A new worktree does not automatically contain ignored dependencies or local environment files. Install the project’s dependencies using its documented command. Supply only the development configuration that task needs. Never copy production credentials into an agent’s folder as a convenience.
Some tools can create the worktree for you. Claude Code has a --worktree (-w) flag that starts a session in an isolated worktree under .claude/worktrees in the repository, and OpenAI’s Codex desktop app offers a Worktree option for new threads. Either way, you should still know which folder and branch each agent is using.
Give each agent a brief you can review
A useful brief includes the observed problem, the expected result, the files the agent may change, and the checks it should run. A login task might say:
Fix the login error shown when an email contains leading spaces.
Work in the login-fix worktree only.
Keep the public API unchanged.
Add a regression case for the failing input.
Run the repository's documented checks.
Report the changed files and any remaining uncertainty.
Ask the documentation agent to avoid the login implementation. Agree on shared dependencies first: if both tasks need the same schema change, land that prerequisite before splitting the remaining work.
Review and integrate one task at a time
In each worktree, inspect git diff, run the repository’s checks, and commit only the intended files. Do not accept “tests passed” without knowing which commands ran and whether those checks cover the bug. The review checklist goes into this in more detail.
After the first task is accepted into your integration branch, refresh and rebase the second task before reviewing it:
cd C:\Projects\worktrees\my-app\docs-update
git fetch origin
git rebase origin/dev-preview
git diff origin/dev-preview...HEAD
Resolve conflicts deliberately and run checks again when integration changes the result. Use your team’s pull-request process or an authorised fast-forward integration. Never force-push a shared integration branch to make parallel work fit.
Integrate one task at a time
Accept the first task
Read its diff, run the checks, commit only the intended files, integrate it.Refresh the second task
git fetch originin its folder.Rebase it on the integration branch
git rebase origin/dev-preview. Resolve conflicts deliberately.Review it again
git diff origin/dev-preview...HEAD, then run the checks again.Integrate it
Your pull-request process or an authorised fast-forward. Never force-push the shared branch.
Separate worktrees isolate edits, not runtime resources. Two development servers can still compete for a port. Two test suites can still change the same database. Use separate ports and disposable test data where those resources are shared.
What a worktree separates
Separate per worktree
- Working files
- The checked-out branch
- Uncommitted changes
Still shared
- Ports for development servers
- Databases and test data
- Installed tools
- Commit history
Clean up after the changes are accepted
Before removing a worktree, check for uncommitted and ignored files you need to keep. Then remove the finished worktree from the original repository using Git, rather than deleting the folder manually:
Clean up, annotated
cd C:\Projects\my-appgit -C C:\Projects\worktrees\my-app\login-fix status --short1git worktree remove C:\Projects\worktrees\my-app\login-fix2git branch -d agent/login-fix3- 1Anything listed is not committed. Keep what you need before going on, and check ignored files too.
- 2Let Git remove the folder. If it refuses, find out why; do not add a force flag.
- 3
-ddeletes the branch only once it has been merged.
If Git refuses, investigate. Do not add a force flag just to clear the warning. Keep backups and local configuration until you have confirmed they are no longer needed.
Where Towfu fits
Towfu brings your coding-agent CLIs into a Windows workspace and can give each agent its own Git worktree. That helps you see the sessions together while keeping their edits apart. It does not make competing edits compatible or replace your review.

You can use this workflow from ordinary terminals, too. Towfu is useful when the folders, sessions and account status become difficult to keep track of. See Towfu’s workspace features, read how to work with Claude Code and Codex together, or see how to run agents unattended once one task at a time feels comfortable.