skillfed

turborepo

turborepo is a high-performance build system designed for monorepos that streamlines task orchestration across multiple packages. Configure task dependencies, output handling, and intelligent caching directly in turbo.json to accelerate your build pipeline and reduce redundant work.

turborepo organizes monorepos into a root directory containing a turbo.json configuration file, with subdirectories for packages (reusable libraries) and apps (consumer applications). Each package and app has its own package.json with scripts. Start by creating your workspace root, adding a turbo.json at the top level to define task pipelines, then structure your directories as apps/ and packages/ folders. turborepo automatically discovers and links dependencies between these workspaces, enabling efficient task orchestration across your entire monorepo.

AI-generated summary based on this skill's SKILL.md

2,603 420 MIT updated by module-federation

Install

module-federation/core/turborepo · repository language: JavaScript

CLI (skillfed)coming soon
git clone https://github.com/module-federation/core
cp -r core/.codex/skills/turborepo ~/.claude/skills/turborepo

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I set up turborepo monorepo structure with packages and apps?

turborepo organizes monorepos into a root directory containing a turbo.json configuration file, with subdirectories for packages (reusable libraries) and apps (consumer applications). Each package and app has its own package.json with scripts. Start by creating your workspace root, adding a turbo.json at the top level to define task pipelines, then structure your directories as apps/ and packages/ folders. turborepo automatically discovers and links dependencies between these workspaces, enabling efficient task orchestration across your entire monorepo.

What is the turborepo task configuration and dependencies setup in turbo.json?

turborepo's turbo.json file defines your build pipeline by specifying tasks, their dependencies, and output caching rules. In the pipeline object, you declare tasks like build, test, or lint, then configure which tasks must run first using the dependsOn field. For example, a build task might depend on a prebuild task running first. You also define outputs—files and directories turborepo should cache—and set environment variable hashing to invalidate cache when specific variables change. This configuration ensures turborepo executes tasks in the correct order and caches results intelligently.

Why is turborepo caching not working and how do I debug cache misses?

turborepo cache misses occur when environment variables affecting your build aren't tracked, when output paths in turbo.json don't match actual build outputs, or when source files change unexpectedly. Debug by checking that your turbo.json outputs field correctly lists all generated files and directories. Configure globalDependencies to hash files like .env or build config files that affect output. Use the globalEnv field to specify environment variables turborepo should include in cache keys. Run turbo with --verbose to see cache hit/miss reasons, and verify that your scripts produce outputs in the exact paths you've declared.

How do I use the turborepo --affected flag for changed packages in CI/CD workflows?

turborepo's --affected flag runs tasks only on packages that have changed since a baseline commit, dramatically reducing CI/CD time. Use turbo run build --affected to build only modified packages and their dependents. In GitHub Actions or other CI systems, set the baseline using the --since flag to compare against a specific commit or branch. This approach filters packages by name and change detection automatically, so you avoid rebuilding unchanged code. Configure your CI/CD to pass the appropriate baseline (often main or master branch) so turborepo accurately identifies which packages need processing.

What are turborepo best practices for package.json scripts and enforcing package boundaries?

turborepo best practices include defining clear, consistent scripts in each package.json (build, test, lint, dev) that turbo.json references in its pipeline. Avoid prebuild script anti-patterns—instead, declare explicit task dependencies in turbo.json using dependsOn so turborepo orchestrates execution correctly. Enforce architectural boundaries by using turborepo's package isolation rules and dependency constraints to prevent unwanted cross-package imports. Structure your monorepo so apps depend on packages but packages don't depend on apps, maintaining clear separation of concerns and enabling parallel task execution across your workspace.

How do I configure turborepo for parallel task execution and watch mode development?

turborepo executes tasks in parallel by default when there are no task dependencies blocking them, maximizing build speed. For development, use turbo run dev --parallel to run watch-mode scripts across all packages simultaneously, enabling hot-reload workflows. In turbo.json, tasks without dependsOn constraints run concurrently. For CI/CD, turborepo's parallel execution combined with caching and the --affected flag ensures fast, efficient builds. Configure your pipeline so independent tasks have no dependencies, allowing turborepo to distribute work across available CPU cores and complete your build system tasks as quickly as possible.

SKILL.md

rendered from the published skill — quoted content, verbatim

Turborepo Skill

Build system for JavaScript/TypeScript monorepos. Turborepo caches task outputs and runs tasks in parallel based on dependency graph.

IMPORTANT: Package Tasks, Not Root Tasks

DO NOT create Root Tasks. ALWAYS create package tasks.

When creating tasks/scripts/pipelines, you MUST:

  1. Add the script to each relevant package's package.json
  2. Register the task in root turbo.json
  3. Root package.json only delegates via turbo run <task>

DO NOT put task logic in root package.json. This defeats Turborepo's parallelization.

```json // DO THIS: Scripts in each package // apps/web/package.json { "scripts":

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 15 files
.codex/skills/turborepo/SKILL.md
.codex/skills/turborepo/command/turborepo.md
.codex/skills/turborepo/references/best-practices/RULE.md
.codex/skills/turborepo/references/best-practices/dependencies.md
.codex/skills/turborepo/references/best-practices/packages.md
.codex/skills/turborepo/references/best-practices/structure.md
.codex/skills/turborepo/references/boundaries/RULE.md
.codex/skills/turborepo/references/caching/RULE.md
.codex/skills/turborepo/references/caching/gotchas.md
.codex/skills/turborepo/references/caching/remote-cache.md
.codex/skills/turborepo/references/ci/RULE.md
.codex/skills/turborepo/references/ci/github-actions.md
.codex/skills/turborepo/references/ci/patterns.md
.codex/skills/turborepo/references/ci/vercel.md
.codex/skills/turborepo/references/cli/RULE.md

Related skills

Tags

monorepo-orchestration build-caching-strategy dependency-graph-management workspace-task-pipelines ci-optimization-patterns package-isolation-rules incremental-builds parallel-execution-control environment-hashing repository-structure-patterns