Agent Tile BlogRunning a fleet of AI coding agents, well.

Using Git Worktrees to Run Multiple AI Coding Agents Safely

· git, workflow, fleet

When two AI coding agents work in the same repository at the same time, they fight: one switches branches while the other is mid-edit, uncommitted changes collide, and you spend more time untangling than shipping. Git worktrees fix this cleanly by giving each agent its own working directory on its own branch.

What a worktree is

A worktree is an additional checkout of the same repository, linked to the same .git history but living in a separate folder on a separate branch. git worktree add ../feature-x feature-x gives you a second directory where an agent can work without touching your main checkout.

Why it fits multi-agent work

  • No branch tug-of-war. Each agent stays on its own branch in its own folder. One agent switching branches can't yank the rug out from another.
  • Uncommitted work is isolated. Edits in one worktree don't appear in another until they're committed and merged.
  • Shared history, cheap setup. Worktrees share the object store, so they're far lighter than full clones and still share commits.

A simple workflow

  1. One worktree per task/agent: git worktree add ../fix-refund fix-refund.
  2. Point one agent at each folder. The agent's session lives in that directory and only that directory.
  3. Encode the folder in the session's name so you never act on the wrong one — see session naming conventions.
  4. Clean up when merged: git worktree remove ../fix-refund.

The identity problem worktrees create

Worktrees solve collisions but multiply near-identical terminals — now you have several folders that look alike. That's exactly the "which session is this?" risk from running multiple sessions in parallel. The answer is the same: make each session's folder and branch visible at a glance. That per-directory visibility is part of why we relaunch every session with --resume in its original worktree in Agent Tile.

Takeaway

Git worktrees let multiple AI agents work the same repo without colliding — separate folders, separate branches, shared history. Pair them with clear per-folder session identity so the isolation on disk is also obvious on your screen.

Agent Tile
Practical guides for running many Claude Code sessions in parallel on macOS — orchestration, review workflows, and staying sane with a fleet of AI coding agents.
Get Agent Tile — full source, $10 once →
Also from TechAthletes
  • IT-QA — Technical Q&A with AI-assisted answers and point bounties — for the questions that come up while you're running a fleet.