Master monorepo management with Turborepo, Nx

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Monorepo management cover

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 Codenpx skills add wshobson/agents --skill monorepo-management -g -a claude-code
Claude 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-management
Windows (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" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.0 KB
  • references/1 file · 7.2 KB
Read the files here
wshobson/4236bb92 files
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

  1. Consistent Versioning: Lock dependency versions across workspace
  2. Shared Configs: Centralize ESLint, TypeScript, Prettier configs
  3. Dependency Graph: Keep it acyclic, avoid circular dependencies
  4. Cache Effectively: Configure inputs/outputs correctly
  5. Type Safety: Share types between frontend/backend
  6. Testing Strategy: Unit tests in packages, E2E in apps
  7. Documentation: README in each package
  8. 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---
2name: monorepo-management
3description: 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 
8Build 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```bash
60# Create new monorepo
61npx create-turbo@latest my-monorepo
62cd 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```json
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```json
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```json
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 
169Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
170 
171## Best Practices
172 
1731. **Consistent Versioning**: Lock dependency versions across workspace
1742. **Shared Configs**: Centralize ESLint, TypeScript, Prettier configs
1753. **Dependency Graph**: Keep it acyclic, avoid circular dependencies
1764. **Cache Effectively**: Configure inputs/outputs correctly
1775. **Type Safety**: Share types between frontend/backend
1786. **Testing Strategy**: Unit tests in packages, E2E in apps
1797. **Documentation**: README in each package
1808. **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```bash
194# Using Changesets
195pnpm add -Dw @changesets/cli
196pnpm changeset init
197 
198# Create changeset
199pnpm changeset
200 
201# Version packages
202pnpm changeset version
203 
204# Publish
205pnpm changeset publish
206```
207 
208```yaml
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 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
SkillCreate branded architecture, architecture deltaDiagram designcathrynlavery/diagram-design · by cathrynlaveryCreate branded architecture, architecture delta, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, polar chart (polar/radial lollipop), loop/flywheel, nested, tree, org chart, layer stack, Venn, pyramid/funnel, treemap and marimekko, heatmap, bar and dumbbell, waterfall, line (slopegraph, ridgeline, streamgraph, bump), Gantt and scatter charts (bubble, beeswarm), high-level, process, medallion, data flow, DP integration, DP security matrix, Sankey, fishbone, Wardley map, kanban, user journey, deployment, dependency graph, UML class, story map, or database schema diagrams as HTML/SVG/PNG, with .drawio, Mermaid, and .excalidraw import, plus lifecycle phase maps, block decomposition trees, and onboarding guidance.★ 43.2k GitHub starsSkillReview a PR against the Pascal architectural rulesReview architecturepascalorg/editor · by pascalorgReview a PR against the Pascal architectural rules — package boundaries (core/viewer/editor/nodes), the registry-driven composition model (def.geometry / def.renderer / def.system), legacy-dispatch regressions, the slots + world-scale-UV convention for new nodes/geometry, hook hygiene (useEditor/useScene/useViewer), and selector performance. Use when the user asks to review a PR, audit a branch, or check that changes respect the codebase's architecture.★ 24.6k GitHub starsSkillCreate and edit draw.io/diagrams.net diagramsDraw.io Architecture StudioAgents365-ai/drawio-skill · by Agents365-aiCreate and edit draw.io/diagrams.net diagrams as editable `.drawio` files. Covers architecture, UML/ERD/sequence, BPMN, network, and swimlane views authored from a description or converted from code, IaC, SQL, and API schemas, plus sync, query, test, review, export, and publish of existing diagrams. Use when the user asks for draw.io/diagrams.net or an editable diagram; prefer Mermaid/PlantUML when diagrams-as-code is enough.★ 9.8k GitHub starsSkillCreate polished dark-themed architecture diagramsArchitecture Diagram SkillCocoon-AI/architecture-diagram-generator · by Cocoon-AICreate polished dark-themed architecture diagrams as self-contained HTML+SVG files. Use when the user asks for system, infrastructure, cloud, security, or network topology diagrams.★ 7.4k GitHub starsSkillThe foundational knowledge distillation pattern for buildingLLM Wiki — Knowledge Distillation PatternAr9av/obsidian-wiki · by Ar9avThe foundational knowledge distillation pattern for building and maintaining an AI-powered Obsidian wiki. Based on Andrej Karpathy's LLM Wiki architecture. Use this skill whenever the user wants to understand the wiki pattern, set up a new knowledge base, or needs guidance on the three-layer architecture (raw sources → wiki → schema). Also use when discussing knowledge management strategy, wiki structure decisions, or how to organize distilled knowledge. This is the "theory" skill — other skills handle specific operations (ingesting, querying, linting).★ 3.5k GitHub starsSkillManage software complexity through deep modulesA Philosophy of Software Design Frameworkwondelai/skills · by wondelaiManage software complexity through deep modules, information hiding, and strategic programming. Use when the user mentions "module design", "API too complex", "shallow class", "complexity budget", "strategic vs tactical", "deep module", "information leakage", "pass-through method", "this code is over-engineered", or "simplify this design". Also trigger when reviewing an interface for simplicity, evaluating whether an abstraction is pulling its weight, deciding whether a comment is worth writing, or choosing between general-purpose and special-purpose approaches. Covers deep vs shallow modules, red flags for complexity, and comments as design documentation. For code quality, see clean-code. For architecture boundaries, see clean-architecture.★ 2.2k GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars