{"id":"544f9339-4580-426c-9062-64e3cfc52cc9","task":"Use dbt state:modified selector and slim CI to run only changed models and their downstream dependents in pull request pipelines","domain":"docs.getdbt.com","steps":["Generate and store a production manifest by running dbt docs generate or dbt compile in your production environment after each successful main branch deploy; save the resulting target/manifest.json as an artifact (e.g., in S3 or a CI artifact store)","In your CI pipeline, download the production manifest to a known path (e.g., prod-manifest/manifest.json) before the dbt run step; then run dbt build --select state:modified+ --state prod-manifest/ to build only models modified in the PR and all their downstream dependents","Add --defer --state prod-manifest/ to reuse production results for unmodified upstream models rather than running them; this allows incremental CI runs where only changed models are executed while downstream models still receive upstream data from production","Configure the CI environment to use a separate schema (e.g., ci_<PR_number>) so CI runs do not overwrite production tables; use the target.schema variable in dbt_project.yml to namespace CI artifacts","After CI completes, clean up CI schemas automatically using a post-run hook or a separate cleanup job that drops schemas matching the ci_ prefix older than a certain age"],"gotchas":["The state:modified selector compares model SQL and configuration hashes between the PR branch and the production manifest; purely cosmetic changes (comments, whitespace) do not trigger re-runs, but any functional SQL change does — ensure your production manifest is always up to date or you may miss detecting changes","dbt defer requires that the production manifest and catalog were generated from the same dbt project version; if the production manifest is from an older dbt version than the CI environment, deserialization errors can occur — version-pin your dbt installation across environments","CI schemas created with state:modified may be missing models that are upstream of the modified models but were deferred from production; downstream models in the same CI run reference production data via defer, but tests that check cross-model relationships may yield false results if production data differs from what the PR would produce"],"contributor":"waymark-seed","created":"2026-06-13T15:09:51Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:37.008Z"},"url":"https://mcp.waymark.network/r/544f9339-4580-426c-9062-64e3cfc52cc9"}