Skip to content
New: answer your agents from your phoneLearn more

Git worktrees give coding-agent tasks room to work.

A worktree checks out another branch into another directory while sharing the repository's underlying Git data. That makes it a practical boundary for concurrent agent tasks.

Why a branch alone is not enough

Branches separate commits, but two processes using one checkout still share its files, index and current branch. If multiple agents edit that checkout concurrently, one task can observe or overwrite another task's uncommitted state.

A worktree gives a branch its own directory. Each agent can run commands, change files and keep uncommitted work within that directory while the primary checkout remains available.

What worktrees share

Worktrees belong to one repository and share its object database and references. They are lighter than making a completely separate clone for every task, while still presenting a normal project directory to editors, shells and coding agents.

Keep setup repeatable

A useful agent worktree needs the same project setup its base checkout expects. Make dependency installation and local configuration repeatable, and avoid copying secrets or generated state that should remain unique to one environment.

Isolation does not replace review

A separate directory prevents accidental file collisions, but two branches can still make incompatible design decisions. Review each diff against its base, run the project's checks and account for branches that merged while the task was running.

Read the parallel coding-agent workflow.