Master monorepo management with Turborepo, Nx

Master monorepo management with Turborepo, Nx, and pnpm workspaces to build efficient, scalable multi-package repositories with optimized builds and dependency management. Use when setting up monorepos, optimizing builds, or managing…
--- name: monorepo-management description: Master monorepo management with Turborepo, Nx, and pnpm workspaces to build efficient, scalable multi-package repositories with optimized builds and dependency management. Use when setting up monorepos, optimizing builds, or managing shared dependencies. --- # Monorepo Management Build efficient, scalable monorepos that enable code sharing, consistent tooling, and atomic changes across multiple packages and applications. ## When to Use This Skill - Setting up new monorepo projects - Migrating from multi-repo to monorepo - Optimizing build and test performance - Managing shared dependencies - Implementing code sharing strategies - Setting up CI/CD for monorepos - Versioning and publishing packages
Overview
Build efficient, scalable monorepos that enable code sharing, consistent tooling, and atomic changes across multiple packages and applications.
Manual install (npx, ZIP)
Claude Code
npx skills add wshobson/agents --skill monorepo-management -g -a claude-codeClaude Code (manual)
mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/developer-essentials/skills/monorepo-managementWindows (PowerShell)
New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/a4af696c1c67495458c5/monorepo-management.zip" -OutFile "$env:TEMP\monorepo-management.zip"; Expand-Archive "$env:TEMP\monorepo-management.zip" -DestinationPath "$HOME\.claude\skills" -ForceClaude.ai / desktop
Codex, Cursor, other agents
Connects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md5.0 KBreferences/1 file · 7.2 KB
Read the files here
SKILL.md
Show the full text218 lines
Monorepo Management
Build efficient, scalable monorepos that enable code sharing, consistent tooling, and atomic changes across multiple packages and applications.
When to Use This Skill
- Setting up new monorepo projects
- Migrating from multi-repo to monorepo
- Optimizing build and test performance
- Managing shared dependencies
- Implementing code sharing strategies
- Setting up CI/CD for monorepos
- Versioning and publishing packages
- Debugging monorepo-specific issues
Core Concepts
1. Why Monorepos?
Advantages:
- Shared code and dependencies
- Atomic commits across projects
- Consistent tooling and standards
- Easier refactoring
- Simplified dependency management
- Better code visibility
Challenges:
- Build performance at scale
- CI/CD complexity
- Access control
- Large Git repository
2. Monorepo Tools
Package Managers:
- pnpm workspaces (recommended)
- npm workspaces
- Yarn workspaces
Build Systems:
- Turborepo (recommended for most)
- Nx (feature-rich, complex)
- Lerna (older, maintenance mode)
Turborepo Setup
Initial Setup
# Create new monorepo
npx create-turbo@latest my-monorepo
cd my-monorepo
# Structure:
# apps/
# web/ - Next.js app
# docs/ - Documentation site
# packages/
# ui/ - Shared UI components
# config/ - Shared configurations
# tsconfig/ - Shared TypeScript configs
# turbo.json - Turborepo configuration
# package.json - Root package.json
Configuration
// turbo.json
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
},
"test": {
"dependsOn": ["build"],
"outputs": ["coverage/**"]
},
"lint": {
"outputs": []
},
"dev": {
"cache": false,
"persistent": true
},
"type-check": {
"dependsOn": ["^build"],
"outputs": []
}
}
}
// package.json (root)
{
"name": "my-monorepo",
"private": true,
"workspaces": ["apps/*", "packages/*"],
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"test": "turbo run test",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"clean": "turbo run clean && rm -rf node_modules"
},
"devDependencies": {
"turbo": "^1.10.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
"packageManager": "[email protected]"
}
Package Structure
// packages/ui/package.json
{
"name": "@repo/ui",
"version": "0.0.0",
"private": true,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./button": {
"import": "./dist/button.js",
"types": "./dist/button.d.ts"
}
},
"scripts": {
"build": "tsup src/index.ts --format esm,cjs --dts",
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
"lint": "eslint src/",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"@repo/tsconfig": "workspace:*",
"tsup": "^7.0.0",
"typescript": "^5.0.0"
},
"dependencies": {
"react": "^18.2.0"
}
}
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
- Consistent Versioning: Lock dependency versions across workspace
- Shared Configs: Centralize ESLint, TypeScript, Prettier configs
- Dependency Graph: Keep it acyclic, avoid circular dependencies
- Cache Effectively: Configure inputs/outputs correctly
- Type Safety: Share types between frontend/backend
- Testing Strategy: Unit tests in packages, E2E in apps
- Documentation: README in each package
- Release Strategy: Use changesets for versioning
Common Pitfalls
- Circular Dependencies: A depends on B, B depends on A
- Phantom Dependencies: Using deps not in package.json
- Incorrect Cache Inputs: Missing files in Turborepo inputs
- Over-Sharing: Sharing code that should be separate
- Under-Sharing: Duplicating code across packages
- Large Monorepos: Without proper tooling, builds slow down
Publishing Packages
# Using Changesets
pnpm add -Dw @changesets/cli
pnpm changeset init
# Create changeset
pnpm changeset
# Version packages
pnpm changeset version
# Publish
pnpm changeset publish
# .github/workflows/release.yml
- name: Create Release Pull Request or Publish
uses: changesets/action@v1
with:
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
| 1 | |
| 2 | name monorepo-management |
| 3 | description Master monorepo management with Turborepo, Nx, and pnpm workspaces to build efficient, scalable multi-package repositories with optimized builds and dependency management. Use when setting up monorepos, optimizing builds, or managing shared dependencies. |
| 4 | |
| 5 | |
| 6 | # Monorepo Management |
| 7 | |
| 8 | Build efficient, scalable monorepos that enable code sharing, consistent tooling, and atomic changes across multiple packages and applications. |
| 9 | |
| 10 | ## When to Use This Skill |
| 11 | |
| 12 | Setting up new monorepo projects |
| 13 | Migrating from multi-repo to monorepo |
| 14 | Optimizing build and test performance |
| 15 | Managing shared dependencies |
| 16 | Implementing code sharing strategies |
| 17 | Setting up CI/CD for monorepos |
| 18 | Versioning and publishing packages |
| 19 | Debugging monorepo-specific issues |
| 20 | |
| 21 | ## Core Concepts |
| 22 | |
| 23 | ### 1. Why Monorepos? |
| 24 | |
| 25 | **Advantages:** |
| 26 | |
| 27 | Shared code and dependencies |
| 28 | Atomic commits across projects |
| 29 | Consistent tooling and standards |
| 30 | Easier refactoring |
| 31 | Simplified dependency management |
| 32 | Better code visibility |
| 33 | |
| 34 | **Challenges:** |
| 35 | |
| 36 | Build performance at scale |
| 37 | CI/CD complexity |
| 38 | Access control |
| 39 | Large Git repository |
| 40 | |
| 41 | ### 2. Monorepo Tools |
| 42 | |
| 43 | **Package Managers:** |
| 44 | |
| 45 | pnpm workspaces (recommended) |
| 46 | npm workspaces |
| 47 | Yarn workspaces |
| 48 | |
| 49 | **Build Systems:** |
| 50 | |
| 51 | Turborepo (recommended for most) |
| 52 | Nx (feature-rich, complex) |
| 53 | Lerna (older, maintenance mode) |
| 54 | |
| 55 | ## Turborepo Setup |
| 56 | |
| 57 | ### Initial Setup |
| 58 | |
| 59 | |
| 60 | # Create new monorepo |
| 61 | npx create-turbo@latest my-monorepo |
| 62 | cd my-monorepo |
| 63 | |
| 64 | # Structure: |
| 65 | # apps/ |
| 66 | # web/ - Next.js app |
| 67 | # docs/ - Documentation site |
| 68 | # packages/ |
| 69 | # ui/ - Shared UI components |
| 70 | # config/ - Shared configurations |
| 71 | # tsconfig/ - Shared TypeScript configs |
| 72 | # turbo.json - Turborepo configuration |
| 73 | # package.json - Root package.json |
| 74 | |
| 75 | |
| 76 | ### Configuration |
| 77 | |
| 78 | |
| 79 | // turbo.json |
| 80 | { |
| 81 | "$schema": "https://turbo.build/schema.json", |
| 82 | "globalDependencies": ["**/.env.*local"], |
| 83 | "pipeline": { |
| 84 | "build": { |
| 85 | "dependsOn": ["^build"], |
| 86 | "outputs": ["dist/**", ".next/**", "!.next/cache/**"] |
| 87 | }, |
| 88 | "test": { |
| 89 | "dependsOn": ["build"], |
| 90 | "outputs": ["coverage/**"] |
| 91 | }, |
| 92 | "lint": { |
| 93 | "outputs": [] |
| 94 | }, |
| 95 | "dev": { |
| 96 | "cache": false, |
| 97 | "persistent": true |
| 98 | }, |
| 99 | "type-check": { |
| 100 | "dependsOn": ["^build"], |
| 101 | "outputs": [] |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | |
| 107 | |
| 108 | // package.json (root) |
| 109 | { |
| 110 | "name": "my-monorepo", |
| 111 | "private": true, |
| 112 | "workspaces": ["apps/*", "packages/*"], |
| 113 | "scripts": { |
| 114 | "build": "turbo run build", |
| 115 | "dev": "turbo run dev", |
| 116 | "test": "turbo run test", |
| 117 | "lint": "turbo run lint", |
| 118 | "format": "prettier --write \"**/*.{ts,tsx,md}\"", |
| 119 | "clean": "turbo run clean && rm -rf node_modules" |
| 120 | }, |
| 121 | "devDependencies": { |
| 122 | "turbo": "^1.10.0", |
| 123 | "prettier": "^3.0.0", |
| 124 | "typescript": "^5.0.0" |
| 125 | }, |
| 126 | "packageManager": "[email protected]" |
| 127 | } |
| 128 | |
| 129 | |
| 130 | ### Package Structure |
| 131 | |
| 132 | |
| 133 | // packages/ui/package.json |
| 134 | { |
| 135 | "name": "@repo/ui", |
| 136 | "version": "0.0.0", |
| 137 | "private": true, |
| 138 | "main": "./dist/index.js", |
| 139 | "types": "./dist/index.d.ts", |
| 140 | "exports": { |
| 141 | ".": { |
| 142 | "import": "./dist/index.js", |
| 143 | "types": "./dist/index.d.ts" |
| 144 | }, |
| 145 | "./button": { |
| 146 | "import": "./dist/button.js", |
| 147 | "types": "./dist/button.d.ts" |
| 148 | } |
| 149 | }, |
| 150 | "scripts": { |
| 151 | "build": "tsup src/index.ts --format esm,cjs --dts", |
| 152 | "dev": "tsup src/index.ts --format esm,cjs --dts --watch", |
| 153 | "lint": "eslint src/", |
| 154 | "type-check": "tsc --noEmit" |
| 155 | }, |
| 156 | "devDependencies": { |
| 157 | "@repo/tsconfig": "workspace:*", |
| 158 | "tsup": "^7.0.0", |
| 159 | "typescript": "^5.0.0" |
| 160 | }, |
| 161 | "dependencies": { |
| 162 | "react": "^18.2.0" |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | ## Detailed patterns and worked examples |
| 168 | |
| 169 | Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient. |
| 170 | |
| 171 | ## Best Practices |
| 172 | |
| 173 | **Consistent Versioning**: Lock dependency versions across workspace |
| 174 | **Shared Configs**: Centralize ESLint, TypeScript, Prettier configs |
| 175 | **Dependency Graph**: Keep it acyclic, avoid circular dependencies |
| 176 | **Cache Effectively**: Configure inputs/outputs correctly |
| 177 | **Type Safety**: Share types between frontend/backend |
| 178 | **Testing Strategy**: Unit tests in packages, E2E in apps |
| 179 | **Documentation**: README in each package |
| 180 | **Release Strategy**: Use changesets for versioning |
| 181 | |
| 182 | ## Common Pitfalls |
| 183 | |
| 184 | **Circular Dependencies**: A depends on B, B depends on A |
| 185 | **Phantom Dependencies**: Using deps not in package.json |
| 186 | **Incorrect Cache Inputs**: Missing files in Turborepo inputs |
| 187 | **Over-Sharing**: Sharing code that should be separate |
| 188 | **Under-Sharing**: Duplicating code across packages |
| 189 | **Large Monorepos**: Without proper tooling, builds slow down |
| 190 | |
| 191 | ## Publishing Packages |
| 192 | |
| 193 | |
| 194 | # Using Changesets |
| 195 | pnpm add -Dw @changesets/cli |
| 196 | pnpm changeset init |
| 197 | |
| 198 | # Create changeset |
| 199 | pnpm changeset |
| 200 | |
| 201 | # Version packages |
| 202 | pnpm changeset version |
| 203 | |
| 204 | # Publish |
| 205 | pnpm changeset publish |
| 206 | |
| 207 | |
| 208 | |
| 209 | # .github/workflows/release.yml |
| 210 | - name: Create Release Pull Request or Publish |
| 211 | uses: changesets/action@v1 |
| 212 | with: |
| 213 | publish: pnpm release |
| 214 | env: |
| 215 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 216 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 217 | |
| 218 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
SkillCreate branded architecture, architecture deltaDiagram design
SkillReview a PR against the Pascal architectural rulesReview architecture
SkillCreate and edit draw.io/diagrams.net diagramsDraw.io Architecture Studio
SkillCreate polished dark-themed architecture diagramsArchitecture Diagram Skill
SkillThe foundational knowledge distillation pattern for buildingLLM Wiki — Knowledge Distillation Pattern
SkillManage software complexity through deep modulesA Philosophy of Software Design FrameworkMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns