Skip to content
OpenSmartRoute
Skillv1.0.0

monorepo-management

Manage monorepos and multi-package repositories with workspace tools, dependency management, selective builds, and change detection. Covers npm/pnpm workspaces, Turborepo, and Python monorepo patterns

by organvm-iv-taxis(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from organvm-iv-taxis/a-i--skills (skills/development/monorepo-management/SKILL.md). Install upstream with npx skills add organvm-iv-taxis/a-i--skills --skill monorepo-management. Copyright stays with the author (MIT).

Monorepo Management

Organize and build multi-package repositories efficiently.

When to Monorepo

Situation Monorepo Polyrepo
Shared libraries across packages Yes No
Tight coupling between packages Yes No
Independent release cycles needed No Yes
Different teams, different cadences No Yes
Atomic cross-package changes Yes No
< 20 packages Yes Either
> 100 packages Depends Often better

JavaScript/TypeScript Workspaces

pnpm Workspaces

# pnpm-workspace.yaml
packages:
  - "packages/*"
  - "apps/*"
  - "tools/*"
// package.json (root)
{
  "private": true,
  "scripts": {
    "build": "turbo build",
    "test": "turbo test",
    "lint": "turbo lint"
  }
}

Package Structure

monorepo/
├── pnpm-workspace.yaml
├── turbo.json
├── package.json
├── packages/
│   ├── ui/                # Shared UI components
│   │   ├── package.json
│   │   └── src/
│   ├── config/            # Shared config (ESLint, TS)
│   │   └── package.json
│   └── utils/             # Shared utilities
│       └── package.json
├── apps/
│   ├── web/               # Next.js app
│   │   └── package.json
│   └── api/               # Express API
│       └── package.json
└── tools/
    └── scripts/           # Build/deploy scripts

Internal Package References

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

Turborepo Configuration

// turbo.json
{
  "$schema": "https://turbo.build/schema.json",
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", ".next/**"]
    },
    "test": {
      "dependsOn": ["build"],
      "outputs": []
    },
    "lint": {
      "outputs": []
    },
    "dev": {
      "persistent": true,
      "cache": false
    }
  }
}

Filtered Builds

# Build only packages affected by changes
turbo build --filter=...[HEAD~1]

# Build a specific package and its dependencies
turbo build --filter=@myorg/web

# Build everything that depends on a package
turbo build --filter=...@myorg/ui

Python Monorepo Patterns

Using a Shared Virtualenv

monorepo/
├── pyproject.toml          # Root with all optional deps
├── packages/
│   ├── core/
│   │   ├── pyproject.toml
│   │   └── src/core/
│   ├── api/
│   │   ├── pyproject.toml
│   │   └── src/api/
│   └── worker/
│       ├── pyproject.toml
│       └── src/worker/
└── tests/
# Root pyproject.toml
[project]
name = "monorepo"
dependencies = []

[project.optional-dependencies]
core = ["./packages/core"]
api = ["./packages/api"]
worker = ["./packages/worker"]
dev = ["pytest", "ruff", "mypy"]
all = ["monorepo[core,api,worker,dev]"]
pip install -e ".[all]"

Namespace Packages

packages/core/src/myorg/core/__init__.py
packages/api/src/myorg/api/__init__.py
# Both install into the `myorg` namespace

Dependency Management

Version Consistency

// .syncpackrc (syncpack)
{
  "versionGroups": [
    {
      "dependencies": ["react", "react-dom"],
      "packages": ["**"],
      "pinVersion": "^18.3.0"
    }
  ]
}
# Check version consistency
syncpack list-mismatches
# Fix mismatches
syncpack fix-mismatches

Dependency Graph

# Visualize internal dependencies
turbo ls --graph

# nx
nx graph

CI/CD for Monorepos

Change Detection

#!/usr/bin/env bash
set -euo pipefail

# Detect which packages changed
CHANGED=$(git diff --name-only HEAD~1 | grep '^packages/' | cut -d/ -f2 | sort -u)

for pkg in $CHANGED; do
    echo "Building packages/$pkg"
    cd "packages/$pkg" && npm run build && cd ../..
done

GitHub Actions Matrix

jobs:
  detect-changes:
    runs-on: ubuntu-latest
    outputs:
      packages: ${{ steps.changes.outputs.packages }}
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 2 }
      - id: changes
        run: |
          PKGS=$(git diff --name-only HEAD~1 | grep '^packages/' | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n") | map(select(. != ""))')
          echo "packages=$PKGS" >> $GITHUB_OUTPUT

  build:
    needs: detect-changes
    if: needs.detect-changes.outputs.packages != '[]'
    strategy:
      matrix:
        package: ${{ fromJson(needs.detect-changes.outputs.packages) }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: cd packages/${{ matrix.package }} && npm ci && npm run build

Anti-Patterns

  • No task runner — Manual build ordering doesn't scale; use Turborepo or Nx
  • Circular dependencies — Packages must form a DAG; validate in CI
  • Everything in one package.json — Separate packages even in a monorepo
  • No change detection in CI — Building everything on every commit wastes time
  • Version drift — Enforce consistent dependency versions with syncpack or similar
  • Implicit dependencies — Always declare package-level dependencies explicitly

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/organvm-iv-taxis-a-i-skills-monorepo-management/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

organvm-iv-taxis-a-i-skills-monorepo-management.ocm.jsonjson
{
  "ocm": "1",
  "id": "organvm-iv-taxis-a-i-skills-monorepo-management",
  "kind": "skill",
  "name": "monorepo-management",
  "description": "Manage monorepos and multi-package repositories with workspace tools, dependency management, selective builds, and change detection. Covers npm/pnpm workspaces, Turborepo, and Python monorepo patterns. Triggers on monorepo setup, workspace management, or multi-package repository requests.",
  "publisher": "organvm-iv-taxis",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "monorepo",
      "workspaces",
      "turborepo",
      "multi-package",
      "build-system",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Manage monorepos and multi-package repositories with workspace tools, dependency management, selective builds, and change detection. Covers npm/pnpm workspaces, Turborepo, and Python monorepo patterns. Triggers on monorepo setup, workspace management, or multi-package repository requests."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/organvm-iv-taxis/a-i--skills",
      "path": "skills/development/monorepo-management/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/organvm-iv-taxis/a-i--skills/blob/HEAD/skills/development/monorepo-management/SKILL.md",
      "key": "organvm-iv-taxis/a-i--skills/skills/development/monorepo-management/SKILL.md"
    },
    "license": "MIT"
  },
  "instructions": "# Monorepo Management\n\nOrganize and build multi-package repositories efficiently.\n\n## When to Monorepo\n\n| Situation | Monorepo | Polyrepo |\n|-----------|----------|----------|\n| Shared libraries across packages | Yes | No |\n| Tight coupling between packages | Yes | No |\n| Independent release cycles needed | No | Yes |\n| Different teams, different cadences | No | Yes |\n| Atomic cross-package changes | Yes | No |\n| < 20 packages | Yes | Either |\n| > 100 packages | Depends | Often better |\n\n## JavaScript/TypeScript Workspaces\n\n### pnpm Workspaces\n\n```yaml\n# pnpm-workspace.yaml\npackages:\n  - \"pack",
  "cost": {
    "context_tokens": 1266
  }
}

Fetch it by URL: GET /api/v1/registry/organvm-iv-taxis-a-i-skills-monorepo-management/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.