Common Filter Patterns
Practical examples for typical monorepo scenarios.
Single Package
Run task in one package:
turbo run build --filter=web
turbo run test --filter=@acme/api
Package with Dependencies
Build a package and everything it depends on:
turbo run build --filter=web...
Useful for: ensuring all dependencies are built before the target.
Package Dependents
Run in all packages that depend on a library:
turbo run test --filter=...ui
Useful for: testing consumers after changing a shared package.
Dependents Only (Exclude Target)
Test packages that depend on ui, but not ui itself:
turbo run test --filter=...^ui
Changed Packages
Run only in packages with file changes since last commit:
turbo run lint --filter=[HEAD^1]
Since a specific branch point:
turbo run lint --filter=[main...HEAD]
Changed + Dependents (PR Builds)
Run in changed packages AND packages that depend on them:
turbo run build test --filter=...[HEAD^1]
Or use the shortcut:
turbo run build test --affected
Directory-Based
Run in all apps:
turbo run build --filter=./apps/*
Run in specific directories:
turbo run build --filter=./apps/web --filter=./apps/api
Scope-Based
Run in all packages under a scope:
turbo run build --filter=@acme/*
Exclusions
Run in all apps except admin:
turbo run build --filter=./apps/* --filter=!admin
Run everywhere except specific packages:
turbo run lint --filter=!legacy-app --filter=!deprecated-pkg
Complex Combinations
Separate --filter flags are unioned, not intersected — to intersect a directory with a git range, wrap the directory in {} inside a single filter.
Apps that changed since the last commit:
turbo run build --filter={./apps/*}[HEAD^1]
All packages except docs, but only if changed:
turbo run build --filter=[main...HEAD] --filter=!docs
Debugging Filters
Use --dry to see what would run without executing:
turbo run build --filter=web... --dry
Use --dry=json for machine-readable output:
turbo run build --filter=...[HEAD^1] --dry=json
CI/CD Patterns
PR validation (most common):
turbo run build test lint --affected
Deploy only changed apps:
turbo run deploy --filter={./apps/*}[main...HEAD]
Full rebuild of specific app and deps:
turbo run build --filter=production-app...