Blog · Guide · 25 November 2026

Migrating a Monorepo With One Agent Per Package

A migration across a monorepo is the job that splits most cleanly between coding agents. Two hundred packages need the same change: a new HTTP client, a framework upgrade, a renamed API. Each package is a unit of work with its own tests. One agent per package should finish in the time it takes to do one.

In practice, the run goes wrong in predictable places. Agents all ask the same question at once. Two agents edit a shared helper. A few agents never finish. The planner cannot tell which packages are done. This guide walks through a setup that handles each of those, and reports what Forkit measured when it load-tested exactly this scenario.

What teams have reported

Three accounts from this year frame the job.

Navan with Cursor (Cursor customer story, 16 Oct 2026). Navan moved to Spring Boot 4 across 8 applications and 15 libraries. The previous migration "took Rahul Popuri, Sr. Staff Software Engineer, over a month." This one "finished in about a week without freezing development." That is a vendor's customer story, and it does not say how many agents ran at once.

Cognition, "How Devin Is Modernizing COBOL at Fortune 500 Companies" (8 Apr 2026). One example moved a 25,000-line COBOL customs workflow to AWS Lambda. Because the workflow was a batch job, the rewrite could be checked against known outputs. The post says the migration "required a playbook": written instructions for how Devin should do the work.

Linear, "AI coding has made CI a bottleneck, so we reworked ours to keep up" (Mufeez Amjad, 21 Sep 2026). Linear's test suites grew almost fourfold during 2026. "Every PR still has to pass through CI, so as development accelerates, CI becomes a bottleneck."

Read together: a migration goes faster with agents when each piece can be checked by itself, when the instructions are written down once, and when the checking at the end can keep up.

The shape of the run

A planner agent, started by a person, owns the migration. It does five things:

  1. Lists the packages and the order they must go in.
  2. Starts a fan-out: one worker agent per package, each with its own key.
  3. Answers nothing itself. Workers' permission questions go to rules and to a person.
  4. Reads each worker's handoff as it arrives.
  5. Collects and merges the work at the end.

Each worker does four things: claims its package, makes the change, runs the package's tests, and hands off a result. Nobody sits beside the workers.

Step 1: List the packages, in order

Packages depend on each other. A package should be migrated after the packages it imports. Forkit's tasks can carry dependencies: the planner creates one task per package inside execute_code and adds a blocks dependency from each package to the packages that import it. ready_tasks then returns only the packages whose blockers are done, so the planner starts workers in waves. See task dependencies for agents.

For a migration with no ordering between packages, skip this and start every worker at once.

Step 2: Start the fan-out with limits

forkit fanout create --name migrate-http --agents 200 \
  --ttl 3600 --max-tool-calls 20000 --max-cost 50 \
  --repo-from .

This returns 200 keys once, named migrate-http-001 and onward. With --repo-from, the planner pushes its own checkout to an empty starting repository, and each worker asks Forkit for its own fork of it. Forkit takes no repository token, so this works for a private monorepo.

The limits matter more than the count:

  • --ttl 3600: the keys stop working after an hour.
  • --max-tool-calls 20000: the whole fan-out stops after 20,000 tool calls. It can overshoot by a few.
  • --max-cost 50: a warning at $40 and a stop at $50, as Forkit estimates it. It can pass the budget by about 20 seconds of spending.

Your plan sets the size: 5 agents in one fan-out on Free, 50 on Pro and 1,000 on Team.

Each worker's sandbox runs forkit init --sandbox, which installs Claude Code's hooks without asking anything and makes an unanswered permission request a denial. The key arrives in FORKIT_API_KEY. A worker's session links to the planner's thread by itself, so its handoff goes to the planner.

Step 3: Each worker claims its package

The first thing a worker does is claim the paths it will edit:

await codemode.claim_paths({ patterns: ["packages/billing/**"], ttl_seconds: 1800 })

A file has one owner at a time. If a worker's change reaches into a shared helper another worker already holds, its claim on that path is refused and the refusal names the holder. The edit itself is refused too: the hook checks every path of an edit before it happens and denies one under another agent's claim. Claims expire, are renewed while the worker is active, and are released when its session ends, so a crashed worker does not hold a package forever.

This is where most migrations go wrong without coordination. In a 2026 study of parallel sub-agents in Codex, Claude Code and Kimi Code, the largest failure category was concurrent writes to the same or related files, 26.5% of failures (Li et al., arXiv 2610.10263, preprint). See why multi-agent coding fails.

Step 4: One question, answered once

Every worker will want to run the same install command within the same minute. Two hundred identical permission prompts would be unusable.

Forkit groups them. Pending requests with the same fan-out, tool, subject and repository are one question, and one person's answer settles all of them in one transaction. Better still, answer it before the run: an allow rule for pnpm install answers each request at once.

Some requests are never grouped and never answered by a rule: those that touch production, secrets or money. Each reaches a person and can only be allowed once. A migration that suddenly wants a production credential should stop and wait for someone.

Step 5: Handoffs, not chat

A worker reports with a handoff, a typed message that goes to its planner. The planner reads handoffs as they arrive and marks the package's task done, which releases the next wave in ready_tasks. Workers do not message each other. Server limits on messages (30 a minute per sending session, among others) keep a confused worker from flooding the planner.

Step 6: Stop the runaways

Some workers will not finish: a package with a circular import, a test suite that hangs, an agent that keeps retrying. The fan-out's limits stop them all together. A person can also stop the whole fan-out from the fan-outs page or the Mac app. After a stop, every request from the fan-out's keys is refused with the reason, the hook tells each agent not to continue, pending permission requests are denied and claims are released. See how to stop a runaway agent.

Step 7: Check the merge, then collect

Each worker's change is in its own fork. Before a worker finishes, Forkit's Stop hook compares its change with every peer's the way git's merge decides, waits for peers that have not checked in, and holds a worker whose change would conflict, naming the file, the lines and the peer. Then the planner collects:

forkit fanout collect <fanout-id> ./out --merge

Every pushed fork is fetched as agent/<name> and merged one by one into fanout/<name>. A worker whose work conflicts is left as a branch for a person, and the command exits with code 3. Then CI runs on the merged branch, which is where Linear's point applies: two hundred packages' tests at once is a load your CI has to carry.

What was measured

Forkit load-tested this scenario on its staging deployment. The test rig behaved like agents. It did not use real coding agents. Each simulated agent started, took a prompt, claimed its package, made 8 tool calls, asked for the same pnpm install, was refused when nobody answered, handed off and ended. Some never finished and were stopped. Agents arrived 40 a second. One run per case.

13 Nov 2026, 1,000 agents:

  • 1,000 of 1,000 starts, prompts and claims accepted.
  • 800 of 800 permission requests accepted, and 792 recorded as denied when nobody answered (8 lost their long-poll).
  • 800 of 800 handoffs read by the planner.
  • 200 of 200 runaways stopped within 4 seconds.
  • Medians: start 4 s, prompt 3 s, claim 2 s, permission request 6 s, tool call 0.3 s.
  • 69 of 10,717 tool calls were answered with a 503 while the database refused work for its ten-second limit.

14 Nov 2026, 1,000 agents, after further changes:

  • Every request answered, no job dropped, 800 of 800 unanswered requests denied.
  • Medians: start 0.36 s, prompt 0.31 s, claim 0.37 s, permission request 0.31 s, handoff 0.52 s, end 0.35 s, tool call 0.15 s.
  • 95th percentile under 0.75 s for every step.

14 Nov 2026, 3,000 agents in three fan-outs at once, 120 arriving a second: no job dropped and every handoff read. Medians: start 1.2 to 1.8 s, claim 1.5 to 6.7 s, tool call 0.37 s. About one start in ten and 3% of tool calls never reached Forkit, because the test machine's connections timed out. These figures cover the requests that connected.

The closest real run is smaller. On 17 Nov 2026, on staging, six real Claude Code agents each built one family of a units CLI in its own fork. All six asked to run node --test within 46 s, one "Allow once" answered all six, all pushed 65 s after starting, six branches merged with no conflict, and 28 of 28 tests passed. One run.

What was not measured

  • A real fleet of hooks at this size. The load tests used a rig.
  • A person answering a grouped question under load. In the load tests nobody answered.
  • More than one workspace under this load.
  • An actual monorepo migration of hundreds of packages with real agents.

A checklist before you start

  1. Migrate one package by hand with one agent. Turn what you learned into the prompt.
  2. Run five workers. Read their handoffs.
  3. Write the allow rule for the install and test commands.
  4. Set the key lifetime, the tool call budget and the dollar budget.
  5. Make claiming the package the worker's first step.
  6. Start the rest, in waves if packages depend on each other.

Related: agent fan-out explained, an agent swarm backend and planner and workers.

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. It gives a migration its keys, claims, grouped questions, handoffs, merge check and stop. Forkit never runs agents: you bring the planner, the sandboxes and the agents. It is free to try at forkit-mcp.com.

Sources