data-contract-extractor
Overview
This skill formalizes the prose of a data PRD into a data contract -
the producer/consumer agreement on schema, freshness, volume, semantic
invariants, and ownership - that the QA test suite can mechanically
assert against, typically via the sibling skills in this plugin
(dbt-testing, great-expectations, soda-checks). "Data contract" is
practitioner-emergent terminology (Andrew Jones / Chad Sanderson), not
ISTQB-canonical; this skill cites industry-engineering sources.
When to use
- A new data product (dbt model, table, file feed) is being scoped
and the team wants assertions before shipping.
- An existing data product has implicit assumptions consumers rely
on; the team is documenting them ahead of a refactor.
- A PRD or design doc references a dataset and the team needs the
schema / SLA pulled out into structured form.
- A data-quality engineer needs the contract as input to suite generation.
What goes in a data contract
The five required sections, in order of authoring priority:
1. Schema
For each column:
| Field |
Required |
Notes |
| Name |
yes |
snake_case; matches the warehouse table. |
| Type |
yes |
Warehouse-native type (VARCHAR, BIGINT, TIMESTAMP, etc.). |
| Nullable |
yes |
true / false - the test suite's not_null decision. |
| PK |
yes |
true for primary-key column(s). |
| Unique |
yes |
true for candidate keys (separate from PK). |
| FK |
optional |
If foreign key, the <table>.<column> reference. |
| PII |
required |
Tag values: none, direct (email/name), indirect (zip, dob alone), sensitive (SSN, payment). |
| Constraint |
optional |
Range / enum / regex (per the sibling data-quality-conventions skill). |
| Description |
yes |
One-sentence semantic meaning; not just the type. |
2. Freshness SLA
| Field |
Notes |
| Update cadence |
daily / hourly / continuous / weekly. |
| Max staleness |
The point past which downstream consumers should treat the data as broken (per the sibling data-quality-conventions skill: typically 2× cadence). |
| Source-of-truth column |
The timestamp column the freshness check reads (e.g. updated_at, loaded_at, event_time). |
3. Volume bounds
| Field |
Notes |
| Expected min/max |
Row-count range under normal operation. |
| Volatility |
stable / monotonic-growth / cyclical / event-driven. |
| Recovery action |
If volume falls outside bounds, what does the consumer do? |
4. Distribution invariants
For each business-meaningful column, what must hold:
| Field |
Example |
| Categorical: accepted values |
status ∈ {placed, shipped, completed, returned}. |
| Numeric: range |
discount_pct ∈ [0, 100]. |
| Frequency / rate |
cancellation_rate ≤ 5% (rolling 7-day window). |
5. Ownership and governance
| Field |
Notes |
| Producer team |
Who runs the pipeline. |
| Owner handle |
Routing handle (Slack / email) for breaks. |
| Consumers |
Known downstream models / dashboards / services. |
| Versioning |
How breaking changes are communicated. |
Output format
Emit as YAML for direct consumption by dbt / GX / Soda:
# data-contracts/<dataset-slug>.yml
contract_version: 1
dataset:
name: orders
description: One row per customer order; updated within 1h of placement.
schema:
- name: order_id
type: BIGINT
nullable: false
pk: true
unique: true
pii: none
description: Surrogate key.
- name: customer_id
type: BIGINT
nullable: false
fk: customers.customer_id
pii: indirect
description: Customer who placed the order.
- name: email
type: VARCHAR
nullable: false
pii: direct
constraint: { format: email }
description: Customer email at time of order (immutable snapshot).
- name: status
type: VARCHAR
nullable: false
constraint:
accepted_values: [placed, shipped, completed, returned]
description: Current fulfillment status.
- name: discount_pct
type: DECIMAL(5,2)
nullable: true
constraint: { range: [0, 100] }
description: Promotion discount applied; null = no promo.
- name: updated_at
type: TIMESTAMP
nullable: false
description: Last-modified timestamp; freshness source-of-truth.
freshness:
cadence: hourly
max_staleness: 2h
source_column: updated_at
volume:
min_per_day: 100
max_per_day: 1000000
volatility: cyclical
recovery_action: |
Investigate ingestion pipeline at <runbook-url> if volume falls outside bounds for >2 cycles.
distribution:
- column: status
rule: accepted_values
values: [placed, shipped, completed, returned]
- column: discount_pct
rule: range
range: [0, 100]
- column: cancellation_rate
rule: rolling_window
window: 7d
max: 0.05
ownership:
producer_team: data-platform
owner: '@data-platform-oncall'
consumers:
- dbt: marts/orders_summary
- dashboard: 'Order Health'
- service: shipping-microservice
versioning: |
Breaking changes coordinated via #data-contracts Slack 14d in advance.
Step-by-step extraction
When reading a data PRD:
- Schema - look for table-spec sections, ER diagrams, or
per-column descriptions. If only column names are given, flag
missing types as gaps; do not guess.
- PII tagging - every column gets a
pii: tag, even pii: none.
Force the data-product author to confirm; PII handling drives
downstream architecture.
- Freshness - look for "updated daily" / "real-time" / "<X
minutes." If absent, flag as a gap.
- Volume - look for traffic projections or current scale. If
absent, flag as a gap to be filled before the contract is
actionable.
- Distribution - look for business rules in prose form ("status
is one of...", "discount up to 100%") and translate.
- Ownership - look for the responsible team / Slack channel.
Gap flagging
The agent never fabricates contract fields. Every gap becomes an
explicit question:
## Contract gaps (HUMAN INPUT REQUIRED)
| Section | Field | Question |
|---------------|------------------------|--------------------------------------------------------------------------|
| schema | `customer_phone.pii` | Direct PII (yes - phone numbers are PII per most jurisdictions). Confirm. |
| freshness | `cadence` | PRD says "fresh data" - daily? hourly? real-time? Each implies a different gate. |
| volume | `max_per_day` | Not specified; required to set a `row_count between` assertion. |
| distribution | `payment_method` | What's the accepted-value set? PRD lists four; are there more (e.g. "apple_pay" added recently)? |
Until the gaps are filled, the contract is incomplete and the test
suite cannot be generated.
Examples
Three worked examples (PRD to contract, minimal source with a gap list,
and refactor of an existing dataset) are in
references/examples.md.
Anti-patterns
| Anti-pattern |
Why it fails |
Fix |
Auto-tagging every column pii: none |
Misses real PII; downstream ungoverned. |
Force the author to make the call; default to "needs review" rather than "none". |
| Generic freshness "real-time" |
Ambiguous; "real-time" varies from <100ms to <1min by team. |
Quantify: cadence: continuous, max_staleness: 60s. |
| Distribution rules without a window |
"Cancellation rate ≤5%" - over what window? Lifetime? |
Always specify a window: rolling_window: 7d. |
| Skipping Ownership |
A contract without an owner is a wishlist; nobody's on the hook. |
Require ownership before declaring the contract complete. |
References
- ISTQB Glossary V4.7.1 - testability + non-functional testing
(cited in
non-functional-requirement-extractor, in the qa-shift-left
plugin) - for the underlying observability heuristic.
- ISO/IEC 25012:2008 - data-quality model (cite by stable ID;
paywalled at iso.org).
- Sibling skills
dbt-testing, great-expectations, soda-checks -
the downstream consumers of this skill's output.
data-quality-conventions - naming and threshold conventions referenced from the contract.
1---2name: data-contract-extractor3description: "Use when scoping a new data product or formalizing checks on an existing one. Reads a data PRD, dataset README or lineage doc and writes a data contract: schema with types, nullability and PII flags, freshness SLA, volume bounds, distribution rules and owner, for dbt, Great Expectations or Soda."4metadata:5 source: https://skillmd.com/skills/testland/data-contract-extractor6---78# data-contract-extractor910## Overview1112This skill formalizes the prose of a data PRD into a **data contract** -13the producer/consumer agreement on schema, freshness, volume, semantic14invariants, and ownership - that the QA test suite can mechanically15assert against, typically via the sibling skills in this plugin16(`dbt-testing`, `great-expectations`, `soda-checks`). "Data contract" is17practitioner-emergent terminology (Andrew Jones / Chad Sanderson), not18ISTQB-canonical; this skill cites industry-engineering sources.1920## When to use2122- A new data product (dbt model, table, file feed) is being scoped23 and the team wants assertions before shipping.24- An existing data product has implicit assumptions consumers rely25 on; the team is documenting them ahead of a refactor.26- A PRD or design doc references a dataset and the team needs the27 schema / SLA pulled out into structured form.28- A data-quality engineer needs the contract as input to suite generation.2930## What goes in a data contract3132The five required sections, in order of authoring priority:3334### 1. Schema3536For each column:3738| Field | Required | Notes |39|---------------|----------|-------|40| Name | yes | snake_case; matches the warehouse table. |41| Type | yes | Warehouse-native type (`VARCHAR`, `BIGINT`, `TIMESTAMP`, etc.). |42| Nullable | yes | `true` / `false` - the test suite's `not_null` decision. |43| PK | yes | `true` for primary-key column(s). |44| Unique | yes | `true` for candidate keys (separate from PK). |45| FK | optional | If foreign key, the `<table>.<column>` reference. |46| PII | required | Tag values: `none`, `direct` (email/name), `indirect` (zip, dob alone), `sensitive` (SSN, payment). |47| Constraint | optional | Range / enum / regex (per the sibling `data-quality-conventions` skill). |48| Description | yes | One-sentence semantic meaning; not just the type. |4950### 2. Freshness SLA5152| Field | Notes |53|-------------------|-------|54| Update cadence | `daily / hourly / continuous / weekly`. |55| Max staleness | The point past which downstream consumers should treat the data as broken (per the sibling `data-quality-conventions` skill: typically 2× cadence). |56| Source-of-truth column | The timestamp column the freshness check reads (e.g. `updated_at`, `loaded_at`, `event_time`). |5758### 3. Volume bounds5960| Field | Notes |61|-------------------|-------|62| Expected min/max | Row-count range under normal operation. |63| Volatility | `stable / monotonic-growth / cyclical / event-driven`. |64| Recovery action | If volume falls outside bounds, what does the consumer do? |6566### 4. Distribution invariants6768For each business-meaningful column, what must hold:6970| Field | Example |71|------------------------------|----------------------------------------------------|72| Categorical: accepted values | `status ∈ {placed, shipped, completed, returned}`. |73| Numeric: range | `discount_pct ∈ [0, 100]`. |74| Frequency / rate | `cancellation_rate ≤ 5%` (rolling 7-day window). |7576### 5. Ownership and governance7778| Field | Notes |79|--------------|-------|80| Producer team| Who runs the pipeline. |81| Owner handle | Routing handle (Slack / email) for breaks. |82| Consumers | Known downstream models / dashboards / services. |83| Versioning | How breaking changes are communicated. |8485## Output format8687Emit as YAML for direct consumption by dbt / GX / Soda:8889```yaml90# data-contracts/<dataset-slug>.yml91contract_version: 192dataset:93 name: orders94 description: One row per customer order; updated within 1h of placement.9596schema:97 - name: order_id98 type: BIGINT99 nullable: false100 pk: true101 unique: true102 pii: none103 description: Surrogate key.104 - name: customer_id105 type: BIGINT106 nullable: false107 fk: customers.customer_id108 pii: indirect109 description: Customer who placed the order.110 - name: email111 type: VARCHAR112 nullable: false113 pii: direct114 constraint: { format: email }115 description: Customer email at time of order (immutable snapshot).116 - name: status117 type: VARCHAR118 nullable: false119 constraint:120 accepted_values: [placed, shipped, completed, returned]121 description: Current fulfillment status.122 - name: discount_pct123 type: DECIMAL(5,2)124 nullable: true125 constraint: { range: [0, 100] }126 description: Promotion discount applied; null = no promo.127 - name: updated_at128 type: TIMESTAMP129 nullable: false130 description: Last-modified timestamp; freshness source-of-truth.131132freshness:133 cadence: hourly134 max_staleness: 2h135 source_column: updated_at136137volume:138 min_per_day: 100139 max_per_day: 1000000140 volatility: cyclical141 recovery_action: |142 Investigate ingestion pipeline at <runbook-url> if volume falls outside bounds for >2 cycles.143144distribution:145 - column: status146 rule: accepted_values147 values: [placed, shipped, completed, returned]148 - column: discount_pct149 rule: range150 range: [0, 100]151 - column: cancellation_rate152 rule: rolling_window153 window: 7d154 max: 0.05155156ownership:157 producer_team: data-platform158 owner: '@data-platform-oncall'159 consumers:160 - dbt: marts/orders_summary161 - dashboard: 'Order Health'162 - service: shipping-microservice163 versioning: |164 Breaking changes coordinated via #data-contracts Slack 14d in advance.165```166167## Step-by-step extraction168169When reading a data PRD:1701711. **Schema** - look for table-spec sections, ER diagrams, or172 per-column descriptions. If only column names are given, flag173 missing types as gaps; do not guess.1742. **PII tagging** - every column gets a `pii:` tag, even `pii: none`.175 Force the data-product author to confirm; PII handling drives176 downstream architecture.1773. **Freshness** - look for "updated daily" / "real-time" / "<X178 minutes." If absent, flag as a gap.1794. **Volume** - look for traffic projections or current scale. If180 absent, flag as a gap to be filled before the contract is181 actionable.1825. **Distribution** - look for business rules in prose form ("status183 is one of...", "discount up to 100%") and translate.1846. **Ownership** - look for the responsible team / Slack channel.185186## Gap flagging187188The agent never fabricates contract fields. Every gap becomes an189explicit question:190191```markdown192## Contract gaps (HUMAN INPUT REQUIRED)193194| Section | Field | Question |195|---------------|------------------------|--------------------------------------------------------------------------|196| schema | `customer_phone.pii` | Direct PII (yes - phone numbers are PII per most jurisdictions). Confirm. |197| freshness | `cadence` | PRD says "fresh data" - daily? hourly? real-time? Each implies a different gate. |198| volume | `max_per_day` | Not specified; required to set a `row_count between` assertion. |199| distribution | `payment_method` | What's the accepted-value set? PRD lists four; are there more (e.g. "apple_pay" added recently)? |200```201202Until the gaps are filled, the contract is incomplete and the test203suite cannot be generated.204205## Examples206207Three worked examples (PRD to contract, minimal source with a gap list,208and refactor of an existing dataset) are in209[references/examples.md](references/examples.md).210211## Anti-patterns212213| Anti-pattern | Why it fails | Fix |214|---------------------------------------------------|---------------------------------------------------------------|-----|215| Auto-tagging every column `pii: none` | Misses real PII; downstream ungoverned. | Force the author to make the call; default to "needs review" rather than "none". |216| Generic freshness "real-time" | Ambiguous; "real-time" varies from <100ms to <1min by team. | Quantify: `cadence: continuous, max_staleness: 60s`. |217| Distribution rules without a window | "Cancellation rate ≤5%" - over what window? Lifetime? | Always specify a window: `rolling_window: 7d`. |218| Skipping Ownership | A contract without an owner is a wishlist; nobody's on the hook. | Require ownership before declaring the contract complete. |219220## References221222- ISTQB Glossary V4.7.1 - testability + non-functional testing223 (cited in `non-functional-requirement-extractor`, in the qa-shift-left224 plugin) - for the underlying observability heuristic.225- ISO/IEC 25012:2008 - data-quality model (cite by stable ID;226 paywalled at iso.org).227- Sibling skills `dbt-testing`, `great-expectations`, `soda-checks` -228 the downstream consumers of this skill's output.229- `data-quality-conventions` - naming and threshold conventions referenced from the contract.