For Nx, determine the base SHA by finding the last successful CI commit on the main branch; many CI providers expose this via an environment variable, or use the nrwl/nx-set-shas action on GitHub Actions to set NX_BASE automatically
Run affected tasks with: npx nx affected -t build test lint --base=$NX_BASE --head=$NX_HEAD — Nx computes the project graph, finds projects touched by changed files, and runs only those tasks
For Turborepo, use turbo run build test --filter=...[origin/main] — the [...BASE] filter syntax tells Turbo to include only packages with changes relative to the specified Git ref
Ensure the CI job fetches full Git history (or at least the range from base to head): use actions/checkout with fetch-depth: 0 or fetch the specific range needed for the diff to work correctly
Cache task outputs remotely (Nx Cloud or Turborepo remote cache) so that even 'affected' tasks that were previously computed on another branch are returned from cache rather than re-executed
For deployment steps, gate them on the affected output: in Nx use nx show projects --affected to get a list, then conditionally run deployment scripts only for changed services
Known gotchas
Using fetch-depth: 1 (the default shallow clone) means the base SHA may not exist in local history, causing affected detection to fall back to running all tasks — always use a deeper fetch or fetch-unshallow in CI
Affected detection is based on file-to-project mappings in the project graph; files outside any project boundary (root config files) may mark all projects as affected — configure implicitDependencies in nx.json or root package settings to limit the blast radius
For Turborepo, the --filter flag with a Git range only works if the packages are properly declared in the workspace; unlisted packages are invisible to Turbo's change detection
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp