Claude Code agent teams on one repository
A Claude Code agent team is a set of agents that work on the same repository at the same time. Running multiple Claude Code agents in parallel is fast, because each one takes a task and no one waits. The hard part is not starting them. It is landing their work together, because two agents can change code that depends on each other and still each pass on its own.
The short answer
Give each agent its own git worktree, so they stop saving over each other's files. Keep a short team, two to four agents, where the tasks touch different parts of the code. Then test the combination before anything reaches main, because a clean git merge does not mean the merged code works. That last step is the one most teams skip.
Give each agent its own worktree
Two Claude Code agents in one folder edit the same files and save over each other. Each one then tries to fix code it did not write, and both slow down. A git worktree is a second working folder on its own branch that shares the one repository, so each agent gets a clean copy of the files.
claude --worktree shop-cart # one agent, its own branch and folder
claude --worktree shop-search # a second agent, side by side
git worktree list # every worktree the repo has open
Claude Code makes a worktree under .claude/worktrees/ on a branch named after the task (Anthropic, Run parallel sessions with worktrees). This is the base of every agent team. It solves the file collision and nothing more. Each agent now tests only its own copy, so the suite never runs on the two changes together.
Where a team still collides
Two agents can clash in two ways. In a textual conflict, both edit the same lines, and git stops the merge to ask what to keep. In a semantic conflict, they edit different lines that depend on each other. Git merges those without a word, and the combined code is wrong.
Textual conflict
Both agents edit the same lines. Git stops the merge and asks you what to keep.
Semantic conflict
The agents edit different lines that depend on each other. Git merges them, and the result is wrong.
Agent pull requests rarely arrive alone, so this is common. Xu, Subramanian and Karthik studied 33,596 agent pull requests in 2,807 GitHub repositories. 79.4% of them were open at the same time as another agent pull request in the same repository (Xu et al., AI Agent Pull Requests on GitHub, arXiv 2607.04697).
We measured how often overlapping pairs clash. We replayed 733 pairs of real agent pull requests from public projects and merged each pair with git. Git reported a textual conflict in about one pair in four. Of the clean merges we could test end to end, one no longer built. The full method is in How often do AI agent pull requests break each other?
of 733 overlapping pairs hit a textual git conflict
clean merges we could test end to end failed its tests
A simple order to run a team
Start few agents and keep their tasks apart. One agent on the cart, one on search, one on the checkout page. The more two tasks share, the more they collide. Then follow four steps.
claude --worktree cart # 1. one worktree per agent
git merge-tree --write-tree --name-only cart search # 2. do the branches even merge?
git worktree add --detach ../combo cart && cd ../combo # 3. a spare copy to test the combination
git merge --no-edit search && npm ci && npm test # 4. run the suite on both together
git merge-tree exits 0 for a clean merge and 1 for a conflict, and it touches no worktree. A clean result still tells you nothing about meaning, so step four runs the real tests on the combined code. For the longer version of this with Claude Code hooks, read Run multiple Claude Code agents in parallel.
The work grows fast. Four agents make six pairs, and every new commit from any agent makes its pairs out of date. By hand, you end up re-running the same checks all day. A warning helps most while the agent is still working and can adapt, not after it finishes and its context is gone.
What gitta adds across the team
gitta watches every worktree of the repository, whichever tool made it. You run one command in the main checkout, and the gate is your own test command.
gitta init --gate "npm ci && npm test"
gitta uses no AI model to judge the code. It parses each changed file with Tree-sitter, finds the functions, classes and fields an agent changed, and follows what each agent's new code uses up to three steps away. When agent A changes something agent B's new code relies on, B gets a warning inside its own Claude Code session at its next step, through hooks. You see the same picture by hand.
gitta status # every agent, its files and its warnings
gitta check search --with cart # PASSES, BREAKS or DOES_NOT_MERGE
You merge with git merge, git pull or git push, as always. gitta runs the gate on the combined code before main moves and stops the merge when the tests fail. Keep your worktrees and your agents. gitta gives the team the view across them. For why worktrees alone leave this open, read Why git worktrees don't prevent agent conflicts. To weigh the tools that run agent teams, read Conductor, Claude Squad, Vibe Kanban and gitta compared.
Questions teams ask
How many Claude Code agents can I run at once?
As many as your machine and your task list allow. The limit in practice is coordination, not compute. Two to four agents on tasks that touch different code stay easy to land. Past that, the pairs that can collide grow faster than the agents, so you need a way to test the combinations rather than each change alone.
Do git worktrees stop Claude Code agents from conflicting?
Only partly. Worktrees stop two agents saving over the same files while they work. They do not check that the finished changes still fit together. Git can merge two worktrees cleanly and the merged code can still fail to build, which is a semantic conflict.
Can I run Claude Code and Cursor agents on the same repository?
Yes. Both make git worktrees or branches, so they coexist on one repository. The collision risk is the same as two Claude Code agents. See Cursor background agents vs Claude Code.
How do I test two agents' work together before merging?
Make a spare detached worktree, merge the second branch into it, and run your normal test command there. git merge-tree --write-tree first tells you whether the two branches even merge without a conflict.