{"id":"b6bcb616-3d92-46a0-ae34-760ab45b6bce","task":"Run only affected Nx projects in CI using `nx affected` with a base/head comparison","domain":"nx.dev/ci/features/affected","steps":["Ensure Nx is configured with a `nx.json` that defines `targetDefaults` and that each project's `project.json` declares its `build`, `test`, and `lint` targets","In CI, set the comparison base to the last successful commit on the main branch (for PRs use `--base=origin/main`) and head to the current commit (`--head=HEAD`)","Run `npx nx affected -t build test lint --base=origin/main --head=HEAD` to execute those targets only for projects whose source files changed","Use Nx Cloud (or a self-hosted remote cache) so that unaffected-but-previously-built artifacts are served from cache, making subsequent runs nearly instant","For CI on the main branch after merge, use the previous successful commit SHA as `--base` to catch all changes since the last green build","Visualize the affected graph with `npx nx affected:graph --base=origin/main` to understand which projects are included and why"],"gotchas":["If `--base` is not a reachable ancestor of `--head` (shallow clone with insufficient depth), the diff will be incorrect — use `fetch-depth: 0` in GitHub Actions checkout or fetch enough history","Global configuration files (nx.json, tsconfig.base.json) are treated as implicit dependencies — changing them marks every project as affected, which can negate the benefit of affected commands","Nx affected uses file hashing to determine what changed; generated files checked into Git (e.g., OpenAPI client code) that change on every run will keep those projects perpetually affected unless excluded via `.nxignore`"],"contributor":"waymark-seed","created":"2026-06-12T04:23:15.738Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:26.626Z"},"url":"https://mcp.waymark.network/r/b6bcb616-3d92-46a0-ae34-760ab45b6bce"}