monorepoBuild and manage monorepos with Turborepo, Nx, and pnpm workspaces ā covering workspace structure, dependency management, task orchestration, caching, CI/CD, and publishing. Use when setting up monorepos, optimizing builds, or managing shared packages.
Install via ClawdBot CLI:
clawdbot install wpank/monorepoBuild efficient, scalable monorepos that enable code sharing, consistent tooling, and atomic changes across multiple packages and applications.
Advantages: Shared code and dependencies, atomic commits across projects, consistent tooling, easier refactoring, better code visibility.
Challenges: Build performance at scale, CI/CD complexity, access control, large Git history.
| Manager | Recommendation | Notes |
|---------|---------------|-------|
| pnpm | Recommended | Fast, strict, excellent workspace support |
| npm | Acceptable | Built-in workspaces, slower installs |
| Yarn | Acceptable | Mature, but pnpm surpasses in most areas |
| Tool | Best For | Trade-off |
|------|----------|-----------|
| Turborepo | Most projects | Simple config, fast caching, Vercel integration |
| Nx | Large orgs, complex graphs | Feature-rich but steeper learning curve |
| Lerna | Legacy projects | Maintenance mode ā migrate away |
Guidance: Start with Turborepo unless you need Nx's code generation, dependency graph visualization, or plugin ecosystem.
my-monorepo/
āāā apps/
ā āāā web/ # Next.js app
ā āāā api/ # Backend service
ā āāā docs/ # Documentation site
āāā packages/
ā āāā ui/ # Shared UI components
ā āāā utils/ # Shared utilities
ā āāā types/ # Shared TypeScript types
ā āāā config-eslint/ # Shared ESLint config
ā āāā config-ts/ # Shared TypeScript configs
āāā turbo.json # Turborepo pipeline config
āāā pnpm-workspace.yaml # Workspace definition
āāā package.json # Root package.json
Convention: apps/ for deployable applications, packages/ for shared libraries.
# pnpm-workspace.yaml
packages:
- "apps/*"
- "packages/*"
// package.json (root)
{
"name": "my-monorepo",
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"test": "turbo run test",
"lint": "turbo run lint",
"type-check": "turbo run type-check",
"clean": "turbo run clean && rm -rf node_modules"
},
"devDependencies": {
"turbo": "^2.0.0",
"prettier": "^3.0.0"
},
"packageManager": "pnpm@9.0.0"
}
// turbo.json
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**"],
"inputs": ["src/**", "package.json", "tsconfig.json"]
},
"test": {
"dependsOn": ["build"],
"outputs": ["coverage/**"]
},
"lint": {
"outputs": []
},
"type-check": {
"dependsOn": ["^build"],
"outputs": []
},
"dev": {
"cache": false,
"persistent": true
}
}
}
Key concepts:
dependsOn: ["^build"] ā build dependencies first (topological)outputs ā what to cache (omit for side-effect-only tasks)inputs ā what invalidates cache (default: all files)persistent: true ā for long-running dev serverscache: false ā disable caching for dev tasks// packages/ui/package.json
{
"name": "@repo/ui",
"version": "0.0.0",
"private": true,
"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"
},
"devDependencies": {
"@repo/config-ts": "workspace:*",
"tsup": "^8.0.0"
}
}
npx create-nx-workspace@latest my-org
# Generate projects
nx generate @nx/react:app my-app
nx generate @nx/js:lib utils
// nx.json
{
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"],
"cache": true
},
"test": {
"inputs": ["default", "^production"],
"cache": true
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*"],
"production": ["default", "!{projectRoot}/**/*.spec.*"]
}
}
# Nx-specific commands
nx build my-app
nx affected:build --base=main # Only build what changed
nx graph # Visualize dependency graph
nx run-many --target=build --all --parallel=3
Nx advantage: nx affected computes exactly which projects changed, skipping unaffected ones entirely.
# Install in specific package
pnpm add react --filter @repo/ui
pnpm add -D typescript --filter @repo/ui
# Install workspace dependency
pnpm add @repo/ui --filter web
# Install in root (shared dev tools)
pnpm add -D eslint -w
# Run script in specific package
pnpm --filter web dev
pnpm --filter @repo/ui build
# Run in all packages
pnpm -r build
# Filter patterns
pnpm --filter "@repo/*" build
pnpm --filter "...web" build # web + all its dependencies
# Update all dependencies
pnpm update -r
# Hoist shared dependencies for compatibility
shamefully-hoist=true
# Strict peer dependency management
auto-install-peers=true
strict-peer-dependencies=true
// packages/config-ts/base.json
{
"compilerOptions": {
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"declaration": true
}
}
// apps/web/tsconfig.json
{
"extends": "@repo/config-ts/base.json",
"compilerOptions": { "outDir": "dist", "rootDir": "src" },
"include": ["src"]
}
# Turborepo + Vercel remote cache
npx turbo login
npx turbo link
# Now builds share cache across CI and all developers
# First build: 2 minutes. Cache hit: 0 seconds.
{
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"],
"inputs": ["src/**/*.tsx", "src/**/*.ts", "package.json"]
}
}
}
Critical: Define inputs precisely. If a build only depends on src/, don't let changes to README.md invalidate the cache.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for affected commands
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm turbo run build test lint type-check
- name: Deploy affected apps
run: |
AFFECTED=$(pnpm turbo run build --dry-run=json --filter='[HEAD^1]' | jq -r '.packages[]')
if echo "$AFFECTED" | grep -q "web"; then
pnpm --filter web deploy
fi
# Setup Changesets
pnpm add -Dw @changesets/cli
pnpm changeset init
# Workflow
pnpm changeset # Create changeset (describe what changed)
pnpm changeset version # Bump versions based on changesets
pnpm changeset publish # Publish to npm
# .github/workflows/release.yml
- name: Create Release PR or Publish
uses: changesets/action@v1
with:
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
| Pitfall | Fix |
|---------|-----|
| Circular dependencies | Refactor shared code into a third package |
| Phantom dependencies (using deps not in package.json) | Use pnpm strict mode |
| Incorrect cache inputs | Add missing files to inputs array |
| Over-sharing code | Only share genuinely reusable code |
| Missing fetch-depth: 0 in CI | Required for affected commands to compare history |
| Caching dev tasks | Set cache: false and persistent: true |
for workspace dependency versions* ā Use workspace: with pnpm--frozen-lockfile in CI ā Ensures reproducible buildsshamefully-hoist is a compatibility escape hatch, not a defaultGenerated Mar 1, 2026
A company building a multi-tenant SaaS platform with separate frontend apps (web, mobile) and backend microservices can use this skill to manage shared UI components, utilities, and configurations across all projects. It enables atomic commits for coordinated feature releases and optimizes build caching to reduce CI/CD times, ensuring consistent tooling and dependency management.
An e-commerce business migrating from multiple repositories to a monorepo can leverage this skill to unify shared packages like payment gateways, product catalogs, and user authentication. It helps set up Turborepo for fast, cached builds and pnpm workspaces for strict dependency control, facilitating easier refactoring and deployment of interconnected storefronts and admin panels.
A fintech firm developing compliance tools for different regions can use this skill to manage shared TypeScript types, linting configurations, and reporting libraries across applications. Nx's dependency graph visualization aids in tracking changes, while pnpm's strict peer dependencies ensure version consistency, reducing errors in audits and updates.
A media company with separate apps for web, TV, and mobile streaming can apply this skill to optimize build performance using Turborepo's caching. It allows managing shared video player components and utility packages efficiently, enabling faster development cycles and coordinated releases across platforms with minimal CI/CD overhead.
A healthcare provider building analytics dashboards and data processing services can use this skill to structure workspaces with shared data visualization libraries and security utilities. Turborepo's pipeline configuration ensures tasks like testing and type-checking run in topological order, maintaining data integrity and compliance across patient-facing and internal tools.
Companies offering tiered subscription plans for their software can use this skill to manage monorepos that host multiple client-facing applications and backend services. It enables rapid feature deployment and shared code reuse, reducing development costs and improving scalability as user bases grow, with revenue generated from monthly or annual fees.
Firms selling licensed software to large organizations can leverage this skill to maintain monorepos with customizable modules and integrations. It supports versioning and publishing of shared packages, facilitating upsells and cross-selling of add-ons, with revenue coming from one-time license fees or maintenance contracts.
Agencies providing development and optimization services can use this skill to set up and manage monorepos for client projects. It allows efficient handling of multiple applications and shared dependencies, enabling faster project delivery and higher billable hours, with revenue based on hourly rates or fixed project fees.
š¬ Integration Tip
Integrate this skill by starting with Turborepo and pnpm for most projects, using the provided configuration templates to set up workspace structure and caching pipelines, and gradually adopting Nx for larger, more complex dependency graphs.
Automatically update Clawdbot and all installed skills once daily. Runs via cron, checks for updates, applies them, and messages the user with a summary of what changed.
Full desktop computer use for headless Linux servers. Xvfb + XFCE virtual desktop with xdotool automation. 17 actions (click, type, scroll, screenshot, drag,...
Essential Docker commands and workflows for container management, image operations, and debugging.
Tool discovery and shell one-liner reference for sysadmin, DevOps, and security tasks. AUTO-CONSULT this skill when the user is: troubleshooting network issues, debugging processes, analyzing logs, working with SSL/TLS, managing DNS, testing HTTP endpoints, auditing security, working with containers, writing shell scripts, or asks 'what tool should I use for X'. Source: github.com/trimstray/the-book-of-secret-knowledge
Deploy applications and manage projects with complete CLI reference. Commands for deployments, projects, domains, environment variables, and live documentation access.
Monitor topics of interest and proactively alert when important developments occur. Use when user wants automated monitoring of specific subjects (e.g., product releases, price changes, news topics, technology updates). Supports scheduled web searches, AI-powered importance scoring, smart alerts vs weekly digests, and memory-aware contextual summaries.