miles-knowbl

infra-monorepo

1
0
# Install this skill:
npx skills add miles-knowbl/orchestrator --skill "infra-monorepo"

Install specific skill from multi-skill repository

# Description

Configure monorepo tooling with workspace management, task orchestration, and build caching for multi-package projects.

# SKILL.md


name: infra-monorepo
description: "Configure monorepo tooling with workspace management, task orchestration, and build caching for multi-package projects."
phase: IMPLEMENT
category: infra
version: "1.0.0"
depends_on: ["scaffold"]
tags: [infrastructure, monorepo, turbo, workspace, build-system]


Infra Monorepo

Configure monorepo tooling for multi-package projects.

When to Use

  • Multi-package project β€” Shared code across multiple apps or libraries
  • Monorepo migration β€” Moving from multi-repo to monorepo
  • Build optimization β€” Adding caching and incremental builds
  • When you say: "set up monorepo", "workspace config", "turborepo"

Required Deliverables

Deliverable Location Condition
Workspace config package.json or pnpm-workspace.yaml Always
Task config turbo.json When using Turborepo
Package structure packages/ and/or apps/ Always

Core Concept

Monorepo setup answers: "How do multiple packages share code, dependencies, and build infrastructure?"

Root Config β†’ Workspace Packages β†’ Shared Dependencies β†’ Cached Builds β†’ Coordinated Publishing

Tool Selection

Tool Best For Package Manager
Turborepo Task caching, incremental builds npm/pnpm/yarn
pnpm workspaces Dependency management, disk efficiency pnpm
npm workspaces Simple monorepos, no extra tools npm
Nx Enterprise, generators, plugins npm/pnpm/yarn

Turborepo Setup

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

Workspace Structure

monorepo/
β”œβ”€β”€ package.json          # Root with workspaces
β”œβ”€β”€ turbo.json            # Task configuration
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/              # Next.js app
β”‚   β”‚   └── package.json
β”‚   └── api/              # Express server
β”‚       └── package.json
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ shared/           # Shared utilities
β”‚   β”‚   └── package.json
β”‚   └── config/           # Shared config (tsconfig, eslint)
β”‚       └── package.json
└── pnpm-workspace.yaml   # If using pnpm

pnpm Workspace Config

# pnpm-workspace.yaml
packages:
  - 'apps/*'
  - 'packages/*'

Cross-Package Dependencies

// apps/web/package.json
{
  "dependencies": {
    "@monorepo/shared": "workspace:*"
  }
}

Checklist

  • [ ] Workspace configuration in root package.json
  • [ ] Task runner configured (turbo.json or scripts)
  • [ ] Shared packages in packages/ directory
  • [ ] Apps in apps/ directory
  • [ ] Cross-package dependencies use workspace protocol
  • [ ] Build caching enabled

Relationship to Other Skills

Skill Relationship
scaffold Scaffold creates the directory structure; monorepo adds workspace tooling
infra-docker Each app may have its own Dockerfile
distribute CI/CD may need to build affected packages only
test-generation Tests run per-package with shared configuration

Key Principles

Share code, not coupling. Packages should have clear boundaries and APIs.

Cache everything. Turborepo caching avoids rebuilding unchanged packages.

Workspace protocol. Use workspace:* for internal dependencies, never published versions.

Incremental builds. Only rebuild what changed; task graphs express dependencies.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.