Subchapter 9.23
references/filtering/RULE.mdMarkdown4 KBView on GitHub
The primary way to run only changed packages is --affected:
# Run build/test/lint only in changed packages and their dependents
turbo run build test lint --affectedThis compares your current branch to the default branch (usually main or master) and runs tasks in:
If you change @repo/ui, packages that import @repo/ui (like apps/web) need to re-run their tasks to verify they still work with the changes.
# Use a different base branch
turbo run build --affected --affected-base=origin/develop
# Use a different head (current state)
turbo run build --affected --affected-head=HEAD~5# .github/workflows/ci.yml
- run: turbo run build test lint --affectedThis is the most efficient CI setup - only run tasks for what actually changed.
For more control, use --filter with git comparison syntax:
# Changed packages + dependents (same as --affected)
turbo run build --filter=...[origin/main]
# Only changed packages (no dependents)
turbo run build --filter=[origin/main]
# Changed packages + dependencies (packages they import)
turbo run build --filter=[origin/main]...
# Changed since last commit
turbo run build --filter=...[HEAD^1]
# Changed between two commits
turbo run build --filter=[a1b2c3d...e4f5g6h]| Syntax | Meaning |
|---|---|
[ref] | Packages changed since ref |
...[ref] | Changed packages + their dependents |
[ref]... | Changed packages + their dependencies |
...[ref]... | Dependencies, changed, AND dependents |
Filters select which packages to include in a turbo run invocation.
turbo run build --filter=<package-name>
turbo run build -F <package-name>Multiple filters combine as a union (packages matching ANY filter run).
--filter=web # exact match
--filter=@acme/* # scope glob
--filter=*-app # name glob--filter=./apps/* # all packages in apps/
--filter=./packages/ui # specific directory| Syntax | Meaning |
|---|---|
pkg... | Package AND all its dependencies |
...pkg | Package AND all its dependents |
...pkg... | Dependencies, package, AND dependents |
^pkg... | Only dependencies (exclude pkg itself) |
...^pkg | Only dependents (exclude pkg itself) |
Exclude packages with !:
--filter=!web # exclude web
--filter=./apps/* --filter=!admin # apps except adminRun a specific task in a specific package:
turbo run web#build # only web's build task
turbo run web#build api#test # web build + api testMultiple --filter flags create a union:
turbo run build --filter=web --filter=api # runs in both| Goal | Command |
|---|---|
| Changed + dependents (recommended) | turbo run build --affected |
| Custom base branch | turbo run build --affected --affected-base=origin/develop |
| Only changed (no dependents) | turbo run build --filter=[origin/main] |
| Changed + dependencies | turbo run build --filter=[origin/main]... |
| Since last commit | turbo run build --filter=...[HEAD^1] |