| name | turborepo |
| description | Turborepo high-performance monorepo build system. Use for monorepo setup, build optimization, task pipelines, caching strategies, or multi-package orchestration. |
| license | MIT |
| metadata | {"version":"2.0.0","last_verified":"2025-12-17T00:00:00.000Z","optimization_date":"2025-12-17T00:00:00.000Z","token_savings":"~54%","complexity":"7/10"} |
Turborepo Skill
Turborepo is a high-performance build system optimized for JavaScript and TypeScript monorepos, written in Rust. It provides intelligent caching, task orchestration, and remote execution capabilities to dramatically speed up development workflows.
Official Reference: https://turborepo.com/llms.txt
Quick Start (5 Minutes)
Create New Monorepo
bunx create-turbo@latest my-monorepo
cd my-monorepo
bun install
bun run build
bun run dev
Add to Existing Monorepo
bun add turbo --dev
bunx turbo run build
Templates: See templates/ directory for ready-to-use configurations.
Need Help?: See references/troubleshooting.md for common issues.
When to Use This Skill
Primary Use Cases
- Setting up monorepos with 2+ packages/apps
- Optimizing CI/CD build times (50-90% reduction typical)
- Migrating from Lerna or Nx to Turborepo
- Implementing remote caching for teams
- Building full-stack applications with shared code
Common Scenarios
- "Set up turborepo for Next.js + shared UI library"
- "Configure remote caching with Vercel"
- "Optimize monorepo builds for GitHub Actions"
- "Create Docker builds with turbo prune"
- "Migrate Lerna monorepo to Turborepo"
- "Build only changed packages in CI"
Keywords: monorepo, turborepo, build system, caching, task pipeline, workspace, incremental builds, remote cache, vercel, next.js monorepo, pnpm workspace, yarn workspace, npm workspace, bun workspace
Core Concepts
1. Monorepo Architecture
Turborepo organizes code into packages within a single repository:
- Root Package: Contains workspace configuration
- Internal Packages: Shared libraries, utilities, configs
- Applications: Frontend apps, backend services, etc.
- Workspaces: npm/yarn/pnpm/bun workspace configuration
Example Structure: See templates/monorepo-structure.txt
2. Task Pipeline
Tasks are organized in a dependency graph:
- Task Dependencies: Define execution order (build before test)
- Package Dependencies: Respect internal package relationships
- Parallel Execution: Run independent tasks simultaneously
- Topological Ordering: Execute tasks in correct dependency order
Configuration: Defined in turbo.json
3. Intelligent Caching
Turborepo caches task outputs based on inputs:
- Local Cache: Stores outputs on local machine (
.turbo/)
- Remote Cache: Shares cache across team/CI (Vercel or custom)
- Content-Based Hashing: Only re-run when inputs change
- Cache Restoration: Instant task completion from cache
Cache Benefits:
- 50-90% faster builds
- Reduced CI compute costs
- Consistent builds across environments
4. Task Outputs
Define what gets cached:
- Build artifacts (dist/, build/)
- Test results and coverage
- Generated files
- Type definitions
Installation
Prerequisites
node --version
Per-Project Installation (Recommended)
bun add turbo --dev
Configuration
Basic turbo.json
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": [".env", "tsconfig.json"],
"globalEnv": ["NODE_ENV"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"test": {
"dependsOn": ["build"]
},
"dev": {
"cache": false,
"persistent": true
}
}
}
For complete configuration guide: Load references/configuration-guide.md when configuring turbo.json, task pipelines, or framework-specific setups.
Available Templates:
templates/turbo-basic.json - Minimal configuration
templates/turbo-fullstack.json - Production-ready setup
templates/turbo-nextjs.json - Next.js specific
templates/turbo-vite.json - Vite specific
Essential Commands
turbo run
turbo run build
turbo run build test lint
turbo run build --filter=web
turbo run build --filter='./apps/*'
turbo run build --filter='...[origin/main]'
For complete command reference: Load references/configuration-guide.md when using advanced command options or filters.
Other Commands
turbo prune --scope=web --docker
turbo login
turbo link
turbo ls
Filtering
Quick Examples
turbo run build --filter=web
turbo run build --filter='[origin/main]'
turbo run build --filter='...web'
turbo run test --filter='ui...'
For complete filtering guide: Load references/advanced-filtering.md when implementing CI/CD filters, dependency-based builds, or advanced filter patterns.
Caching
Local Caching
Enabled by default, stores in ./node_modules/.cache/turbo
rm -rf ./node_modules/.cache/turbo
turbo run build --force
Remote Caching
Share cache across team and CI:
turbo login
turbo link
For complete caching guide: Load references/best-practices-patterns.md when optimizing cache configuration or implementing remote caching strategies.
CI/CD Integration
Quick Example (GitHub Actions)
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: bun install
- run: bunx turbo run build test
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
For complete CI/CD guide: Load references/ci-cd-guide.md when setting up CI/CD pipelines, optimizing builds, or configuring platform-specific workflows (GitHub Actions, GitLab, Docker, etc.).
Complete Templates:
templates/github-actions.yml - GitHub Actions
templates/gitlab-ci.yml - GitLab CI
templates/Dockerfile - Docker builds
Troubleshooting
Quick Fixes
Cache not working:
turbo run build --dry-run=json
turbo run build --force
rm -rf ./node_modules/.cache/turbo
Tasks running in wrong order:
- Check
dependsOn configuration
- Use
^task for dependency tasks
- Verify task names match package.json scripts
Dev server not starting:
{
"pipeline": {
"dev": {
"cache": false,
"persistent": true
}
}
}
For complete troubleshooting: Load references/troubleshooting.md when encountering cache issues, dependency problems, task execution issues, or CI/CD errors.
Migration
From Lerna
npm install turbo --save-dev
Command Mapping:
lerna run build → turbo run build
lerna run test --scope=pkg → turbo run test --filter=pkg
lerna run build --since main → turbo run build --filter='...[main]'
From Nx
npm install turbo --save-dev
Command Mapping:
nx run-many --target=build → turbo run build
nx run app:build → turbo run build --filter=app
nx affected --target=build → turbo run build --filter='...[origin/main]'
For complete migration guide: Load references/migration-guide.md when migrating from Lerna or Nx, including detailed steps, configuration conversion, and common pitfalls.
When to Load References
Load reference files when working on specific aspects of Turborepo:
configuration-guide.md
Load when:
- Task-based: Configuring turbo.json for the first time, setting up task pipelines with complex dependencies
- Framework-based: Configuring framework-specific builds (Next.js, Vite, Nuxt, Remix, Astro, SvelteKit)
- Command-based: Using advanced command options (prune, gen, link with custom configs)
- Problem-based: Need detailed examples of pipeline configuration, environment variable setup
best-practices-patterns.md
Load when:
- Project setup: Structuring a new monorepo, organizing packages and apps
- Optimization: Optimizing task dependencies, cache configuration, environment variable usage
- Architecture: Implementing full-stack applications, shared component libraries, microfrontends, multi-platform setups
- Team setup: Implementing remote caching strategies, organizing scripts consistently
advanced-filtering.md
Load when:
- CI/CD optimization: Implementing git-based filters to build only changed packages
- Selective builds: Building specific apps with dependencies, testing only affected packages
- Complex filters: Using dependency operators, exclude patterns, combined filters
- Performance: Need CI/CD optimization patterns, filter benchmarks, best practices
ci-cd-guide.md
Load when:
- Platform setup: Configuring GitHub Actions, GitLab CI, CircleCI, Buildkite, Travis CI, Vercel
- Docker: Creating Docker builds with turbo prune, multi-stage builds
- Remote cache: Setting up Vercel remote cache or custom cache servers
- Optimization: Implementing optimization strategies, environment variable management, deployment strategies
- Troubleshooting: Debugging CI/CD cache issues, out-of-memory problems
migration-guide.md
Load when:
- Migration: Migrating from Lerna or Nx to Turborepo
- Conversion: Converting lerna.json or nx.json to turbo.json
- Coexistence: Running Turborepo alongside Lerna or Nx temporarily
- Pitfalls: Understanding common migration pitfalls, rollback strategies, success metrics
troubleshooting.md
Load when:
- Cache issues: Tasks not using cache, cache too large, remote cache not working
- Dependency issues: Internal packages not found, version mismatches
- Task execution: Tasks running in wrong order, dev servers not starting, tasks skipping unexpectedly
- Performance: Builds taking too long, out of memory in CI
- CI/CD issues: Cache not persisting, environment variable problems
- Docker: Docker builds failing, multi-stage build issues
Resources
Templates & Scripts
- Templates: All configs in
templates/ directory
- Scripts: Setup automation in
scripts/ directory
- References: Detailed guides in
references/ directory
Official Documentation
Detailed Guides (6 references)
references/configuration-guide.md - Complete configuration, commands, framework setups
references/best-practices-patterns.md - Best practices, architectural patterns
references/advanced-filtering.md - Complete filtering guide
references/ci-cd-guide.md - CI/CD platform integration
references/migration-guide.md - Migration from Lerna/Nx
references/troubleshooting.md - Complete troubleshooting guide
Implementation Checklist
When setting up Turborepo:
Last Updated: 2025-12-17
Skill Version: 2.0.0
Turborepo Version: 2.6.1+
Official LLM Docs: https://turborepo.com/llms.txt