The benefits of a monorepo

Greg Foster
Greg Foster
Graphite software engineer
Try Graphite

Table of contents

A monorepo (short for “mono‑repository”) is a version control strategy where multiple projects—services, libraries, applications—live in a single repository rather than in separate ones.

Important clarifications:

  • A monorepo is not the same as a monolithic architecture. You can still have modular, independent services in a monorepo.
  • Companies like Google, Meta, and Twitter manage massive monorepos with specialized tools.

With all projects in one repo, shared libraries are easier to reuse. There's no need to publish and version them independently. You can make atomic changes that span multiple packages, avoiding broken dependencies.

All teams have access to the entire codebase. This promotes transparency, encourages reuse, and lowers the barrier to contributing across components.

You can change an API and update every consumer in the same commit. This avoids synchronization issues between repositories or packages.

Monorepos support standardized builds and testing, with all components tested in a single CI pipeline. This ensures compatibility and avoids environment mismatches.

New developers or internal transfers can get started quickly without needing to hunt down multiple repositories or setup scripts.

  • Nx: A monorepo framework for TypeScript and JavaScript. It supports project graph analysis, task orchestration, and dependency-aware builds.
  • Google’s Piper: Google’s internal monorepo system scales to billions of lines of code and thousands of engineers.
ChallengeMitigation strategy
Build slownessUse graph-aware build systems like Bazel, Buck, or Pants.
Merge conflictsImplement merge queues and stacked diffs.
Access controlUse code ownership rules (e.g., CODEOWNERS) and fine-grained permissions.
Tooling complexityInvest in CI, caching, linters, and developer tooling tailored for monorepos.
  • Build systems: Tools like Bazel, Buck, and Pants build only the parts of the codebase that change, reducing CI time.
  • Merge automation: Merge queues help prevent broken main branches by testing and merging PRs one at a time.
  • Stacked pull requests: Tools like Graphite support breaking large changes into smaller, dependent PRs.
  • Ownership enforcement: GitHub’s CODEOWNERS and similar tools restrict and streamline review responsibilities.

Graphite is a devtool specifically designed to improve code review in monorepos. It introduces several important workflows:

  • Stacked diffs: Developers can break large changes into a sequence of smaller, logical commits, improving review speed and clarity.
  • Merge queue: Graphite provides an automated merge pipeline that runs CI tests, handles rebases, and queues approved pull requests.
  • Custom merge rules: Teams can configure Graphite to apply branch protections, required reviews, or test passes depending on path ownership.
  • Review analytics: Graphite tracks review speed, feedback loops, and throughput, helping engineering leaders optimize team performance.

These features address key pain points in monorepos, where changes often span multiple packages or services and require many reviewers.

Choose a monorepo if:

  • You have many shared libraries or services that need to evolve together.
  • Your engineering organization is large and needs better coordination.
  • You can invest in good infrastructure (CI, caching, build tools).

Avoid a monorepo if:

  • You require strict isolation or regulatory separation.
  • Your team lacks the capacity to maintain custom tooling or process.

Monorepos provide compelling benefits: atomic commits across projects, easier sharing, simplified refactors, and more consistent development workflows. But they require tooling investments and process discipline to avoid slow builds, merge conflicts, and complexity.

Tools like Graphite help make monorepos more scalable by introducing workflows like stacked pull requests, merge queues, and rule-based automation. Combined with modern build systems, a well-managed monorepo can increase engineering velocity and cross-team collaboration.

Built for the world's fastest engineering teams, now available for everyone