
How git worktrees enable effective collaboration with multiple coding agents without the context switching penalties
I had never even heard of git worktrees before a couple of weeks ago, and I've been working with git professionally on and off for at least a dozen years.
Turns out, they're just the ticket for solving my problem of sitting and waiting for a coding agent to crank through a longer running hard task - allowing me to easily switch to another related task and collaborate with another agent on that.
I think Codex and Cursor's and its competitors background agents along with Devin are attempting to productize this type of thing, but this also lets me keep everything local which for a lot of environments is faster.
So, I asked Claude Code to write me a quick script to create a new worktree with a branch name I give it and pop a new cursor window in that context. It put some guardrails in bash I wouldn't have thought of to make sure I'm not doing something dumb by accident, and suggested an alias to make it memorable. I also had it make another script and alias to help me clean up after I'm done with it.
Context switching is the enemy of most software engineering, but as long as I'm not switching to another project entirely, this is the type of multi tasking I think has promise.
At first blush it feels more like hands on working with a team, not just pairing. I think both modes of working have their place, with people and with robots.
Know when to hold em, fold em, walk away, and run when working with AI development agents
My workflow makes it easy to spin up 10+ parallel agent threads, but 5 or 6 well-sized tasks is the sweet spot - for my sanity and to keep the final review pile manageable.
Why Claude Code outperforms me at writing code, and where humans still have the edge
Get More Like This
Follow along as I build and share what I learn
Found this helpful? Share it with your network!