PluginBench
Skill
Pass
Audit score 90

monorepo-management

wshobson/agents

Master Turborepo, Nx, and pnpm workspaces for efficient, scalable multi-package repositories.

What is monorepo-management?

This skill teaches monorepo management using modern tools like Turborepo and pnpm workspaces. Use it when setting up new monorepos, migrating from multi-repo architectures, optimizing builds, managing shared dependencies, or implementing CI/CD pipelines for multi-package projects.

  • Set up and configure Turborepo monorepos with optimized build pipelines
  • Manage shared dependencies and code across multiple packages using pnpm workspaces
  • Configure task caching and dependency graphs to accelerate builds and tests
  • Structure packages and applications with consistent tooling and TypeScript configs
  • Implement versioning and publishing workflows using Changesets
  • Debug circular dependencies and phantom dependency issues

How to install monorepo-management

npx skills add https://github.com/wshobson/agents --skill monorepo-management
Prerequisites
  • Node.js 16+ and pnpm 8.0+
  • Basic understanding of package managers and npm workspaces
  • Git repository for version control
Claude Code
Cursor
Windsurf
Cline

How to use monorepo-management

  1. 1.Run `npx create-turbo@latest my-monorepo` to scaffold a new monorepo with apps/ and packages/ directories
  2. 2.Configure `turbo.json` with pipeline tasks (build, test, lint, dev) and their dependencies using `dependsOn`
  3. 3.Set up `pnpm workspaces` in root `package.json` to link local packages with `workspace:*` protocol
  4. 4.Create shared packages in `packages/` (e.g., @repo/ui, @repo/tsconfig) with proper exports and TypeScript configs
  5. 5.Run `pnpm install` to install dependencies, then `turbo run build` to execute cached builds across all packages
  6. 6.Set up Changesets with `pnpm changeset init` and `pnpm changeset` to manage versioning and publishing

Use cases

Good for
  • Creating a new monorepo with apps (Next.js, docs) and shared packages (UI components, configs)
  • Migrating from separate repositories to a unified monorepo while maintaining atomic commits
  • Optimizing CI/CD pipelines to cache and parallelize builds across 10+ packages
  • Publishing versioned packages to npm with automated release workflows
  • Sharing TypeScript types and ESLint configs across frontend and backend applications
Who it's for
  • Full-stack teams managing multiple related applications
  • Platform engineers building internal tooling and component libraries
  • Open-source maintainers publishing multiple interdependent packages
  • Teams migrating from polyrepo to monorepo architecture

monorepo-management FAQ

What's the difference between Turborepo and Nx?

Turborepo is simpler and faster for most teams, focusing on task orchestration and caching. Nx is more feature-rich with generators, workspace analysis, and stricter dependency rules, but adds complexity. Choose Turborepo for straightforward monorepos; Nx for large enterprises needing advanced tooling.

How do I avoid circular dependencies?

Structure packages hierarchically: apps depend on packages, packages depend on other packages, but never reverse. Use ESLint rules like `eslint-plugin-import` to detect cycles. Keep shared utilities in a base package that nothing else depends on.

Why use pnpm workspaces over npm or Yarn?

pnpm workspaces are faster, use less disk space with hard links, and enforce stricter dependency management to prevent phantom dependencies. They're the recommended choice for modern monorepos.

How do I cache builds correctly in Turborepo?

Configure `inputs` and `outputs` in turbo.json pipeline tasks. Inputs specify which files trigger cache invalidation; outputs specify what to cache. For example, `build` outputs `dist/**` and depends on `^build` of dependencies.

Can I publish individual packages from a monorepo?

Yes, use Changesets to manage versioning and publishing. Each package has its own version and package.json. Run `pnpm changeset publish` to publish changed packages to npm automatically.

Full instructions (SKILL.md)

Source of truth, from wshobson/agents.


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
  • 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": "pnpm@8.0.0"
}

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 }}