VCode home

Have agents work in worktrees

Agents: claude, codex, opencode · On: phone, desktop

Work on, in the cog's Git group, decides where agents make code changes. With Worktree, the default, every agent is told to put each task on its own branch in a git worktree under worktrees/, and to remove the worktree once the branch is merged. In a folder that is not a git repository it works in place. With Main, agents are told nothing about it.

Why you would use it

Several tabs work in one repository at once and you want each task kept apart until you merge it. On the explorer's Changes tab each tab's files show under its worktree's heading, and the agent cleans up after itself so the list does not fill with finished branches.

How to use it

  1. Tap the cog (#settings-open).

  2. In the Git group, Work on (#git-work-on) reads Worktree unless you changed it. Pick a value and the group's status reads Saved.

    The Git group in settings: a line saying where agents make code changes, and Work on set to Worktree

  3. Start a turn. The agent reads the setting each time it starts, so a tab already open picks it up the next time its agent starts.

Pick Main to go back to agents working where they are.

What you see

With Worktree, an agent asked to change code in a git repository:

On the Changes tab each worktree has its own heading, its repository's name, › and the worktree's folder name, and its branch.

Options and settings

Option Default What it changes
Work on (#git-work-on) Worktree Worktree adds the worktree instructions to what every agent is told. Synced to every workstation on your account

Limits and known gaps