Autonomous Multi-Session AI Coding Without Worktrees

Fazm Team··2 min read

Autonomous Multi-Session AI Coding Without Worktrees

The conventional advice for running parallel AI coding agents is to use git worktrees - each agent gets its own working copy to avoid file conflicts. But there is a simpler approach that works surprisingly well: skip worktrees entirely and run five Claude Code instances on the same repo.

Why Worktrees Are Overkill for Most Tasks

Git worktrees solve a real problem - file-level conflicts between concurrent edits. But most well-scoped tasks touch different files. If one agent is working on the API layer and another is updating the UI, they are not editing the same files.

Worktrees add overhead: setting them up, managing branches, merging back. For a solo developer running a few agents in parallel, that overhead eats into the time savings.

The Same-Repo Approach

The setup is straightforward. CLAUDE.md has the project spec and architectural context. Each agent gets a discrete, well-scoped task via its conversation prompt. The tasks are chosen to touch different parts of the codebase.

Agent 1 might be adding a new API endpoint. Agent 2 refactors the test suite. Agent 3 updates documentation. Agent 4 fixes a CSS layout bug. Agent 5 adds a new database migration.

These tasks naturally touch different files, so conflicts are rare.

When Conflicts Do Happen

Occasionally two agents edit the same file. Git handles this gracefully most of the time - if the changes are in different parts of the file, the merge is automatic. When there is a real conflict, you resolve it manually, which takes a minute.

The key insight is that conflict resolution time is almost always less than worktree management time for small teams.

Making It Work

Three rules keep this approach reliable. First, scope tasks to different directories or modules. Second, put shared context in CLAUDE.md so every agent follows the same conventions. Third, commit frequently so merge conflicts stay small.

The CLAUDE.md file is the linchpin. Without it, agents make inconsistent decisions about naming, patterns, and architecture. With it, five agents write code that looks like one person wrote it.

More on This Topic

Fazm is an open source macOS AI agent. Open source on GitHub.

Related Posts