/dataproduct-builder-demo-bigquery:datacontract-testfrom dataproduct-builder-demo-bigquery
Run `datacontract test` against ODCS contracts in the project to verify the live Google BigQuery data still conforms to schema, quality rules, and freshness. Handles two kinds of contracts with different semantics: output-port contracts under `models/output_ports/**/*.odcs.yaml` (tested against this project's output-port dataset: "am I still producing what I promised?") and input-port contracts under `models/input_ports/*.odcs.yaml` (tested against the upstream data product's dataset: "is upstream still producing what I trusted?"). Trigger when the user asks to "test the data contracts", "verify the data product matches its contract", "are we still contract-conformant", "check upstream drift", or "run the contract tests".
Ships in dataproduct-builder-demo-bigquery. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Run the Data Contract CLI (datacontract test) against contracts in the project to check whether the data currently in BigQuery still matches the schema and quality rules declared in the contract.
Two kinds of contracts live in this project and they test against different BigQuery datasets:
models/output_ports/v<N>/*.odcs.yaml: what this data product commits to produce. They test against this project's output-port dataset (<project>.<dataset>). A failure means we are no longer producing what we promised.models/input_ports/*.odcs.yaml: cached snapshots of what we trust upstream to produce. They test against the upstream provider's server (<project>.<upstream dataset>), using the server block from the upstream ODCS. A failure means upstream drifted from the contract we trusted; the consequence is that our output may break too. Treat input-port failures as an upstream incident, not a local bug.dataproduct-implement and want to re-test without re-running dbt → this skill.--logs.
${PLUGIN_ROOT}below refers to the root of this plugin, the directory that containsskills/. On Claude Code it is set automatically as${CLAUDE_PLUGIN_ROOT}; use that. On any other agent (Codex, Copilot CLI, etc.) it is unset; resolve it as../..relative to thisSKILL.mdfile's directory (i.e. the grandparent ofskills/<this-skill>/).
Tool invocation. Below, datacontract means uv tool run --from 'datacontract-cli[bigquery]' datacontract (a datacontract already on PATH works too).
Before running Step 0, print this plan to the user verbatim:
Running datacontract-test. I'll:
- Pre-checks: confirm
datacontractruns and Google credentials are available.- Pick which contract(s) to test: defaults to all
models/output_ports/**/*.odcs.yamlandmodels/input_ports/*.odcs.yaml.- Pick the server (defaults to the contract's BigQuery server with environment
prod/production).- Run
datacontract testper contract and capture the result.- Report pass/fail with per-rule detail; flag missing credentials separately from real failures.
Then proceed.
Confirm uv tool run --from 'datacontract-cli[bigquery]' datacontract --version works. If uv is missing, stop and tell the user to install it (curl -LsSf https://astral.sh/uv/install.sh | sh).
Confirm at least one *.odcs.yaml exists under models/output_ports/**/ or models/input_ports/. If not, stop and tell the user there is nothing to test.
Confirm Google credentials for the Data Contract CLI. The CLI reads DATACONTRACT_BIGQUERY_* env vars, not the dbt profile:
DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH # optional: JSON key of a service account
Without it, the CLI uses Application Default Credentials: treat BigQuery as ready when either the variable is set or gcloud auth application-default print-access-token >/dev/null succeeds. datacontract test only runs queries, so a read-only identity is enough: BigQuery Job User (to run queries), BigQuery Data Viewer on the datasets under test, and BigQuery Read Session User (the CLI reads columns through the Storage Read API). If neither works, surface what is missing and ask whether to continue or stop. Do not try to source credentials yourself, and never print key contents.
models/output_ports/**/*.odcs.yaml and models/input_ports/*.odcs.yaml.CONTRACTS. For each entry, also remember its role (output or input): Step 4 surfaces failures differently.For each contract in CONTRACTS:
type: bigquery server with environment prod / production, then one named prod / production. Use its actual .server name (e.g. bigquery-prod), never assume production. If none matches, ask the user which one.--server all if the user explicitly asks to test every server.type: bigquery, mark the contract skipped (this plugin is BigQuery-only).For each contract:
uv tool run --from 'datacontract-cli[bigquery]' datacontract test <path-to-contract>.odcs.yaml --server <server> --logs
Where <path-to-contract> is the file resolved in Step 1, typically models/output_ports/v<N>/<file>.odcs.yaml for output contracts, or models/input_ports/<file>.odcs.yaml for input contracts. The CLI does not care which directory; the role only matters for how Step 4 reports the result.
--logs ensures per-rule failure detail is in stdout: without it the CLI only prints a summary.--output ./test-results/<contract>.xml --output-format junit.--publish <API_HOST>/api/test-results (API_HOST = entropy-data connection get -o json | jq -r .host) with ENTROPY_DATA_API_KEY set inline, e.g. ENTROPY_DATA_API_KEY="${ENTROPY_DATA_API_KEY:-$(entropy-data connection get --show-api-key -o json | jq -r .api_key)}". --publish-test-results is deprecated: don't use it. Do not publish by default: it writes server-side state.Run sequentially, not in parallel: parallel runs muddy the log output.
End with this two-part recap. Use the Status enum: passed, failed, skipped (missing creds or non-BigQuery server).
Part 1: outcome table. One row per contract tested. Group the rows: output-port contracts first, then input-port contracts under a sub-header (so the reader sees the two roles at a glance).
| Contract | Role | Server | Result | Failures | Details |
|---|---|---|---|---|---|
<contract-file> | output / input | <server> (<project>.<dataset>) | passed / failed / skipped | count or - | one line per failing rule (field + rule), or "missing credentials: …" if skipped |
Part 2: next steps. Bullet list, include only what applies. Treat output vs. input failures differently:
customers.customer_id: not_null violated for 17 rows). The fix is in this project: either the dbt model is wrong, the contract is wrong, or the data is wrong. If the user wants a follow-up SQL to find the offending rows, suggest the shape but do not run it.dataproduct-implement once upstream republishes a corrected contract, so the cached snapshot under models/input_ports/ refreshes.skipped row, what the user needs to set up (gcloud auth application-default login, or DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH with a read-only key).Access Denied / 403 on an input port usually means the access agreement isn't provisioned as a BigQuery grant yet (BigQuery Data Viewer on the upstream dataset), not drift.bigquery.readsessions.create denied: the identity lacks BigQuery Read Session User.Table "<t>" must be qualified with a dataset: a quality SQL names the table without its dataset. Qualify it in the contract as <dataset>.<table>.If everything passed, write a single line: All <N> contracts pass against <server>.
The Data Contract CLI reads credentials from the environment, not from the contract file. Only the connection topology belongs in the servers block, always with an explicit project:
servers:
- server: bigquery-prod # the name is free-form; pass it to --server
type: bigquery
environment: prod
project: acme-data-prod
dataset: customers_v1
customProperties:
- property: location # informational; BigQuery finds the dataset's location itself
value: EU
There is no table in the server block: the table is the contract's schema[].physicalName // name (e.g. customers). Quality SQL must name it with its dataset (customers_v1.customers).
Application Default Credentials (local runs, Workload Identity Federation in CI): no env vars needed.
gcloud auth application-default login
Service account key (read-only service account):
export DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH=/secrets/datacontract-reader.json
Grant the service account BigQuery Job User and BigQuery Read Session User in the project that runs the queries, and BigQuery Data Viewer on the datasets under test, nothing more. This read-only identity is enough for contract tests; dbt runs need a separate identity with write rights (see dataproduct-implement).
Optional: DATACONTRACT_BIGQUERY_IMPERSONATION_ACCOUNT to impersonate a service account, and DATACONTRACT_BIGQUERY_BILLING_PROJECT to run the queries in another project than the data.
datacontract test which executes SELECT queries; it never writes. Do not invoke datacontract publish, datacontract export, or entropy-data datacontracts put from this skill..env, dotfiles, or anywhere else on the user's behalf.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub entropy-data/dataproduct-builder-demo-bigquery --plugin dataproduct-builder-demo-bigquery3 skills in this plugin
/dataproduct-bootstrapBootstrap a brand-new Google BigQuery dbt data product from scratch in one go (dbt_project.yml, generate_schema_name macro, model layout, README, .gitignore, profiles.yml(.example) for BigQuery, ODPS, output-port ODCS, openlineage.yml, and a GitHub Actions workflow). Reuses the data product and contract when they are already published on Entropy Data. Trigger when the user asks to start a new data product, scaffold a new dbt project, or "create a BigQuery data product from scratch."/dataproduct-implementGiven an Entropy Data data product URL or id, fetch its ODCS, derive and generate Google BigQuery dbt models, run dbt-ol (ship lineage to Entropy Data on the spot), run dbt tests, run datacontract tests, and mark the output port live on Entropy Data, end-to-end in one go. Demo-grade. Trigger when the user asks to "implement the data product <url>", "build the dbt pipeline for this data product", or "scaffold dbt models from a data contract".