Kemet Dugue

← Writings

Scaling AI Development with Git Worktrees

April 25th, 2026

agents ai

Since transitioning to agent-based development, I’ve found myself wanting to extend my development workflow, especially when using multiple agents. I noticed a bottleneck when using agent workflows: if I had to work on multiple unrelated work items, I was still stuck in a synchronous cycle.

Even though I had multiple agents available to help, I was limited by being on the same branch in a single directory. If I needed one agent to handle a task and another to handle a different task, I was forced to stop one agent, stash its progress, and switch branches just to let the second one start.

I recently discovered git worktrees and found that this was a perfect solution to my bottleneck.

At a conceptual level, git worktrees allow you to work on multiple branches of the same repository in separate directories simultaneously. In other words, you can work on different features or subfeatures while keeping the state of those changes intact (without needing to stash or make unmeaningful commits).


A Real Use Case

Recently, I was working on a feature adding a button component to an existing design. While that agent was working, Data Science requested updates for an event’s metadata.

My typical workflow would include:

  1. Stashing current changes: Even in an agentic workflow, this is basically asking the agent to undo its changes so I can clear the “desk.”

    git stash save "work in progress button"
  2. Creating a new branch: I’d have to move the entire environment to a new branch for the metadata change.

  3. Switching back: Once the metadata was done, I’d have to revert the environment and pop the stash, forcing the first agent to re-index and “remember” its state.

With git worktrees, the workflow looks like this:

  1. Create a separate worktree: I spin up a new directory for the metadata task.

    git worktree add ../metadata-update ds-metadata-update
  2. Parallel Agent Development: Agent A continues working on the UI button in the original folder, while Agent B starts the metadata update in the new folder.

  3. Zero Downtime: Both agents finish their work in parallel. I never had to tell an agent to stop or save its state.


Why this matters for Agents

Worktrees are a force multiplier for agentic workflows because they solve the physical bottleneck of the directory. Without them, you are capped at the speed of a single branch.

By using worktrees, I can finally align my local environment with the parallel nature of AI development. It allows for true scaling, risk-free experimentation, and the ability to juggle multiple features without the mental overhead of stashing.