npx skills add ...
npx skills add openai/plugins --skill turborepo
Turborepo expert guidance. Use when setting up or optimizing monorepo builds, configuring task caching, remote caching, parallel execution, or the --affected flag for incremental CI.
npx skills add openai/plugins --skill turborepo
You are an expert in Turborepo v2.8 — "the build system for agentic coding" — a high-performance build system for JavaScript/TypeScript monorepos, built by Vercel with a Rust-powered core.
--affected flag runs only changed packages + dependentsturbo devtools (2.8+)turbo.json from any package, not just root (2.7+)turbo docs returns markdown responses optimized for AI agents (2.8+)The turbo.json file defines your task dependency graph. Here are comprehensive examples:
dependsOn: ["^build"] — Run build in dependencies first (^ = topological)dependsOn: ["build"] — Run build in the same package first (no ^)outputs — Files to cache (build artifacts)inputs — Files that affect the task hash (default: all non-gitignored files)env — Environment variables that affect the task hashcache: false — Skip caching (for dev servers, codegen)persistent: true — Long-running tasks (dev servers)globalDependencies — Files that invalidate all task caches when changedglobalEnv — Env vars that invalidate all task caches when changedRun tasks in specific packages or subsets of your monorepo:
| Pattern | Meaning |
|---|---|
web | Only the web package |
web... | web and all its dependencies |
...web | web and all its dependents |
...web... | web, its dependencies, and its dependents |
./apps/* | All packages in the apps/ directory |
[main] | Packages changed since main branch |
{./apps/web}[main] | web only if it changed since main |
!docs | Exclude the docs package |
Run tasks in watch mode for development — re-executes when source files change:
Watch mode respects the task graph — if test depends on build, changing a source file re-runs build first, then test.
persistent: true in turbo.json: The task itself is long-running (e.g., next dev). Turbo starts it and keeps it alive.turbo watch: Turbo re-invokes the task on file changes. Use for tasks that run and exit (e.g., vitest run, tsc --noEmit).Enforce architectural constraints across your monorepo with boundaries in turbo.json:
This enforces:
turbo boundariesInspect your task dependency graph:
The dry run output shows:
Note:
turbo docsoutput is optimized for AI coding agents — markdown format preserves context windows. The docs site also includes sample prompts for common tasks you can copy directly into your agent.
Package configs can now extend from any workspace package, not just the root:
The most important optimization for CI pipelines:
This performs intelligent graph traversal:
Turborepo is the recommended orchestration layer for Vercel's Microfrontends architecture — composing multiple independently-deployed apps behind a single URL.
Each micro-app is a separate Vercel project with its own build and deploy lifecycle:
Use Turborepo's dependency graph to share code without coupling deploys:
Shared packages (ui, auth, config) are built first via ^build, then each micro-app builds against the latest shared code. Remote caching ensures shared package builds are never repeated across micro-app deploys.
Next.js multi-zones let each micro-app own a URL path prefix while sharing a single domain:
Combine with Turborepo boundary rules to enforce architectural isolation:
| Scenario | Recommended? |
|---|---|
| Multiple teams owning independent features | Yes — independent deploys + shared packages |
| Single team, single app | No — standard Next.js is simpler |
| Shared component library across apps | Yes — packages/ui with boundary rules |
| Gradual migration from monolith | Yes — extract features into micro-apps incrementally |
| Need version-skew protection | Yes — isolated builds per micro-app |
Turborepo 2.6+ has stable Bun support with granular lockfile analysis:
bun.lock (text format). If only bun.lockb (binary) is found, it errors with a prompt to generate a text lockfile. Generate with bun install --save-text-lockfile.bun.lock to detect which specific packages changed and only invalidates caches for affected tasks — not the entire monorepo.turbo prune works with Bun workspaces, generating a minimal lockfile for single-app deploys.bun.lock changes don't touch a project's dependencies. Combined with --affected, only changed packages and their dependents rebuild.Known issue:
turbo prunewith Bun 1.3+ may produce lockfiles with formatting differences that breakbun i --frozen-lockfile. Track fixes in turborepo#11007.
Vercel auto-detects Turborepo and optimizes builds. Each app in apps/ can be a separate Vercel project with automatic dependency detection.
| Scenario | Use Turborepo? |
|---|---|
| Single Next.js app | No — Turbopack handles bundling |
| Multiple apps sharing code | Yes — orchestrate builds |
| Shared component library | Yes — manage dependencies |
| CI taking too long | Yes — caching + affected |
| Team sharing build artifacts | Yes — remote caching |
| Enforcing architecture boundaries | Yes — boundary rules |
| Complex multi-step CI pipelines | Yes — task graph + matrix |