Blog · Guide · 25 November 2026

A Repository Per Agent: Forks, Pushes and Collecting the Results

When one agent starts twenty others in cloud sandboxes, each of the twenty needs somewhere to put its work. A shared branch means twenty agents pushing over each other. Twenty branches on the team's main remote means twenty sets of credentials copied into machines nobody watches, and a remote full of branches nobody asked for. A repository per agent avoids both: each agent gets its own fork, a token that lasts minutes, and nothing it can push to except that fork. This guide walks through how Forkit does it, from starting the fan-out to collecting the branches.

Why agents need their own repositories

Two infrastructure write-ups from 2026 describe the same pressure. Cursor's "Git at any scale" (18 Aug 2026) explains that agents create very many small repositories that sit idle most of the time, and describes a storage design that took up to 120 pushes a second on S3 Standard and over 300 on S3 Express One Zone. Cloudflare's announcement of Artifacts (16 Apr 2026) calls it "a versioned file system that speaks Git": repositories created from code, imported from an existing Git repository, and forked, each reachable from an ordinary Git client with a token.

Forkit uses Cloudflare Artifacts for this. Neither post discusses what happens after the pushes: whose work it is, whether it was really pushed, and how twenty branches become one result. That is the part Forkit adds.

Two ways to start

A fan-out is the set of short-lived keys one agent creates for the agents it starts elsewhere (see agent fan-out explained). It can be started with a repository in one of two ways.

From a public repository. Give the fan-out a URL:

forkit fanout create --name docs-fix --agents 20 --repo https://github.com/acme/docs --branch main

Forkit imports that repository once, as the fan-out's base. If an import is still running after two minutes, the next agent that asks starts it again.

From any private repository. Give it your checkout instead:

forkit fanout create --name billing --agents 20 --repo-from ./billing --branch main

Here Forkit creates an empty base repository and hands the starting agent a write token for it. The CLI pushes your checkout's branch and then tells Forkit the base is ready. Forkit refuses "ready" until the branch has a commit, and agents that ask for their repository before that are told to wait.

Why two ways? Artifacts imports public repositories only. On staging on 17 Nov 2026 a private import was refused with "Only public repositories can be imported" (HTTP 401), with and without a login in the address. So Forkit takes no repository token at all. A token or a login in the URL is refused with that reason, and private code reaches the base by being pushed from a checkout you already have.

Each agent's own fork

Every agent asks for its repository with its own key:

curl -X POST https://forkit-mcp.com/api/v1/repo \
  -H "Authorization: Bearer $FORKIT_API_KEY"

The first time it asks, Forkit forks the base for it, named after the fan-out and the agent. The answer carries the fork's address and a write token that lasts at most 15 minutes. With ?token=0 the answer says only where the fork is; the session-start hook uses that to tell a fan-out agent where its repository lives.

Fifteen minutes is short for a long task, so agents do not keep the token. POST /api/v1/repo/credential answers in git's credential-helper format, which makes the helper one curl line. Git asks for a fresh token whenever it needs one.

You can set this up two ways:

  • forkit init --sandbox writes the helper into the sandbox's global git config, for https://*.artifacts.cloudflare.net only. It adds an empty helper entry first, so a keychain or other helper does not store a token that expires in minutes.
  • forkit repo clone writes the same helper into one clone.

Forkit stores no token and writes none to disk. In the staging test on 17 Nov 2026, a sandbox set up with forkit init --sandbox cloned and pushed with plain git and no Forkit CLI.

What a fork's token can do was checked in production the same day with a probe Worker (since removed), one run each: a fork's token was refused on another repository, and a read token was refused for a push. Making a fork from a Worker took 2.1 to 2.4 seconds.

Pushes become verified files on the agent's thread

An agent's hook reports which files it changed. That report comes from the agent's side, so a review that relies on it trusts the agent. A push is different: the commits are in the repository, and Forkit can read them itself.

Every push to a fork starts a Cloudflare Workflow. It reads the tree before and after the push, opening only folders whose hash changed, and writes two events on the agent's latest thread:

  • a code event listing the commits
  • an artifact event with the changed paths, marked verified: true, and the commit after the push

Both are written by a system actor named "Forkit repo", and the thread's head commit is set. A push delivered twice is recorded once, because the commit is claimed before anything is written.

This matters for review. Forkit's reviews already count every artifact event on a thread when they work out which files a review covers, and approval rules map path globs to the people who must approve. With pushes recorded this way, those rules apply to files Forkit read from the repository. On staging on 17 Nov 2026, a push was recorded with its two changed files 8 seconds after it was made. In the production probe, a push started the Workflow 1 to 3 seconds later. For more on reviewing this work, see how to review agent pull requests.

Collecting the results

When the agents are done, the agent that started the fan-out lists the forks:

curl https://forkit-mcp.com/api/v1/fanouts/$FANOUT_ID/repos \
  -H "Authorization: Bearer $FORKIT_API_KEY"

The list carries no tokens and works after the fan-out has ended. For each repository it can ask for a read token that lasts 15 minutes. The CLI does all of this in one command:

forkit fanout collect $FANOUT_ID ./collected --merge

It clones the base and fetches every fork that was pushed as a branch named agent/<name>. With --merge it merges them one at a time into fanout/<name>. An agent whose branch conflicts with what was merged before it is left as its own branch, and the command exits with code 3 so a script can tell.

The merge is git's. Nothing runs your tests on the merged result. Run them yourself after the collect.

What three recorded runs showed

Forkit recorded three runs on staging, one run each, with Claude Code agents (Sonnet):

Run Date Agents Timing Collect --merge
A units CLI, one family of units per agent, from --repo-from ./units 17 Nov 2026 6 all pushed 65 s after start 6 branches, no conflict; 28 of 28 tests pass
One hypothesis each about the Palmer Penguins dataset 20 Nov 2026 12 all pushed 69 s after start 12 branches, no conflict
One model each of the Mauna Loa CO2 record 21 Nov 2026 12 run finished 63 s after start 12 branches, no conflict; every result file matched a reference written beforehand

In all three the work was split so that each agent wrote its own files, which is why nothing conflicted. In the end-to-end staging test on 17 Nov 2026, two agents were collected with --merge and one was left as a conflict branch, which is the case the exit code exists for.

Tokens after a fan-out ends, and cleaning up

  • A stopped or ended fan-out's agents get no new tokens.
  • Stopping a fan-out by hand revokes tokens already handed out at once. For fan-outs that ended any other way (time up, a budget reached), a sweep that runs every minute revokes them. In the staging test, after forkit fanout stop the agent's push was refused.
  • forkit fanout clean ID deletes every fork and the base. It is refused while the fan-out is running; in the staging test it was refused while running, then deleted 3 repositories.
  • Otherwise an hourly sweep deletes them after the fan-out ends. How long they are kept depends on the plan unless the fan-out asks for a number with --keep-days: 1 day on Free, 7 on Pro, up to 365 on Team.

Cloudflare bills Artifacts by operations and GB-months from 19 Nov 2026. Deleting forks you have collected keeps that small.

What this does not cover

  • Private imports. A private repository has to be pushed from a checkout with --repo-from. In the staging test a private GitHub repository was pushed that way, cloned by an agent, changed and recorded.
  • Tests on the merged code. collect --merge uses git's merge. Two branches that merge cleanly can still break each other; run the suite after collecting.
  • Your sandboxes. Forkit gives each agent a repository and a key. It does not start agents or machines, and it does not delete the sandboxes.
  • Local development. Wrangler's Artifacts simulator handled import, fork, clone and push, but local dev publishes no push events, so pushes are not recorded there.

When a fork per agent is the wrong tool

On one machine, git worktrees give each agent its own copy for free, and nothing needs a server (git worktrees vs file leases compares them). A fork per agent pays off when agents run in sandboxes or CI, where you do not want the team's own credentials, and when you want each push recorded where reviews and approval rules can use it.

Either way, separate repositories only move conflicts to the merge. If two agents' tasks touch the same files, give the files one owner before they start, as described in how to run 50 coding agents without merge conflicts.

Where Forkit fits

Forkit is the coordination system for agent teams: plans, handoffs, file claims and decisions, shared by every agent and the people behind them. For a fan-out it provides the keys, a fork and a short-lived token per agent, pushes recorded on each agent's thread, and the collect. Your planner and your sandboxes run the agents. It is free to try at forkit-mcp.com.

Sources

Read on 25 Nov 2026: