DEV Community

Nic Flemmer
Nic Flemmer

Posted on

Where should a coding agent's git worktree live?

Giving each coding agent its own git worktree is the easiest way I know to stop agents trampling each other, and you. The part I keep going back and forth on is where the folder goes.

In Styx I put it next to the project, not inside it. For a repo at ~/code/shop, a Claude task gets ~/code/.styx/worktrees/shop/agent-claude-1, on the branch agent/claude-1. The folder you have open in your editor never sees it: no branch switches, no half-finished edits in your working tree, so you can keep coding on your own branch while three agents work on theirs.

The cost is that the agent's folder isn't the one your editor has open. You open it on purpose, with an "Open in" button on the task, and edits you make there are listed apart from the agent's own.

There's one place your main folder does come back in: merging. Landing a task merges its branch into main in the project folder you added, so that folder has to be on main with nothing uncommitted. If it isn't, Styx says so and does nothing, rather than merge over your work.

So my current answer is "next to the repo, and your checkout is only touched at the last step". I can see the case for the opposite: inside the repo, gitignored, so everything for one project is under one directory.

Where do you put yours: inside the repo, next to it, or somewhere temporary? And what made you pick that?

Top comments (0)