monorepo-navigator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Monorepo Navigator

Monorepo导航器

Tier: POWERFUL Category: Engineering / Build Systems Maintainer: Claude Skills Team
等级:高级 分类:工程/构建系统 维护者:Claude技能团队

Overview

概述

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.
可浏览、管理并优化任意规模的monorepo。覆盖Turborepo、Nx、pnpm workspaces、Lerna/Changesets相关能力,支持跨包影响分析、仅针对受影响包的选择性构建、依赖图可视化、远程缓存配置、保留Git历史的多仓转单仓迁移,以及带自动更新日志的包协同发布。

Keywords

关键词

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

Core Capabilities

核心能力

1. Impact Analysis

1. 影响分析

  • Determine which apps break when a shared package changes
  • Trace dependency chains from leaf packages to root apps
  • Visualize impact as Mermaid dependency graphs
  • Calculate blast radius for any file change
  • 判定共享包变更时哪些应用会受影响崩溃
  • 追踪从叶子包到根应用的依赖链
  • 以Mermaid依赖图形式可视化影响范围
  • 计算任意文件变更的影响半径

2. Selective Execution

2. 选择性执行

  • Run tests/builds only for affected packages (not everything)
  • Filter by changed files since a git ref
  • Scope commands to specific packages and their dependents
  • Skip unchanged packages in CI for faster feedback
  • 仅对受影响的包运行测试/构建(而非全量执行)
  • 按某个Git引用之后的变更文件过滤
  • 将命令作用范围限定为特定包及其依赖项
  • 在CI中跳过未变更的包,加快反馈速度

3. Build Optimization

3. 构建优化

  • Remote caching with Turborepo (Vercel) or Nx Cloud
  • Incremental builds with proper input/output configuration
  • Parallel execution with dependency-aware scheduling
  • Artifact sharing between CI jobs
  • 基于Turborepo(Vercel)或Nx Cloud的远程缓存
  • 搭配合理的输入/输出配置实现增量构建
  • 基于依赖感知调度的并行执行
  • CI任务间的构建产物共享

4. Publishing

4. 发布能力

  • Changesets for coordinated versioning across packages
  • Automated changelog generation per package
  • Pre-release channels (alpha, beta, rc)
  • workspace:*
    protocol replacement during publish
  • 基于Changesets实现跨包协同版本管理
  • 自动生成每个包的更新日志
  • 支持预发布通道(alpha、beta、rc)
  • 发布时自动替换
    workspace:*
    协议

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
  • 多个包/应用存在共享代码(UI组件、工具函数、类型定义、API客户端)
  • 每次变更都会触发全量重建,导致构建速度缓慢
  • 正在从多仓库架构迁移到单monorepo架构
  • 需要协同管理版本的npm包发布场景
  • 团队需要跨包协作,期望使用统一的工具链

Tool Selection Decision Matrix

工具选择决策矩阵

RequirementTurborepoNxpnpm WorkspacesChangesets
Simple task runnerBestGoodN/AN/A
Remote cachingBuilt-inNx CloudN/AN/A
Code generationNoBestN/AN/A
Dependency managementN/AN/ABestN/A
Package publishingN/AN/AN/ABest
Plugin ecosystemLimitedExtensiveN/AN/A
Config complexityMinimalModerateMinimalMinimal
Recommended modern stack: pnpm workspaces + Turborepo + Changesets
需求TurborepoNxpnpm WorkspacesChangesets
简单任务运行器最佳良好不适用不适用
远程缓存内置Nx Cloud不适用不适用
代码生成不支持最佳不适用不适用
依赖管理不适用不适用最佳不适用
包发布不适用不适用不适用最佳
插件生态有限丰富不适用不适用
配置复杂度极低中等极低极低
推荐现代技术栈: pnpm workspaces + Turborepo + Changesets

Monorepo Structure

Monorepo结构

my-monorepo/
├── apps/
│   ├── web/                    # Next.js frontend
│   │   ├── package.json        # depends on @repo/ui, @repo/utils
│   │   └── ...
│   ├── api/                    # Express/Fastify backend
│   │   ├── package.json        # depends on @repo/db, @repo/utils
│   │   └── ...
│   └── mobile/                 # React Native app
│       ├── package.json
│       └── ...
├── packages/
│   ├── ui/                     # Shared React components
│   │   ├── package.json        # @repo/ui
│   │   └── ...
│   ├── utils/                  # Shared utilities
│   │   ├── package.json        # @repo/utils
│   │   └── ...
│   ├── db/                     # Database client + schema
│   │   ├── package.json        # @repo/db
│   │   └── ...
│   ├── types/                  # Shared TypeScript types
│   │   ├── package.json        # @repo/types (no runtime deps)
│   │   └── ...
│   └── config/                 # Shared configs (tsconfig, eslint)
│       ├── tsconfig.base.json
│       └── eslint.base.js
├── turbo.json                  # Turborepo pipeline config
├── pnpm-workspace.yaml         # Workspace package locations
├── package.json                # Root scripts, devDependencies
└── .changeset/                 # Changeset config
    └── config.json
my-monorepo/
├── apps/
│   ├── web/                    # Next.js frontend
│   │   ├── package.json        # depends on @repo/ui, @repo/utils
│   │   └── ...
│   ├── api/                    # Express/Fastify backend
│   │   ├── package.json        # depends on @repo/db, @repo/utils
│   │   └── ...
│   └── mobile/                 # React Native app
│       ├── package.json
│       └── ...
├── packages/
│   ├── ui/                     # Shared React components
│   │   ├── package.json        # @repo/ui
│   │   └── ...
│   ├── utils/                  # Shared utilities
│   │   ├── package.json        # @repo/utils
│   │   └── ...
│   ├── db/                     # Database client + schema
│   │   ├── package.json        # @repo/db
│   │   └── ...
│   ├── types/                  # Shared TypeScript types
│   │   ├── package.json        # @repo/types (no runtime deps)
│   │   └── ...
│   └── config/                 # Shared configs (tsconfig, eslint)
│       ├── tsconfig.base.json
│       └── eslint.base.js
├── turbo.json                  # Turborepo pipeline config
├── pnpm-workspace.yaml         # Workspace package locations
├── package.json                # Root scripts, devDependencies
└── .changeset/                 # Changeset config
    └── config.json

Turborepo Configuration

Turborepo配置

turbo.json

turbo.json

json
{
  "$schema": "https://turbo.build/schema.json",
  "globalDependencies": ["**/.env.*local"],
  "globalEnv": ["NODE_ENV", "CI"],
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", "tsconfig.json", "package.json"],
      "outputs": ["dist/**", ".next/**", "!.next/cache/**"],
      "env": ["NEXT_PUBLIC_*"]
    },
    "test": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", "tests/**", "vitest.config.*"],
      "outputs": ["coverage/**"]
    },
    "lint": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", ".eslintrc.*", "tsconfig.json"]
    },
    "typecheck": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", "tsconfig.json"]
    },
    "dev": {
      "cache": false,
      "persistent": true
    }
  }
}
json
{
  "$schema": "https://turbo.build/schema.json",
  "globalDependencies": ["**/.env.*local"],
  "globalEnv": ["NODE_ENV", "CI"],
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", "tsconfig.json", "package.json"],
      "outputs": ["dist/**", ".next/**", "!.next/cache/**"],
      "env": ["NEXT_PUBLIC_*"]
    },
    "test": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", "tests/**", "vitest.config.*"],
      "outputs": ["coverage/**"]
    },
    "lint": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", ".eslintrc.*", "tsconfig.json"]
    },
    "typecheck": {
      "dependsOn": ["^build"],
      "inputs": ["src/**", "tsconfig.json"]
    },
    "dev": {
      "cache": false,
      "persistent": true
    }
  }
}

Key Turborepo Commands

常用Turborepo命令

bash
undefined
bash
undefined

Run all tasks

Run all tasks

turbo run build
turbo run build

Run only affected packages (compared to main)

Run only affected packages (compared to main)

turbo run build test --filter='...[origin/main]'
turbo run build test --filter='...[origin/main]'

Run for a specific package and its dependencies

Run for a specific package and its dependencies

turbo run build --filter=@repo/web...
turbo run build --filter=@repo/web...

Run for a specific package only (no deps)

Run for a specific package only (no deps)

turbo run test --filter=@repo/ui
turbo run test --filter=@repo/ui

Dry run to see what would execute

Dry run to see what would execute

turbo run build --dry=json
turbo run build --dry=json

View dependency graph

View dependency graph

turbo run build --graph=graph.html
turbo run build --graph=graph.html

Summarize cache usage

Summarize cache usage

turbo run build --summarize
undefined
turbo run build --summarize
undefined

pnpm Workspace Configuration

pnpm工作区配置

pnpm-workspace.yaml

pnpm-workspace.yaml

yaml
packages:
  - 'apps/*'
  - 'packages/*'
yaml
packages:
  - 'apps/*'
  - 'packages/*'

Cross-Package References

跨包引用

json
// packages/ui/package.json
{
  "name": "@repo/ui",
  "version": "0.0.0",
  "main": "./src/index.ts",
  "types": "./src/index.ts",
  "dependencies": {
    "@repo/types": "workspace:*"
  }
}

// apps/web/package.json
{
  "name": "@repo/web",
  "dependencies": {
    "@repo/ui": "workspace:*",
    "@repo/utils": "workspace:*"
  }
}
json
// packages/ui/package.json
{
  "name": "@repo/ui",
  "version": "0.0.0",
  "main": "./src/index.ts",
  "types": "./src/index.ts",
  "dependencies": {
    "@repo/types": "workspace:*"
  }
}

// apps/web/package.json
{
  "name": "@repo/web",
  "dependencies": {
    "@repo/ui": "workspace:*",
    "@repo/utils": "workspace:*"
  }
}

Workspace Commands

工作区命令

bash
undefined
bash
undefined

Install all workspace dependencies

Install all workspace dependencies

pnpm install
pnpm install

Add a dependency to a specific package

Add a dependency to a specific package

pnpm add zod --filter @repo/api
pnpm add zod --filter @repo/api

Add a workspace package as dependency

Add a workspace package as dependency

pnpm add @repo/utils --filter @repo/web --workspace
pnpm add @repo/utils --filter @repo/web --workspace

Run a script in a specific package

Run a script in a specific package

pnpm --filter @repo/web dev
pnpm --filter @repo/web dev

Run a script in all packages that have it

Run a script in all packages that have it

pnpm -r run build
pnpm -r run build

List all packages

List all packages

pnpm -r ls --depth -1
undefined
pnpm -r ls --depth -1
undefined

Impact Analysis

影响分析

Find All Dependents of a Changed Package

查找变更包的所有依赖项

bash
undefined
bash
undefined

Using turbo to see what depends on @repo/ui

Using turbo to see what depends on @repo/ui

turbo run build --filter='...@repo/ui' --dry=json |
jq '.tasks[].package' -r | sort -u
turbo run build --filter='...@repo/ui' --dry=json |
jq '.tasks[].package' -r | sort -u

Manual: search for imports of a package

Manual: search for imports of a package

grep -r "from '@repo/ui'" apps/ packages/ --include=".ts" --include=".tsx" -l
undefined
grep -r "from '@repo/ui'" apps/ packages/ --include=".ts" --include=".tsx" -l
undefined

Dependency Graph Visualization

依赖图可视化

bash
undefined
bash
undefined

Generate HTML visualization

Generate HTML visualization

turbo run build --graph=dependency-graph.html
turbo run build --graph=dependency-graph.html

Generate DOT format for custom rendering

Generate DOT format for custom rendering

turbo run build --graph=deps.dot
turbo run build --graph=deps.dot

Quick Mermaid diagram from package.json files

Quick Mermaid diagram from package.json files

echo "graph TD" for pkg in packages//package.json apps//package.json; do name=$(jq -r '.name' "$pkg") jq -r '.dependencies // {} | keys[] | select(startswith("@repo/"))' "$pkg" | while read dep; do echo " $name --> $dep" done done
undefined
echo "graph TD" for pkg in packages//package.json apps//package.json; do name=$(jq -r '.name' "$pkg") jq -r '.dependencies // {} | keys[] | select(startswith("@repo/"))' "$pkg" | while read dep; do echo " $name --> $dep" done done
undefined

Remote Caching

远程缓存

Turborepo Remote Cache (Vercel)

Turborepo远程缓存(Vercel版)

bash
undefined
bash
undefined

Login to Vercel (one-time)

Login to Vercel (one-time)

turbo login
turbo login

Link repo to Vercel team

Link repo to Vercel team

turbo link
turbo link

CI: set environment variables

CI: set environment variables

TURBO_TOKEN=<vercel-token>

TURBO_TOKEN=<vercel-token>

TURBO_TEAM=<team-slug>

TURBO_TEAM=<team-slug>

Verify remote cache works

Verify remote cache works

turbo run build --summarize
turbo run build --summarize

Look for "Remote cache: hit" entries

Look for "Remote cache: hit" entries

undefined
undefined

Self-Hosted Remote Cache

自托管远程缓存

bash
undefined
bash
undefined

Using ducktape/turborepo-remote-cache

Using ducktape/turborepo-remote-cache

docker run -p 3000:3000
-e STORAGE_PROVIDER=local
-e STORAGE_PATH=/cache
ducktape/turborepo-remote-cache
docker run -p 3000:3000
-e STORAGE_PROVIDER=local
-e STORAGE_PATH=/cache
ducktape/turborepo-remote-cache

Configure turbo to use it

Configure turbo to use it

turbo.json:

turbo.json:

{ "remoteCache": { "apiUrl": "http://cache-server:3000" } }

{ "remoteCache": { "apiUrl": "http://cache-server:3000" } }

undefined
undefined

CI/CD with Affected Packages Only

仅针对受影响包的CI/CD

yaml
undefined
yaml
undefined

.github/workflows/ci.yml

.github/workflows/ci.yml

name: CI on: pull_request:
jobs: build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # needed for --filter comparisons
  - uses: pnpm/action-setup@v4
  - uses: actions/setup-node@v4
    with:
      node-version: 20
      cache: 'pnpm'

  - run: pnpm install --frozen-lockfile

  # Only lint/test/build affected packages
  - run: turbo run lint test build --filter='...[origin/main]'
    env:
      TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
      TURBO_TEAM: ${{ vars.TURBO_TEAM }}
undefined
name: CI on: pull_request:
jobs: build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # needed for --filter comparisons
  - uses: pnpm/action-setup@v4
  - uses: actions/setup-node@v4
    with:
      node-version: 20
      cache: 'pnpm'

  - run: pnpm install --frozen-lockfile

  # Only lint/test/build affected packages
  - run: turbo run lint test build --filter='...[origin/main]'
    env:
      TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
      TURBO_TEAM: ${{ vars.TURBO_TEAM }}
undefined

Publishing with Changesets

使用Changesets发布

Setup

初始化设置

bash
undefined
bash
undefined

Install changesets

Install changesets

pnpm add -D -w @changesets/cli @changesets/changelog-github
pnpm add -D -w @changesets/cli @changesets/changelog-github

Initialize

Initialize

pnpm changeset init
undefined
pnpm changeset init
undefined

.changeset/config.json

.changeset/config.json

json
{
  "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
  "changelog": ["@changesets/changelog-github", { "repo": "org/repo" }],
  "commit": false,
  "fixed": [],
  "linked": [["@repo/ui", "@repo/utils"]],
  "access": "public",
  "baseBranch": "main",
  "updateInternalDependencies": "patch"
}
json
{
  "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
  "changelog": ["@changesets/changelog-github", { "repo": "org/repo" }],
  "commit": false,
  "fixed": [],
  "linked": [["@repo/ui", "@repo/utils"]],
  "access": "public",
  "baseBranch": "main",
  "updateInternalDependencies": "patch"
}

Publishing Workflow

发布工作流

bash
undefined
bash
undefined

1. Developer adds a changeset for their changes

1. 开发者为其变更新增changeset记录

pnpm changeset
pnpm changeset

Interactive: select packages, bump type (patch/minor/major), summary

交互式操作:选择包、版本升级类型(补丁/次版本/主版本)、填写变更摘要

2. Before release: consume changesets and bump versions

2. 发布前:消费changeset记录并升级版本号

pnpm changeset version
pnpm changeset version

Updates package.json versions and CHANGELOG.md files

自动更新package.json版本号和CHANGELOG.md文件

3. Publish to npm

3. 发布到npm

pnpm changeset publish
pnpm changeset publish

Replaces workspace:* with real versions and publishes

自动替换workspace:*为真实版本号后发布

undefined
undefined

Migration: Multi-Repo to Monorepo

迁移:从多仓库到Monorepo

bash
undefined
bash
undefined

1. Preserve git history using filter-repo

1. 使用filter-repo保留Git历史

In each source repo:

在每个源仓库中执行:

git filter-repo --to-subdirectory-filter packages/ui git filter-repo --to-subdirectory-filter apps/api
git filter-repo --to-subdirectory-filter packages/ui git filter-repo --to-subdirectory-filter apps/api

2. Create monorepo and merge histories

2. 创建monorepo并合并历史

mkdir monorepo && cd monorepo && git init git remote add ui ../old-ui-repo git fetch ui --no-tags git merge ui/main --allow-unrelated-histories
git remote add api ../old-api-repo git fetch api --no-tags git merge api/main --allow-unrelated-histories
mkdir monorepo && cd monorepo && git init git remote add ui ../old-ui-repo git fetch ui --no-tags git merge ui/main --allow-unrelated-histories
git remote add api ../old-api-repo git fetch api --no-tags git merge api/main --allow-unrelated-histories

3. Set up workspace configuration

3. 配置工作区

Add pnpm-workspace.yaml, turbo.json, root package.json

新增pnpm-workspace.yaml、turbo.json、根package.json

4. Update internal imports

4. 更新内部导入路径

Change "ui-package" imports to "@repo/ui"

将"ui-package"导入改为"@repo/ui"

Change npm versions to "workspace:*"

将npm版本号改为"workspace:*"

5. Verify

5. 验证

pnpm install turbo run build test
undefined
pnpm install turbo run build test
undefined

Common Pitfalls

常见陷阱

PitfallFix
Running
turbo run build
without
--filter
on every PR
Always use
--filter='...[origin/main]'
in CI
workspace:*
breaks npm publish
Use
pnpm changeset publish
which replaces automatically
All packages rebuild when unrelated file changesTune
inputs
in turbo.json to exclude docs, config files
Shared tsconfig breaks type-checks across packagesEach package extends root but overrides
rootDir
/
outDir
Git history lost during migrationUse
git filter-repo --to-subdirectory-filter
before merging
Remote cache misses in CIVerify TURBO_TOKEN and TURBO_TEAM; check with
--summarize
Import cycles between packagesUse
madge --circular
to detect; refactor shared code to a new package
陷阱修复方案
每个PR都执行不带
--filter
turbo run build
CI中始终使用
--filter='...[origin/main]'
workspace:*
导致npm发布失败
使用
pnpm changeset publish
会自动替换该标识
无关文件变更触发所有包重建调整turbo.json中的
inputs
配置,排除文档、配置文件
共享tsconfig导致跨包类型检查失败每个包的配置继承根配置,同时单独覆写
rootDir
/
outDir
迁移过程中丢失Git历史合并前使用
git filter-repo --to-subdirectory-filter
处理
CI中远程缓存未命中验证TURBO_TOKEN和TURBO_TEAM配置,使用
--summarize
排查
包间存在循环依赖使用
madge --circular
检测,将共享代码抽离为新的无内部依赖包

Best Practices

最佳实践

  1. Root package.json has no runtime dependencies — only devDependencies and scripts
  2. Always scope commands with --filter in CI — running everything defeats the monorepo purpose
  3. Remote cache is not optional — without it, monorepo CI is slower than multi-repo
  4. Shared configs extend from root — tsconfig.base.json, eslint.base.js, vitest shared config
  5. packages/types
    is pure TypeScript
    — no runtime code, no dependencies, fastest to build
  6. Changesets over manual versioning — never hand-edit package.json versions in a monorepo
  7. Impact analysis before merging shared package changes — check affected packages, communicate blast radius
  8. Keep workspace: for internal deps* — real version ranges are for external npm packages only
  1. 根package.json不存放运行时依赖 —— 仅存放开发依赖和脚本
  2. CI中始终用--filter限定命令范围 —— 全量执行违背monorepo的设计初衷
  3. 远程缓存是必备能力 —— 没有远程缓存的monorepo CI比多仓架构更慢
  4. 共享配置从根配置继承 —— 包括tsconfig.base.json、eslint.base.js、vitest共享配置
  5. packages/types
    仅存放纯TypeScript定义
    —— 无运行时代码、无依赖,构建速度最快
  6. 优先使用Changesets而非手动版本管理 —— 不要在monorepo中手动编辑package.json的版本号
  7. 合并共享包变更前先做影响分析 —— 检查受影响包,同步变更的影响范围
  8. *内部依赖始终使用workspace:标识 —— 真实版本范围仅用于外部npm包

Troubleshooting

问题排查

ProblemCauseSolution
turbo run build
rebuilds everything despite no changes
Inputs glob is too broad or
globalDependencies
includes volatile files
Narrow
inputs
in turbo.json; exclude
.env
, docs, and test fixtures from build inputs
ERR_PNPM_PEER_DEP_ISSUES
on install
Peer dependency mismatches across workspace packagesAdd
peerDependencyRules.ignoreMissing
or
peerDependencyRules.allowAny
in root
.npmrc
or
package.json
Remote cache reports 0% hit rate in CITURBO_TOKEN or TURBO_TEAM not set, or
inputs
/
outputs
changed between runs
Verify env vars with
turbo run build --summarize
; ensure inputs/outputs are stable across branches
workspace:*
version appears in published package
Published with
npm publish
or
pnpm publish
instead of Changesets
Always use
pnpm changeset publish
which replaces
workspace:*
with resolved versions automatically
Circular dependency detected between packagesTwo packages import from each other directlyRun
madge --circular
to identify the cycle; extract shared code into a new leaf package with no internal deps
TypeScript
Cannot find module '@repo/ui'
in IDE
IDE TypeScript server not resolving workspace pathsAdd
paths
mapping in root
tsconfig.json
or use TypeScript project references; restart TS server after changes
CI takes longer after monorepo migration than multi-repoMissing remote cache, no
--filter
, or
fetch-depth: 1
preventing git comparisons
Enable remote caching, use
--filter='...[origin/main]'
, and set
fetch-depth: 0
in checkout action
问题原因解决方案
无任何变更时
turbo run build
仍触发全量重建
Inputs glob规则太宽泛,或
globalDependencies
包含易变文件
缩小turbo.json中的
inputs
范围,将.env、文档、测试 Mock 文件从构建输入中排除
安装时出现
ERR_PNPM_PEER_DEP_ISSUES
报错
工作区包间的peer依赖版本不匹配在根
.npmrc
package.json
中添加
peerDependencyRules.ignoreMissing
peerDependencyRules.allowAny
配置
CI中远程缓存命中率为0%未配置TURBO_TOKEN或TURBO_TEAM,或两次运行的
inputs
/
outputs
发生变更
使用
turbo run build --summarize
验证环境变量,确保不同分支的inputs/outputs配置一致
已发布的包中出现
workspace:*
版本标识
使用
npm publish
pnpm publish
而非Changesets发布
始终使用
pnpm changeset publish
,会自动将
workspace:*
替换为解析后的真实版本号
检测到包间循环依赖两个包直接互相导入运行
madge --circular
定位循环依赖,将共享代码抽离为无内部依赖的新叶子包
IDE中TypeScript报错
Cannot find module '@repo/ui'
IDE的TypeScript服务未解析工作区路径在根
tsconfig.json
中添加
paths
映射,或使用TypeScript项目引用,变更后重启TS服务
迁移到monorepo后CI耗时比多仓更长未启用远程缓存、未加
--filter
参数,或
fetch-depth: 1
导致Git对比失效
开启远程缓存,使用
--filter='...[origin/main]'
,并在checkout action中设置
fetch-depth: 0

Success Criteria

成功指标

  • Build time reduction: CI pipeline completes affected-only builds in under 50% of full-build time within 2 weeks of adoption
  • Cache hit rate: Remote cache achieves 70%+ hit rate on PR builds after initial warm-up period
  • Impact visibility: Every PR includes an affected-packages summary showing blast radius of changes
  • Zero full rebuilds in CI: No CI workflow runs all packages unconditionally; every pipeline uses
    --filter
    or equivalent
  • Publishing reliability: Changesets workflow produces correct versions and changelogs with zero manual
    package.json
    edits per release cycle
  • Migration completeness: Multi-repo to monorepo migration preserves 100% of git history for all migrated packages
  • Developer onboarding: New team members can run, build, and test any package locally within 15 minutes using documented workspace commands
  • 构建时长缩减:落地后2周内,CI流水线的仅受影响包构建耗时低于全量构建耗时的50%
  • 缓存命中率:预热完成后,PR构建的远程缓存命中率达到70%以上
  • 影响可见性:每个PR都附带受影响包摘要,展示变更的影响半径
  • 无全量CI构建:没有CI工作流无条件运行全量包任务,所有流水线都使用
    --filter
    或等效规则
  • 发布可靠性:Changesets工作流可生成正确的版本号和更新日志,每个发布周期无需手动编辑
    package.json
  • 迁移完整性:多仓到monorepo的迁移100%保留所有迁移包的Git历史
  • 开发者上手速度:新团队成员可通过文档中的工作区命令,在15分钟内完成任意包的本地运行、构建和测试

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
本技能覆盖:
  • Turborepo、Nx、pnpm工作区的配置与优化
  • 跨包依赖分析与影响可视化
  • 远程缓存搭建(Vercel、Nx Cloud、自托管)
  • 基于Changesets的协同版本管理与npm发布
本技能不覆盖:
  • 应用层面的构建配置(webpack、Vite、esbuild内部逻辑)—— 参考
    performance-profiler
  • 超出monorepo专属过滤规则的CI/CD流水线设计 —— 参考
    ci-cd-pipeline-builder
  • Git分支策略与发布流程 —— 参考
    release-manager
  • 依赖漏洞扫描与许可证审计 —— 参考
    dependency-auditor

Integration Points

集成点

SkillIntegrationData Flow
ci-cd-pipeline-builder
Monorepo-aware CI workflows use
--filter
flags and remote caching tokens
Monorepo Navigator defines filter patterns and cache config that CI pipelines consume
release-manager
Changesets versioning feeds into release orchestration and tag managementRelease Manager triggers
changeset version
and
changeset publish
as part of release flow
dependency-auditor
Workspace dependency graph informs vulnerability and license scanning scopeMonorepo Navigator exports the package dependency tree that Dependency Auditor analyzes
performance-profiler
Build profiling data identifies slow packages for optimizationPerformance Profiler measures per-package build times surfaced by Turborepo
--summarize
changelog-generator
Changesets produce per-package changelogs consumed by release notesChangeset summaries flow into Changelog Generator for formatted release documentation
tech-debt-tracker
Cross-package coupling and circular dependencies surface as tracked tech debt itemsMonorepo Navigator's impact analysis identifies coupling hotspots that Tech Debt Tracker records
技能集成方式数据流
ci-cd-pipeline-builder
感知monorepo的CI工作流使用
--filter
参数和远程缓存Token
Monorepo导航器定义CI流水线消费的过滤规则和缓存配置
release-manager
Changesets版本管理能力接入发布编排和标签管理发布管理器作为发布流程的一部分,触发
changeset version
changeset publish
命令
dependency-auditor
工作区依赖图为漏洞和许可证扫描提供范围Monorepo导航器导出包依赖树,供依赖审计器分析
performance-profiler
构建性能数据定位需要优化的慢包性能分析器测量Turborepo
--summarize
输出的单包构建时长
changelog-generator
Changesets生成的单包更新日志供发布说明消费Changeset摘要流入更新日志生成器,用于生成格式化的发布文档
tech-debt-tracker
跨包耦合和循环依赖作为技术债务项跟踪Monorepo导航器的影响分析识别耦合热点,供技术债务跟踪器记录