Okay, the user wants a comprehensive migration plan from polyrepo to monorepo, including tooling and adoption strategies. This is a complex operational change, so the plan needs to be structured yet flexible.
First, I should clarify the goals—why migrate? Common drivers include dependency management, standardization, and developer experience. The response must start with defining success metrics to keep the migration measurable.
Next, tooling selection is critical. The user likely wants practical recommendations, not just theory. I’ll split tools into categories: package managers (like npm/yarn/pnpm), build systems (Bazel/NX/Turbo), CI/CD, and dependency management. Emphasize that tooling should match the team’s scale and complexity—no one-size-fits-all.
Adoption is often the hardest part. Need to address human factors: communication, incremental migration, training, and rollback plans. Highlight pilot projects to de-risk the change. Also, stress governance—how to handle cross-team ownership and conflict resolution in a monorepo.
The timeline should be phased, not big-bang. Weeks 1-4 for prep and pilot, then gradual rollout. Include checkpoints and retrospects. Finally, list common pitfalls (like ignoring legacy tech or poor communication) and mitigation strategies.
The tone should be authoritative but approachable—this is a playbook, not a textbook. Avoid jargon unless explained. Prioritize clarity over completeness; better to focus on actionable steps than overwhelm with options.
Polyrepo to Monorepo Migration Plan
Tooling, Adoption Strategy, and Execution Roadmap
1. Migration Goals & Success Metrics
Primary Goals:
- ✅ Centralize dependency management (reduce version drift).
- ✅ Standardize tooling/configs (linters, formatters, build scripts).
- ✅ Improve cross-project refactoring & atomic commits.
- ✅ Streamline CI/CD (caching, parallelization).
- ✅ Enhance developer onboarding (single clone, consistent scripts).
Success Metrics:
- Build times: 30% faster incremental builds after tooling optimization.
- Dependency consistency: 100% of projects use aligned versions (via lockfile).
- Onboarding time: New devs set up env in <30 mins (vs. polyrepo scattered setup).
- Cross-repo changes: Atomic commits across 3+ services in single PR.
- Adoption: >80% of teams actively developing in monorepo within 6 months.
2. Tooling Selection
Choose based on stack size, team scale, and performance needs.
| Category | Options | Recommendation |
|---|
| Package Manager | npm/yarn, pnpm, Turborepo (built-in) | pnpm (strict, disk-efficient) + Turborepo for caching. |
| Build System | NX, Bazel, Turborepo, Rush | Turborepo (simpler, JS/TS-focused) or NX (plugins, complex graphs). |
| CI/CD | GitHub Actions, GitLab CI, CircleCI | GitHub Actions with remote caching (Turborepo/NX cloud). |
| Code Gen/APIs | Protobuf/GraphQL schema Shared | Centralize .proto/.graphql files in monorepo, generate per-service. |
| Linting/Format | ESLint, Prettier, Biome | Single config at root, extends per-package as needed. |
| Versioning | Changesets, Lerna, Semantic Release | Changesets (simple, human-readable changelogs). |
Why Turborepo?
- Zero-config for JS/TS, remote caching, built-in task orchestration.
- Simpler than NX/Bazel for typical web/mobile stacks.
- Works with pnpm/yarn/npm.
3. Migration Phases
Phase 0: Pre-Migration Prep (Weeks 1-2)
- Inventory all repos:
- Tech stack, dependencies, build scripts, CI configs.
- Identify circular dependencies (⚠️ blocker).
- Pick monorepo tooling (test with 2-3 sample repos).
- Define repo structure:
/monorepo
├── packages/
│ ├── frontend/ # React app
│ ├── backend-api/ # Node.js service
│ ├── shared-utils/ # Common lib
│ └── mobile-app/ # React Native
├── tools/ # Custom scripts
├── package.json # Root (workspaces)
└── turbo.json # Task pipeline
- Establish governance:
- Code owners file (
CODEOWNERS) for each package.
- Merge/PR guidelines (e.g., “no breaking changes without consent from affected teams”).
Phase 1: Pilot Migration (Weeks 3-4)
Scope: Move 2-3 low-risk, loosely coupled repos (e.g., shared-utils + one service).
- Create monorepo skeleton with tooling.
- Move code preserving git history (use
git filter-repo):
git filter-repo --subdirectory-filter old-repo-path new-repo-path
- Fix imports (update relative paths to monorepo workspace deps).
- Configure pnpm workspaces in root
package.json:
{
"private": true,
"workspaces": ["packages/*"]
}
- Test locally: Install deps, run builds/tests.
- Set up CI for pilot (cache layers, run tests per package).
- Retrospective: Document pain points (e.g., path aliases, env vars).
Phase 2: Incremental Migration (Weeks 5-12)
Strategy: Migrate by team or domain, not arbitrarily.
- Prioritize:
- High inter-repo coupling first (so they benefit from atomic commits).
- Low external dependencies (easier to isolate).
- Migration checklist per package:
- Keep old repos read-only (archive, add redirect in README).
- Run both systems in parallel for 1-2 weeks (if feasible) for validation.
Phase 3: Full Cutover & Cleanup (Weeks 13-16)
- Archive polyrepos (set to read-only, update docs/links).
- Finalize monorepo config:
- Global
.gitignore, ESLint/Prettier config at root.
- Shared CI templates (e.g., reusable GitHub Actions).
- Dependency update bots (e.g., Renovate/Dependabot configured for workspaces).
- Training & Documentation:
- Dev onboarding guide: Single clone,
pnpm install, turbo dev.
- Common tasks doc: “How to add a new package”, “How to run tests for one package”.
- Workspace debugging (cache issues, dependency resolution).
- Monitor performance:
- CI times (should drop with remote caching).
- Disk usage (pnpm stores deps efficiently).
4. Adoption & Change Management
Communication Plan
- Week 0: Announce vision, timeline, and pilot teams.
- Weekly standups: Migration sync (blockers, progress).
- Documentation hub: Central Confluence/Notion page with FAQ.
- Feedback loop: Dedicated Slack channel (#monorepo-migration).
Training
- Workshop: “Monorepo 101” (tooling, commands, debugging).
- Office hours: 2x/week for migration help.
- Cheat sheet: Common commands at root vs. package level.
Incentives
- Recognition: Celebrate first team to fully migrate.
- Metrics showcase: “Before/after” CI time, dependency graph clarity.
5. Risks & Mitigations
| Risk | Mitigation |
|---|
| Long initial clone (large repo) | Use sparse-checkout for new hires; archive old history. |
| CI/CD slowdown (all packages) | Optimize Turbo/NX pipeline; cache aggressively; only run affected tasks. |
| Merge conflicts (high traffic) | Encourage small PRs; use turbo run --parallel for non-dependent tasks. |
| Tooling lock-in | Choose open tools (Turborepo/NX); avoid proprietary plugins. |
| Team resistance | Pilot with volunteers; show quick wins (faster installs). |
| Legacy build scripts breaking | Wrap legacy scripts in adapters; gradual refactoring. |
6. Rollback Plan
- Keep old polyrepos archived (tagged commit, read-only).
- Do not delete until 3 months post-migration with zero incidents.
- Preserve migration scripts to reverse if needed (but expect merge pain).
7. Timeline Summary
gantt
title Monorepo Migration Timeline
dateFormat YYYY-MM-DD
section Prep
Inventory & Tooling Selection :2024-06-01, 2w
Pilot Migration :2024-06-15, 2w
section Migration
Incremental (by team) :2024-06-29, 6w
section Stabilization
Cutover & Cleanup :2024-08-10, 4w
Training & Docs :2024-08-10, 3w
8. Sample Migration Command Flow
# 1. Create monorepo
mkdir company-monorepo && cd company-monorepo
pnpm init
pnpm add -wD turbo
# 2. Add workspace package (from old repo)
cp -R ../old-repo packages/service-a
cd packages/service-a
# Update package.json:
# "name": "@company/service-a"
# "dependencies": { "@company/shared-utils": "workspace:*" }
# 3. Root package.json
{
"private": true,
"workspaces": ["packages/*"]
}
# 4. turbo.json (root)
{
"pipeline": {
"build": { "dependsOn": ["^build"], "outputs": ["dist/**"] },
"test": { "dependsOn": ["build"], "outputs": [] }
}
}
# 5. Run all builds
turbo run build
9. Post-Migration Checklist
Key Principle: Incremental, team-led migration—not a big-bang rewrite.
Start small, prove value with pilot, then expand with strong tooling and support.
🚀 Final Tip: Choose tooling that removes friction, not adds complexity. If Turborepo works for 80% of cases, avoid over-engineering with Bazel.