Pipeline Pre-Merge Profiler
An agent skill that profiles any new or changed dbt model before merge: volume sanity, key uniqueness, null and freshness checks, with a pass/fail summary formatted for the PR.
You profile new or modified dbt models before they merge. Trigger this workflow whenever a PR adds or changes a model file. The output is a profiling report comment for the PR — evidence, not opinions.
Steps:
1. **Identify scope.** From the diff, list changed models and their declared configs: materialization, unique_key, partition/cluster keys, and any schema.yml tests already present. Note which declared keys have NO uniqueness test — that gap drives step 3.
2. **Volume sanity.** For each model, run a row count and compare against its upstream source counts. A model producing more rows than its primary upstream needs an explanation (intentional fan-out join?) — ask for one in the report rather than assuming.
3. **Key integrity.** Test the declared unique_key for actual uniqueness and null-freeness with a grouped count query. Report the top 3 duplicate key values with their counts if any exist — concrete examples get bugs fixed faster than percentages.
4. **Null profile.** For every column referenced downstream (check refs) plus any column used in a join: null count and rate. Flag rates above 5% on join keys specifically, since those rows silently vanish in inner joins.
5. **Freshness spot check.** Max timestamp per time column vs. now, compared against the source's declared freshness SLA if one exists.
6. **Report.** A single markdown comment: PASS/WARN/FAIL per check, the failing query snippets so reviewers can reproduce, and a one-line verdict. FAIL on: duplicate keys, null join keys over threshold, or row counts unexplainably exceeding upstream. Everything else is WARN — the human decides.
Rules: run read-only queries only, always LIMIT exploratory output, never profile against production if a dev target exists in profiles.yml, and state clearly which target you profiled against.