Turbo Pipeline
Configure Turborepo tasks, caching, dependencies, and environment rules for enterprise delivery.
Key takeaways
- The Turbo pipeline is a monorepo's execution contract, deciding which tasks run, in what order, what is cached, and which env vars affect correctness.
- Task layers carry different cache expectations: lint and typecheck are cacheable, test is cacheable when deterministic, build needs explicit outputs, and dev and deploy are not cacheable.
- Declare task dependencies (not just names), list build outputs explicitly, and treat env vars as part of the cache key when they affect output.
- Use
--affectedfor PR feedback while keeping full verification for release gates, and keep the default cache directory to preserve Git worktree cache sharing. - When CI fails, ask whether the cause is code, dependency order, cache config, environment leakage, or a nondeterministic test; treat repeated flakiness as a platform problem.
The pipeline is the execution contract of a monorepo. It decides which tasks run, in what order, which outputs are cached, and which environment variables affect correctness.
Task Layers
| Task | Purpose | Cache expectation |
|---|---|---|
lint | Static quality and style checks | Cacheable |
typecheck | Type contract validation | Cacheable |
test | Unit and integration tests | Cacheable when deterministic |
build | Production artifact creation | Cacheable with explicit outputs |
dev | Local development server | Not cacheable |
deploy | External side effect | Not cacheable |
Pipeline Rules
- Define dependencies between tasks, not only task names.
- List build outputs explicitly so cache restore is reliable.
- Treat environment variables as part of the cache key when they affect output.
- Keep long-running development tasks outside cached CI paths.
- Use
--affectedfor PR feedback and keep full verification for release gates. - Keep the default cache directory unless you intentionally want to disable Git worktree cache sharing.
- Review Turborepo 2.9 deprecations before adopting future 3.0 behavior.
Common Pattern
| Need | Pattern |
|---|---|
| Build packages before apps | App build depends on upstream package build |
| Validate contracts early | Run typecheck before expensive tests |
| Avoid stale artifacts | Declare outputs and clean rules |
| Protect production | Add release-only gates after normal CI |
| Agent worktrees | Let Turborepo share local cache across linked Git worktrees |
Failure Review
When a pipeline fails, ask whether the problem is code, dependency order, cache configuration, environment leakage, or a nondeterministic test. Treat repeated flaky CI as a product problem for the platform team.