In last week's issue of "Building an RTS in Godot. What if Claude writes ALL code?" I promised to explore the limits of Claude Code and today is that day.
One way to push the boundaries of Claude Code is to turn a single Claude into many Claudes! This theoretically allows you to do twice the work in the same time it would take to build a single feature.
But using multiple agents has (at least) one significant problem...
If both agents work on the same file, all hell breaks loose. They’ll overwrite each other’s edits and manipulate the other agent’s context.
How do you prevent agents from stepping on each other's toes?
You need a way to keep their workspaces separate, like putting them into separate rooms of an office to avoid disturbing each other.
We can create those separate spaces with git-worktree
Let's say I want to implement a small quality of life feature and work on another feature simultaneously.
How to use git worktree
?
I navigate to my project folder.
cd /Users/lucca/Godot/mobsters
I create a separate project version with git worktree.
git worktree add ../mobsters-worktree/find-my-mobster -b feat/find-my-mobster
I create a separate terminal tab where I navigate to the new worktree folder.
cd ./../mobsters-worktree/find-my-mobster
I can now start a Claude Code session in the first and second tab and work on separate features. (running
claude
)Once I'm done, I commit my changes to my repo and navigate back to my main worktree (
/Users/lucca/Godot/mobsters
) to remove the linked worktree withgit worktree remove ../mobsters-worktree/find-my-mobster
To find your main worktree, use git worktree list
Why not duplicate the folder?
Duplicating your repository folder takes more space than creating a git-worktree "copy".
Git keeps your repository copies in sync. (e.g. fetches happen on all worktrees, git keeps you from checking out the same branch twice)
Caveats
Despite the appeal of this parallel working method, it hasn’t become my default yet.
Setting up worktrees takes time. Depending on the project, I have to copy over files that are not checked into version control or install dependencies. Often, it’s not worth it for a change Claude finishes in 10min.
Juggling multiple Claude sessions is like moderating two separate meetings in neighboring conference rooms - you're endlessly ping-ponging between rooms, keeping track of different discussions, and trying to give meaningful input to both groups without losing the thread of either conversation. The mental gymnastics of context switching not only wears me out but makes me wonder how well I'm steering each session. Especially if Claude regularly needs my input on both features. I can benefit from the parallel approach if one feature is long running and lets me focus on the other.
It sucks up tokens like a Dyson V15. This is so far the only way how I exceeded my Claude Pro Subscription Usage.
I'd love to hear about your experience using multiple agents and how you deal with the context switch.
Top comments (0)