The Deska blog
Monorepo vs Polyrepo When AI Agents Join the Team
Explore the monorepo vs polyrepo debate through the lens of AI agents and learn how workspace tools like Deska optimize large scale development workflows.
· 12 min read
The debate surrounding monorepo vs polyrepo architecture has historically focused on human constraints like build times, ownership, and dependency management. However, the rise of autonomous AI coding agents shifts the landscape significantly. When a large language model is responsible for refactoring code across multiple services, the physical structure of the repository determines the agent's context window efficiency and its ability to maintain systemic integrity. Choosing between a single unified repository and multiple isolated ones is no longer just a DevOps decision, it is an AI orchestration strategy.
Understanding the Core Architectures
A monorepo stores all code for a project, or even an entire company, within a single version control repository. This approach encourages transparency and simplifies cross project refactoring. Major technology firms have famously utilized this model to manage millions of lines of code while ensuring that all components share the same dependencies.
Conversely, a polyrepo strategy breaks the system into multiple repositories, typically one per service or library. This provides strict isolation, allowing teams to move at different speeds. It limits the impact of a single breaking change and keeps the history of each project clean and focused. While it offers autonomy, it introduces challenges when a feature requires simultaneous changes across five different microservices.
How AI Agents Interact with Repository Structures
AI agents like Claude Code or OpenCode operate by indexing files and building a mental map of the codebase. The repository structure dictates how these agents "see" the world.
In a monorepo, an agent has immediate access to all interface definitions and shared libraries. If you ask an agent to update an API signature, it can instantly identify and fix every call site across the entire organization. The challenge here is noise. An agent might get lost in thousands of unrelated files if the workspace management is not handled correctly.
In a polyrepo setup, agents face a discovery problem. An agent restricted to service-a might be unaware that its changes will break service-b located in a different repository. To solve this, developers often have to manually feed multiple repository paths to the agent, which increases the cognitive load on the human operator.
The Challenge of Context and Tooling
Regardless of the repository choice, the real bottleneck is the developer's ability to oversee what the agent is doing. Standard terminal interfaces become cluttered when agents start running background tasks, linting code, and checking test results across various directories.
Tools like Deska address this by providing an infinite canvas. Instead of switching tabs, you can place a terminal for your monorepo build on one side and an AI agent panel on the other. This visual arrangement allows you to monitor how an agent navigates a complex directory tree in real time. For those using coding agents, seeing the file tree alongside the agent output is essential for verifying that the AI is not hallucinating file paths.
Impact on Continuous Integration and AI Reliability
Modern CI/CD pipelines must adapt to agentic workflows. In a monorepo, agents can run comprehensive integration tests easily because all code is present. However, the sheer volume of tests can slow down the feedback loop.
Polyrepos allow for faster, isolated CI runs. When an agent submits a pull request for a specific library, the test suite is small and predictable. The downside is that global consistency is harder to verify. An agent might pass all tests in the current repo but still cause a failure downstream.
Successful teams often use a middle ground by employing powerful terminals that can orchestrate multiple repository environments simultaneously. By running specific sessions side by side, a developer can ensure that an agent's work in a polyrepo doesn't negatively impact external dependencies.
Why Local-First AI Matters for Repository Scale
Security and privacy are paramount when giving agents access to an entire monorepo. Many developers are hesitant to upload massive proprietary codebases to cloud based AI services due to data residency concerns.
A local-first approach ensures that your code, files, and AI sessions stay on your machine. When you use tools that run agents locally, such as Codex CLI, the agent indexes your local files without them ever leaving your hardware. This is particularly beneficial for monorepos, where the volume of data would be expensive and slow to transfer to a cloud provider.
Building an Optimized AI Workspace
To successfully integrate AI agents into your architecture, your workspace needs to be more flexible than a traditional IDE. A canvas based workspace allows for a unique way of organizing repo exploration:
- Place different microservices in separate panels to simulate a monorepo feel within a polyrepo setup.
- Use notes to track the agent's progress across different architectural boundaries.
- Run a dedicated panel for Ask Deska to control the workspace using voice, allowing you to open new repo directories or run build commands without taking your hands off the keyboard.
- Monitor long running agent tasks from a mobile device via a secure relay if you need to step away from your desk.
FAQ
Which repository structure is better for Claude Code?
A monorepo is generally easier for Claude Code because it allows the agent to search across the entire project scope without needing to switch contexts or repositories manually. However, if the monorepo is exceptionally large, you must use precise file filtering to keep the agent within its token limits.
How to manage multiple repositories with AI agents?
The most effective way is to use a workspace that supports multiple terminal and editor panels side by side. This allows you to run one agent instance per repository while maintaining a global view of the project, ensuring that interactions between services are visible on a single screen.
Do AI coding agents work better with local or cloud files?
Local files are preferred for both speed and privacy. Since agents often need to read and write hundreds of files during a refactor, the latency of a cloud file system can significantly degrade performance. Keeping files on your machine ensures the agent responds faster and your IP remains secure.
Start Building with AI Agents
Choosing between monorepo and polyrepo depends on your team's size and deployment needs, but your choice of tools can bridge the gap between these two worlds. By utilizing an infinite canvas and local-first AI, you can maintain the visibility of a monorepo even in a polyrepo environment.
If you want to experience a workspace designed for the era of AI agents, you can download the app for free on Mac, Windows, or Linux. Set up your workspace, place your panels, and let your agents work with the full context they deserve.