« All posts

Solving the Polyrepo Problem for AI Coding Agents

How git worktrees and task-scoped workspaces fix the single-repo limitation of AI coding agents working across polyrepo codebases, via the Orbit prototype.

Shipping a feature across three repos — backend, contract, frontend — exposes a hard limit in today's coding agents: they default to one repo, one session. Merging repos under a shared root just shifts the pain, forcing the agent to crawl dozens of unrelated directories and locking each repo's single working copy to one task at a time, so a second request means manual git stash juggling. Wiring repos together with flags like --add-dir keeps them at scattered absolute paths, which breaks compilers, bundlers, and language servers that expect real relative paths — turning a one-line fix into a full publish-pull-rebuild cycle.

The fix that actually works is unglamorous: lay repos out as git worktrees inside one real directory tree, with isolated per-task workspaces pulling from a shared pool of git objects. Because worktrees share underlying objects, spinning up a new task workspace is near-instant and cheap to discard. The payoff is fourfold — consistent cross-repo context in a single session, on-demand repo loading instead of upfront crawling, zero toolchain adaptation since build tools see ordinary relative paths, and clean task isolation with no branch or context bleed.

This pattern is implemented in Orbit, a minimal bash-and-git prototype with no server or runtime dependency. Open issues remain — stale per-repo notes and skepticism about bash-based reliability — but the underlying concept, treating multi-repo context as real, editable, history-bearing source rather than a flat file dump, stands independent of any single tool.