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.

Separate branches alone do not help if both agents share one checkout. Separate folders do.

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
Example PowerShell output of git worktree list: the main checkout on dev-preview, a login-fix folder on agent/login-fix and a docs-update folder on agent/docs-update, each with a commit hash.
What 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.

The second task is reviewed against what the integration branch looks like after the first one landed, not before.

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
Worktrees isolate edits, not runtime resources. Give each task its own port and disposable test data where they would collide.

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 --shortgit worktree remove C:\Projects\worktrees\my-app\login-fixgit branch -d agent/login-fix
  1. Anything listed is not committed. Keep what you need before going on, and check ignored files too.
  2. Let Git remove the folder. If it refuses, find out why; do not add a force flag.
  3. -d deletes the branch only once it has been merged.
The cleanup commands from the text with what each one protects you from.

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.

The Towfu Board for a sample project with To do, Doing, Review and Done columns. A card in Review is labelled with the agent that worked on it and offers Create PR, Send back to Doing and Mark done.
The Board in Towfu (sample project). Starting a card asks for confirmation and can give its agent a separate worktree. A card in Review shows which agent worked on it, so you can check the changes and create a draft pull request.

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.