Give each coding agent its own Git branch and worktree. Start both from the same reviewed commit, agree on what each agent may change, and test the changes together before merging. You can run Codex and Claude Code this way, or use two sessions of the same tool.
A worktree keeps one agent's uncommitted edits out of the other's checkout. The harder question is whether both agents are still building the same thing. Two branches can pass their tests, touch different files, and merge cleanly while disagreeing about what an API returns.
Start both agents from the same commit
A Git worktree is an additional checkout linked to the same repository. Each worktree has its own checked-out files and staging area. The worktrees still share repository history and most Git references. Each agent should get a distinct branch so its changes can be reviewed separately.
From your primary checkout, verify that HEAD is the committed base you want both agents to use. If you are starting from the latest commit on a remote branch, fetch and select that commit first. From a checkout of the chosen commit, run:
base=$(git rev-parse HEAD)
git worktree add -b parallel/search-api ../search-api "$base"
git worktree add -b parallel/search-ui ../search-ui "$base"Start each session in its assigned directory. Ask it to confirm its current branch and working directory before editing. Any uncommitted files in the primary checkout stay there, so set up local dependencies and configuration for each worktree as needed. Use a separate port, test database, or container environment wherever the tasks would otherwise share mutable state. Worktrees do not provide runtime isolation or restrict an agent's permissions elsewhere on the machine.
Split the work at an agreed interface
Suppose a software team is updating its account search page. One session handles the search API. The other improves how the UI displays the results. Each can write code without editing the other's files, but they both depend on what comes back from search.
Before starting, give both agents the same brief. It can be short enough to read before opening the editor:
| Item | Agreement for this change |
|---|---|
| API owner | Owns the search endpoint and its tests. Suggests any response changes. |
| UI owner | Owns the results component and its tests. Builds against the agreed response. |
| Current contract | Search returns an array of result names in this simplified example. |
| Change rule | Flag any change to the response before treating it as agreed. Name the affected callers and the owner of the update. |
| Done when | Both branches pass their own tests, and the UI renders results from the actual API in a combined check. |
An agreed response shape gives the UI agent something stable to stub. An agreed change rule tells it when that stub is out of date. If both tasks need to change the same schema or migration, give that shared change one owner and complete it first. The other agent can review call sites or write tests against the intended behavior in the meantime.
What a clean merge can miss
In a small local Git example, we simulated what happens when the API branch adds pagination before the two sides agree on the change. Its result moves from an array to a page object with items and nextCursor. The UI branch adds result labels and tests them with the original array as input.
Both branch tests pass. Git merges both branches into a disposable integration worktree without a conflict. Even there, the two original unit tests still pass. Only when the integration check sends the API's real result into the renderer does the failure surface: the UI calls .map() on an object.
That is a useful place to stop and make a decision. If other clients still expect an array, changing the existing endpoint may break them too. Keep the response compatible or plan a versioned change and a migration. In this small example the UI is the only caller, so we kept the page object, updated the UI test to use it, and saved the combined test as a regression check. The combined behavior then passed. The primary branch stayed untouched throughout the exercise.
On a real team, bring the reviewed changes together on a temporary integration branch or through your team's combined CI workflow. Test the actual boundary the agents share, such as an endpoint and its caller, a migration and its queries, or an event and its consumer. For each passing check, record the commit or pair of commits it covered. A later change can make that result stale.
Keep the decision where both sessions can find it
At the point where pagination changes the agreement, updating the API branch is only half the work. Someone needs to tell the UI owner exactly what changed, which revision to build against, and what still needs proving. A note that says "pagination is done" does not answer any of those questions.
In one Swarm Space, save the two briefs as separate Tasks and put the interface agreement in a shared record. Connect each compatible agent to that Space with the access it needs. Give both sessions the location of the agreement and ask them to read it before editing and again before handing back work. Keeping the record in one place is useful even if one person updates it by hand.
When the human owner accepts the page object, update the current agreement and link the relevant commit or pull request. A useful handoff says: "The UI now consumes items from the page object. Build against the API revision linked here. Run the combined search test; the API unit test alone does not cover rendering." The UI owner can acknowledge the revision it used and return the actual check result in the same Space. For longer projects, the guide to sharing project context across AI tools explains what else to carry between sessions.
Keep the diff, required checks, and merge decision on the repository side. GitHub pull requests are where reviewers inspect the proposed changes and see check results. Use the Space to find the agreement and understand why it changed. A record of a passing test in Swarm is a pointer to evidence, not a substitute for inspecting the result on the right revision.
When to use one writer and a reviewer
If both agents need to rewrite the same module while its design is unsettled, a second writer usually gives you more changes to reconcile. Give one agent the implementation and have the second inspect the diff, find missed callers, or propose a regression test. Use a read-only configuration in the reviewer host when supported. A prompt saying "review only" expresses intent; it does not enforce access. The AI code review guide covers how to turn that second pass into evidence a person can use.
For a first trial, pick two small changes with one clearly named dependency. Create a Space for the pair, save the two briefs, and agree on the check that needs both branches. Before opening the second session, see whether it can answer three questions from the shared record alone: What am I responsible for? Which version of the interface am I using? What evidence will show that our changes work together?