bigquery-sql
BigQuery-specific SQL patterns: UNNEST for array expansion, STRUCT, ARRAY_AGG,…
Load when task involves adding, writing, or fixing dbt unit tests. Covers unit_tests YAML format, given/expect blocks, edge-case coverage, and the difference between unit tests and schema tests.
$ npx -y skills add signalpilot-labs/signalpilot --skill dbt-testing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/dbt-testingContext preview
The summary Claude sees to decide when to auto-load this skill.
Load when task involves adding, writing, or fixing dbt unit tests. Covers unit_tests YAML format, given/expect blocks, edge-case coverage, and the difference between unit tests and schema tests.
name: dbt-testing description: "Load when task involves adding, writing, or fixing dbt unit tests. Covers unit_tests YAML format, given/expect blocks, edge-case coverage, and the difference between unit tests and schema tests." disable-model-invocation: false allowed-tools: Bash(dbt *)
Schema tests (`unique`, `not_null`, `accepted_range`) check constraints on output data. Unit tests check computation logic with mock inputs and expected outputs.
When a task says "add tests," determine which type:
If the model already has schema tests and the task says "add tests," it means unit tests.
Do NOT add schema tests when the task asks to verify logic - schema tests cannot detect formula bugs like reversed signs, wrong denominators, or incorrect window sizes.
Unit tests live in a `.yml` file next to the model. Top-level key is `unit_tests:`, NOT inside `models:`.
unit_tests:
- name: test_order_total_basic
model: my_orders
given:
- input: ref('stg_orders')
rows:
- {order_id: 1, quantity: 3, unit_price: 10.00}
- {order_id: 2, quantity: 1, unit_price: 25.00}
- input: ref('stg_discounts')
rows:
- {order_id: 1, discount_amount: 5.00}
expect:
rows:
- {order_id: 1, total: 25.00}
- {order_id: 2, total: 25.00}Rules:
Before writing any unit test, read the model's SQL file. Identify: 1. All `ref()` calls - these are the inputs for `given` blocks. 2. All output column names - these are the keys for `expect` rows. 3. The transformation logic - this determines what edge cases to test.
Do NOT guess input or output column names. Read the SQL.
When the task says "add tests," add tests. Do NOT rewrite, refactor, or rename columns in the model SQL. Unit tests verify existing logic - they do not change it.
If a unit test reveals a bug in the model (e.g., integer division truncation), document the finding. Do NOT delete the failing test to make the suite green. A failing test that catches a real bug is correct.
Write tests that isolate specific behaviors. Each test should catch exactly one class of bug.
Required edge cases for numeric/aggregation models:
For rolling window models, add:
For ratio/percentage models, add:
Name tests descriptively: `test_<model>_<behavior>` (e.g., `test_daily_nps_all_negative_reviews`).
# Run unit tests for a specific model dbt test --select <model_name>,test_type:unit # Run all unit tests in the project dbt test --select test_type:unit
After writing unit tests, run them. If tests fail against the current model, that means the tests caught a bug. Report the finding. Do NOT delete the test.
Put unit test YAML in the same directory as the model's existing `.yml` file. If the model's schema tests are in `models/marts/agg.yml`, add unit tests to `models/marts/agg.yml` (or a new file like `models/marts/unit_tests.yml`). Either location works - dbt finds unit tests by scanning all `.yml` files.
Repo: signalpilot-labs/signalpilot
BigQuery-specific SQL patterns: UNNEST for array expansion, STRUCT, ARRAY_AGG,…
Load when dbt run or dbt parse fails. Covers YML duplicate patches, ref errors, passthrough…
Populate the knowledge base from dbt project research. Proposes entries across all 6…
Load when task involves dbt snapshots, SCD Type 2, or tracking data changes over time. Covers…
Load when task involves dbt model versioning, creating v2 of a model, or backward-compatible…
Load at Step 1 before exploring the project. Covers output shape inference, incremental model…