Skill

Optimize Turborepo Build Caching

Turborepo build caching - pipeline configuration, remote caching, filtering/scoping, and cache debugging.

Works with vercelgithub

91
Spark score
out of 100
Updated 27 days ago
Version 14.2.0

Add to Favorites

Why it matters

Leverage Turborepo's caching capabilities to significantly speed up your monorepo build processes and CI/CD pipelines. This skill provides patterns and configurations for efficient caching, reducing build times and improving developer productivity.

Outcomes

What it gets done

01

Configure Turborepo caching strategies

02

Implement remote caching with Vercel or self-hosted solutions

03

Optimize CI/CD pipelines for faster builds

04

Debug and resolve cache misses

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-turborepo-caching | bash

Overview

Turborepo Caching

Covers Turborepo build caching: pipeline configuration, Vercel and self-hosted remote caching, package/dependency filtering syntax, and cache debugging commands. Use when configuring Turborepo pipelines, setting up remote caching, scoping builds by package, or debugging cache misses.

What it does

Turborepo Caching covers monorepo build caching architecture: a standard workspace layout (apps/ and packages/ directories each with their own package.json, plus a root turbo.json and package.json) and pipeline concepts (dependsOn for task ordering, cache/outputs/inputs for what gets cached and what invalidates it, and persistent for long-running tasks like dev servers). Seven templates cover the full workflow: a base turbo.json configuration, a package-specific pipeline, remote caching with Vercel (login, link the project, run with the remote cache, and CI environment variables in a GitHub Actions workflow), a self-hosted remote cache alternative, filtering and scoping builds by package, dependency, or git diff:

### Build specific package
turbo build --filter=@myorg/web

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

### Build package and its dependents
turbo build --filter=...@myorg/ui

### Build changed packages since main
turbo build --filter='...[origin/main]'

### Build packages in directory
turbo build --filter='./apps/*'

### Combine filters
turbo build --filter=@myorg/web --filter=@myorg/docs

### Exclude package
turbo build --filter='!@myorg/docs'

### Include dependencies of changed
turbo build --filter='...[HEAD^1]...'

advanced pipeline configuration (dependsOn on upstream builds, explicit outputs, and inputs using $TURBO_DEFAULT$ with exclusion globs for markdown and test files), and root package.json setup. A dedicated debugging-cache section covers dry runs to preview what would execute, verbose output with cache hashes, task graph visualization, forcing a no-cache run, checking cache status, and debugging a specific task.

When to use - and when NOT to

Use this skill when configuring Turborepo build caching, setting up remote caching (Vercel-hosted or self-hosted), filtering builds to specific packages or changed packages, or debugging cache misses.

Inputs and outputs

Given a Turborepo caching task, the skill outputs the matching turbo.json configuration, CI workflow snippet, or turbo CLI filter command, matched to the specific need - initial setup, remote cache configuration, scoped builds, or cache debugging.

Integrations

Built on Turborepo's pipeline model and its Vercel-hosted remote cache, with a self-hosted remote cache documented as an alternative. Five stated best practices: define explicit inputs to avoid unwanted cache invalidation, use the workspace:* protocol for internal package references, enable remote caching to share cache across CI and local machines, filter builds in CI to only affected packages, and cache build outputs rather than source files - alongside four don'ts: don't cache dev servers (use persistent: true instead), don't put secrets in cached env vars (use runtime env vars), don't ignore dependsOn (causes race conditions), and don't over-filter (may miss real dependencies).

Who it's for

Monorepo maintainers configuring or debugging Turborepo build caching who want working turbo.json templates, CI remote-cache setup, and precise filter syntax for scoping builds, rather than guessing at pipeline configuration or over-invalidating the cache.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.