Skip to content
Back to skills

Monorepo Navigator

ASecurity

Inspect a monorepo's workspace: dependency graph with cycle detection, version drift between packages, and which packages a set of changed files affects. Also covers Turborepo, Nx, pnpm workspaces and Changesets setup. Use when a change in a shared package needs an affected-package test list, when asked for a package dependency diagram, when checking a workspace for drift or cycles, or when configuring remote caching or coordinated publishing.

  • 1,271 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 27, 2026
developmentpythongobashgitapici/cdperformancedocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add borghei/Claude-Skills --skill monorepo-navigator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Monorepo Navigator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Monorepo Navigator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/borghei-monorepo-navigator/badge)](https://www.skillsdirectory.com/skills/borghei-monorepo-navigator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: monorepo-navigator
description: >
  Inspect a monorepo's workspace: dependency graph with cycle detection, version drift between
  packages, and which packages a set of changed files affects. Also covers Turborepo, Nx, pnpm
  workspaces and Changesets setup. Use when a change in a shared package needs an affected-package
  test list, when asked for a package dependency diagram, when checking a workspace for drift or
  cycles, or when configuring remote caching or coordinated publishing.
license: MIT + Commons Clause
metadata:
  version: 1.2.0
  author: borghei
  category: engineering
  domain: monorepo-architecture
  tier: POWERFUL
  updated: 2026-11-08
  frameworks: turborepo, nx, pnpm-workspaces, changesets
  tags:
    - monorepo
    - turborepo
    - nx
    - pnpm
    - changesets
---
# Monorepo Navigator

Navigate, manage, and optimize monorepos at any scale. Covers Turborepo, Nx, pnpm workspaces, and Lerna/Changesets for cross-package impact analysis, selective builds on affected packages only, dependency graph visualization, remote caching configuration, migration from multi-repo to monorepo with preserved git history, and coordinated package publishing with automated changelogs.

**Keywords:** monorepo, Turborepo, Nx, pnpm workspaces, Changesets, dependency graph, remote cache, affected packages, selective builds, cross-package impact, npm publishing, workspace protocol

## Core Capabilities

- **Impact analysis** — determine which apps break when a shared package changes, trace dependency chains, visualize Mermaid graphs; list the packages to re-test.
- **Selective execution** — run tests/builds only for affected packages, filter by changed files since a git ref, and skip unchanged packages in CI.
- **Build optimization** — remote caching (Turborepo/Vercel, Nx Cloud), incremental builds with input/output config, dependency-aware parallel scheduling, and artifact sharing.
- **Publishing** — Changesets for coordinated versioning, automated per-package changelogs, pre-release channels, and `workspace:*` replacement during publish.

## When to Use

- Multiple packages/apps share code (UI components, utils, types, API clients)
- Build times are slow because everything rebuilds on every change
- Migrating from multiple repos to a single monorepo
- Publishing npm packages with coordinated versioning
- Teams work across packages and need unified tooling

## Clarify First

Before analyzing or configuring, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.

- **Tooling:** Turborepo, Nx, pnpm workspaces, or Changesets (drives the config and commands generated).
- **Task:** impact/dependency analysis, build optimization, or publishing setup (selects `dependency_graph.py`, `impact_detector.py` or `package_analyzer.py`).
- **Repo root & git ref:** the monorepo path and the baseline ref for "affected" detection (sets `--ref` and what counts as changed).

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.

## Tools Overview

| Tool | Purpose | Command |
|------|---------|---------|
| `dependency_graph.py` | Mermaid graph of internal packages, cycle detection, optional focus on one package | `python3 scripts/dependency_graph.py <root> --focus @acme/utils --direction dependents` |
| `impact_detector.py` | Packages affected (directly and transitively) by changed files, plus a paste-ready test command | `python3 scripts/impact_detector.py <root> --ref origin/main` |
| `package_analyzer.py` | Package inventory, internal dependencies, external version drift, cycles, orphans | `python3 scripts/package_analyzer.py <root>` |

`scripts/workspace.py` is a shared helper, not a command. All three tools accept `--format text|json` (`--json` is an alias). Workspace detection order: `pnpm-workspace.yaml`, then the root `package.json` `workspaces` field (npm, Yarn), then `lerna.json`. There is no default folder list: a directory without a workspace config is rejected, not guessed at.

`impact_detector.py` takes its changed files from `--files a b c`, from `--ref <git ref>` (diff against the merge-base with HEAD, paths relative to the monorepo root), or from stdin, one path per line.

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Clean. `package_analyzer`: no version drift, cycles or unreadable package.json. `dependency_graph`: acyclic. `impact_detector`: the change stays inside the packages that own the edited files (or `--ref` found no changes). |
| 1 | Findings. Drift, a dependency cycle, an unreadable package.json, or fan-out (other packages depend on a changed one, or a root config file such as `turbo.json` or a lockfile changed). Every finding quotes the input and gives a fix. |
| 2 | Unusable input: not a directory, no workspace config, unparsable root `package.json`, no packages matched, `--focus` package not found, no changed files given, bad git ref. One `BLOCKED: <reason>` line on stderr, no traceback. |

The root-config file list in `impact_detector.py` and the "one specifier per dependency" drift rule are internal heuristics, not published standards.

## Quick Start

```bash
# from engineering/monorepo-navigator/ (assets/sample_monorepo is a four-package pnpm workspace)
python3 scripts/package_analyzer.py assets/sample_monorepo
python3 scripts/impact_detector.py assets/sample_monorepo --files packages/utils/src/index.ts
python3 scripts/dependency_graph.py assets/sample_monorepo --focus @acme/utils --direction dependents --mermaid-only
```

Real output of the first command (excerpt, exit code 1):

```
FIX 1 issue
Read: 4 packages via pnpm (apps/*, packages/*); 3 internal dependencies; 0 unreadable package.json

FINDINGS
1. [version-drift] date-fns: @acme/docs "^2.30.0" (dependencies); @acme/utils "^3.0.0" (dependencies)
   rule: one specifier per external dependency across the workspace (internal heuristic)
   fix: set "date-fns": "^3.0.0" in apps/docs/package.json (dependencies). Highest specifier chosen; confirm the newer major is acceptable first.
```

A change in `packages/utils` is reported as fan-out to `@acme/ui` and `@acme/web`, with `@acme/docs` unaffected, and the run ends with a command to paste: `pnpm --filter @acme/ui --filter @acme/utils --filter @acme/web run test`.

Other samples in `assets/`: `sound_monorepo` (all three tools exit 0 for a contained change), `flawed_monorepo` (dependency cycle, version drift) and `malformed_monorepo` (invalid root package.json, exit 2). `assets/contract.json` lists every run.

## Reference Documentation

Load the reference that matches the task — keep this file lean and pull detail on demand:

- **[references/tooling-and-configuration.md](references/tooling-and-configuration.md)** — tool selection decision matrix, recommended repo structure, full turbo.json and pnpm-workspace config, key Turborepo/pnpm commands, impact-analysis commands, remote-caching setup, affected-only CI workflow, Changesets publishing, and multi-repo→monorepo migration steps. Read when configuring or operating a monorepo.
- **[references/operations-and-best-practices.md](references/operations-and-best-practices.md)** — common pitfalls, best practices, troubleshooting table, and success criteria. Read when something misbehaves or when validating a setup.

## Anti-Patterns

**Mistake:** Running every test and build on every change.
**Why it matters:** CI time grows with the repo, not with the change, and teams start skipping checks.
**Instead:** Use the affected set from `impact_detector.py` (or the build tool's filter) and run the full suite on a schedule.

**Mistake:** Letting shared dependencies drift between packages.
**Why it matters:** Two versions of the same library ship twice, and bugs reproduce in one app but not another.
**Instead:** Check `package_analyzer.py --only-shared` and pin shared versions in one place (catalog or root constraints).

**Mistake:** Deep imports across package boundaries (`../../packages/ui/src/...`).
**Why it matters:** The dependency never appears in `package.json`, so impact analysis and the build cache miss it.
**Instead:** Import through the package name and declare it with `workspace:*`.

## Files

| File | Purpose |
|------|---------|
| `scripts/package_analyzer.py`, `scripts/impact_detector.py`, `scripts/dependency_graph.py` | Stdlib CLIs |
| `scripts/workspace.py` | Shared workspace loader (helper, not a command) |
| `assets/sample_monorepo/` | pnpm workspace with date-fns drift: `apps/web`, `apps/docs`, `packages/ui`, `packages/utils` |
| `assets/sound_monorepo/`, `flawed_monorepo/`, `malformed_monorepo/` | Exit 0 / 1 / 2 samples; `assets/contract.json` lists the runs |

## Scope & Limitations

**This skill covers:**
- Turborepo, Nx, and pnpm workspace configuration and optimization
- Cross-package dependency analysis and impact visualization
- Remote caching setup (Vercel, Nx Cloud, self-hosted)
- Changesets-based coordinated versioning and npm publishing

**This skill does NOT cover:**
- Application-level build configuration (webpack, Vite, esbuild internals) — see `performance-profiler`
- CI/CD pipeline design beyond monorepo-specific filters — see `ci-cd-pipeline-builder`
- Git branching strategies and release flow — see `release-manager`
- Dependency vulnerability scanning and license auditing — see `dependency-auditor`

Files in this skill

  • SKILL.md16.6 KB
  • scripts/dependency_graph.py16.5 KB
  • scripts/impact_detector.py14.5 KB
  • scripts/package_analyzer.py15 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.