Vetted Talent Options

Dependency Management in Distributed Monorepo Workflows

Treat the dependency graph as a live artifact that decides what builds, tests, and ships.

· 9 min read
Cover illustration for “Dependency Management in Distributed Monorepo Workflows”
Distributed Team Engineering · November 14, 2026 · 9 min read · 2,040 words

Dependency management in distributed monorepo workflows is primarily a problem of change propagation. The dependency graph must act as a living operational artifact that determines what gets built, tested, cached, and deployed. That requires declarations that match the code, graph-aware execution, and clear ownership for every team that works in the workspace.

Why monorepos shift dependency management from version pinning to change propagation

A shared type update in a multi-repo system can require separate pull requests, separate CI runs, and days of back-and-forth before one logical change lands. Version drift creates the visible mismatch, but coordination creates the delay. Each repository must take in the update while its consumers wait or adapt on their own. The work is distributed across repository boundaries even when the change itself is indivisible.

A monorepo brings those packages and applications into one workspace, where the change and its downstream effects can travel together. Instead of asking whether a dependency changed, the team must establish which consumers the change affects and whether they have been built, tested, and deployed. Repository membership alone cannot answer that question.

The distinction becomes concrete when a shared UI package changes. Finding its changed files is easy, but every application that consumes it must be in the affected set even if none of its own files changed. Otherwise, the workflow has deferred a breakage. The dependency graph, rather than an individual package version or directory, becomes the unit through which the team manages the change.

What the dependency graph actually does at runtime — and why "affected" is the operative concept

Graph-aware build tools model the repository as interdependent targets. When they run tasks, they map changed files to the packages that own them and follow dependency relationships outward to find downstream targets. That traversal includes both direct dependents and transitive consumers. The resulting affected set determines which builds, tests, and deployments need to run, while cached results cover reusable work.

Path filters answer a narrower question about which files changed. They do not inherently establish which unchanged packages depend on those files. A consumer separated from a modified package by another shared library may still need rebuilding. The relevant boundary is the reach of the change.

Ignoring that distinction produces a predictable progression of failures. First, running every task on every commit makes pipeline time grow with repository size. Next, flaky tests outside the affected packages can block pull requests even when those packages would pass. Finally, indiscriminate deployment is an execution failure that couples services sharing a repository regardless of whether they share the change.

The graph therefore serves two complementary purposes. It includes consumers that file-based detection would miss, and it excludes unrelated targets that a full-repository run would execute unnecessarily. Precision requires both. A pipeline that achieves speed by missing downstream consumers is no more correct than one that treats every package as affected.

The phantom dependency problem and why strict dependency resolution is a prerequisite for graph integrity

That precision depends on the declarations feeding the graph. A phantom dependency appears when a package imports a module it never declared as a dependency. The import creates a relationship in the code without creating the corresponding declared edge. The build tool then operates on an incomplete model.

Hoisted node_modules arrangements, including npm and Yarn classic behavior, allow this mismatch to arise because a module installed for one package can be accessible to another. The undeclared import may work locally. It can then fail in production or in a published package where that incidental dependency is absent. Local success conceals the missing declaration rather than demonstrating that the package is self-contained.

For affected-only execution, the consequence extends beyond installation. If an undeclared dependency changes, the graph may not identify the package importing it as an affected consumer. A traversal can be internally consistent and still return the wrong result because its input omits a real relationship. Caching and orchestration cannot repair that omission.

Strict dependency resolution exposes the mismatch during development by limiting packages to dependencies they explicitly declare. Non-flat dependency structures make that boundary enforceable. The principle also applies beyond JavaScript, where classpath leakage or under-specified build rules can hide equivalent relationships. Strict resolution is therefore a correctness choice for graph-driven workflows.

How the current tool landscape maps onto graph-awareness and team scale

Tool selection follows from a question of responsibility. Which layer owns the graph, and how accurately does it model the codebase? Lightweight task runners add caching and graph-aware orchestration to the language toolchains already in use and suit repositories with fewer than a few hundred packages that use JavaScript or a typed variant of it. Polyglot build systems model dependencies more finely across languages and support hermetic, reproducible builds with remote execution. Their broader control comes with dedicated build infrastructure requirements.

pnpm workspaces provide the dependency foundation for JavaScript monorepos. Strict resolution keeps undeclared imports from becoming hidden edges, while content-addressable storage deduplicates packages across the workspace. The workspace protocol binds internal packages to their local versions during development and substitutes real versions when publishing. Its catalog feature centralizes shared external dependency versions. These mechanisms keep declarations and version policy coherent before a task runner computes affected work.

Nx 23.x, developed by Nrwl, owns explicit project and task graphs and computes affected sets through nx affected. Nx Core provides local caching and single-machine scheduling, while Nx Cloud adds remote caching and distributed task execution. Its language coverage extends beyond its Angular origins through official Java and.NET plugins and community plugins for Go, Rust, and Python. This makes the fidelity of its project model, rather than its original framework association, the relevant evaluation point.

Scale narrows the remaining choices. Turborepo works best with a small number of packages and no distributed execution, while uv workspaces are enough for most Python teams with fewer than a moderate number of engineers and packages. Bazel and Buck2 fit large polyglot organizations prepared to support dedicated build infrastructure, as does Pants in the broader polyglot category. At hundreds to thousands of engineers, the practical guidance shifts toward one monorepo per bounded domain and separate repositories across domains. A single organizational graph need not require a single repository.

Circular dependencies and versioning drift as failure modes of the graph, not the tools

Even when declarations match the code, dependencies can be poorly designed. A cycle appears when package A imports package B and package B imports package A. That relationship prevents a clean dependency order and undermines task caching and affected-set computation. Strict resolution can reveal every edge while the cycle stays in place.

The design remedy is to extract the shared concern into an independent package. If packages/ui and packages/utils both need formatDate, neither should import the other to obtain it. Instead, packages/dates becomes a dependency of both. The shared function then sits below the packages that use it in a directed acyclic graph. Relaxing graph rules would preserve the design defect.

Version drift is a different form of inconsistency. Packages can satisfy their own manifests while using different versions of the same external dependency, leaving behavior uneven and upgrades dependent on a manual sweep. A centralized catalog turns that shared version into one source of truth. Independently published packages also need coordinated version bumps when shared dependencies change, which a release-management tool addresses by tracking changes and propagating bumps transitively.

These mechanisms support package boundaries. Applications should not depend on other applications, and packages should not depend on applications. Shared utilities belong at the base, with application-level consumers above them. The graph remains usable only when its structure expresses those design decisions.

Affected-only CI/CD as the production expression of graph-driven thinking

A sound dependency structure becomes operational when CI uses it to select work. The pipeline detects changed files, maps them to owning packages, expands the affected set transitively, and runs the corresponding builds, tests, and deployments. That selection must follow the same dependency relationships used during development.

For teams building toward this model, path filters provide an initial level of control. GitHub Actions path triggers and tools such as dorny/paths-filter can gate jobs by project in small repositories with shallow sharing. They are useful within that boundary. As shared dependencies become nested, though, those filters become a copy of the graph that someone must update by hand whenever relationships change.

The next level transfers that responsibility to the build tool. Nx affected execution, Turborepo pipelines, and Bazel targets let the tool compute affected work rather than treating path rules as the source of truth. Remote caching then extends reuse across engineers and CI. When another execution has the same hashed inputs, the previous result can be returned without rebuilding or retesting. Cache hit rate becomes the main way to measure how well this model performs.

Main-branch protection completes the pipeline design. Required status checks scoped to affected projects, together with a merge queue, keep the affected slice accountable without making unrelated packages the default unit of validation. Evaluate the pipeline by its graph ownership and reusable results. A longer feature list does not establish that the pipeline selects the right work.

How AI agents interact with the dependency graph — and what that changes for distributed teams

Once CI uses the graph to make execution decisions, agents can use the same structure to investigate failures and coordinate fixes. The common objection that monorepos contain too much context overlooks the graph’s role in organizing that context. Project relationships and module boundaries give an agent a way to query architecture. The graph becomes an interface for automated reasoning about change.

Nx’s Self-Healing CI demonstrates this operational pattern. Its agent examines failures using project graph context, analyzes the cause, proposes a fix, and validates it by rerunning failed tasks. Nx reports that 60% of its fix suggestions are accepted. The Nx MCP server also connects local agents to CI so they can detect and address failures across the graph. Acceptance remains distinct from generation, even when diagnosis and validation are automated.

Elastic’s engineering team has demonstrated self-correcting pull requests that address dependency issues in large monorepos. Agents look at dependency relationships, find breaking changes, and create fix commits. The dependency model supplies the scope of the repair.

Nx’s Polygraph extends that coordination across repositories without moving code, while preserving session history for work across machines. The Nx roadmap also introduces Synthetic Monorepos as an alternative to migration through cross-repository visibility and intelligence. For distributed and staff-augmented teams, these capabilities can shorten feedback cycles that would otherwise wait for synchronous overlap. A failure can be diagnosed and patched before the next shared working window, making graph tooling part of coordination as well as execution.

Organizational governance of the graph in distributed and augmented teams

Automated coordination does not remove the need for explicit ownership. In a polyrepo, repository boundaries provide a natural unit for permissions. A monorepo needs controls on its directories when contributors should have different levels of access to its packages. CODEOWNERS assignments set out who must review changes, but keeping sensitive code out of view also requires access restrictions that can be enforced. Ownership and access must not be treated as interchangeable.

That distinction becomes harder to maintain as teams, contractors, and engagement types change. A bounded assignment still needs a clear relationship to the packages it can affect. Documentation must therefore explain which packages own which concerns, what their API contracts are, and which can be modified independently. The reader cannot be assumed to be in the room. Undocumented structure becomes a coordination bottleneck when engineers cannot rely on immediate conversation.

Weak ownership therefore puts the structure at greater risk than where people work. Unclear assignments, poor onboarding to graph conventions, and treating remote engineers as task workers leave design intent outside the operational model. The graph can enforce dependency rules. It cannot decide who should own an architectural change or explain why a boundary exists.

Those governance requirements also define when a monorepo is the wrong choice. Language ecosystems with no shared dependencies gain little from consolidation that adds build-system overhead, while strict visibility requirements may be simpler to satisfy through repository isolation. Beyond roughly 10 GB of files, Git operations can themselves become a bottleneck, making partial clones or domain-level splits the structural response.

More in Distributed Team Engineering