posit-dev/pointblank/define-contracts
Claude Code and agent skill by posit-dev/pointblank
- community
Checking that the SKILL.md file is still in the repository.
Define data contracts and pipeline validation with Pointblank. Covers Contract, Step, Schema, Pipeline, and PipelineResult for enforcing structural and semantic expectations at data boundaries, plus YAML serialization and import/export of external contract formats (JSON Schema, Frictionless, dbt, ODCS). Use when setting up source/target contracts, pipeline validation, or contract files.
Install
npx vskill@latest install posit-dev/pointblank/define-contractsSKILL.md
The same SKILL.md was published earlier as posit-dev/pointblank/define-contracts.
Define Contracts
Skill for defining data contracts that enforce expectations at the boundaries of data pipelines. A contract declares what a dataset must look like (schema) and what properties it must satisfy (steps), along with metadata about ownership and violation behavior.
Quick start
Skill directory structure
When to use what
| I want to... | Use | |
|---|---|---|
| Declare expected table structure | Schema | |
| Declare a semantic check as a step | Step | |
| Bundle schema + steps into a contract | Contract | |
| Validate data at pipeline ingestion | Pipeline with source | |
| Validate data after transformation | Pipeline with target | |
| Validate both source and target | Pipeline with both | |
| Serialize a contract to YAML | contract.to_yaml() | |
| Load a contract from YAML | Contract.from_yaml() | |
| Convert to JSON Schema, dbt, etc. | export_contract() | |
| Read JSON Schema, dbt, ODCS, etc. | import_contract() | |
| Add reusable steps to a contract | to_validate() + add_steps() | |
| Warn on violation without stopping | on_violation="warn" | |
| Raise an exception on violation | on_violation="raise" | |
| Log violations instead of warning | on_violation="log" |
Core concepts
Contract
A Contract bundles:
- name -- identifier for the contract
- direction --
"source"(incoming data) or"target"(output) - schema -- expected column names and types
- steps -- list of
Stepobjects defining semantic checks - on_violation -- what a
Pipelinedoes when validation fails
Step
A Step is a declarative representation of a validation method call:
The method argument names a Validate method, and the keyword arguments are passed to it. A contract accepts only these methods (any other name raises a ValueError when the contract is created): the col_vals_* comparison, range, set, null, regex, within_spec, increasing/decreasing, and expr methods; col_exists, col_pct_null, col_schema_match, col_count_match, row_count_match, rows_distinct, rows_complete; and conjointly, whose expressions go in a list: pb.Step("conjointly", exprs=[lambda df: pl.col("a") > 0]).
For other checks (aggregates, data_freshness, tbl_match, text checks, ...), compile the contract and chain them on, or add a pb.Steps bundle:
Schema
Define expected table structure:
Validating against a contract
Or convert to a Validate object for further customization:
on_violation behavior
on_violation applies only when a Pipeline enforces the contract (run(), validate_source(), validate_target()). A boundary fails when any test unit fails, whatever the thresholds.
| Value | Behavior | |
|---|---|---|
"warn" | Issue a UserWarning (default) | |
"raise" | Raise ContractViolationError (a RuntimeError) | |
"log" | Write a warning to the "pointblank.contract" logger |
The error has contract, validation, and (from run()) result attributes, the last being the PipelineResult of the run.
Pipeline
A Pipeline orchestrates source and target contract validation around a data transformation:
PipelineResult
Serialization
Step arguments must be plain data to be written to YAML; a lambda, an expression, or a column selector makes to_yaml() raise a ValueError.
Other contract formats
Rules with no equivalent in the other format are left out of an export, and the import summary reports what couldn't be mapped.
Workflows
Setting up a new contract
- Profile the data with
pb.DataScan(data=df)to understand its
shape, types, and distributions.
- Take a starting schema from the data:
schema = pb.Schema(tbl=df). - Define steps for the semantic rules your domain requires.
- Choose
on_violationbased on criticality. - Test with
contract.validate(data=df). - Serialize to YAML for version control.
Adding contracts to an existing pipeline
- Define source and target contracts.
- Wrap the transformation in a
Pipeline. - Use
short_circuit=Trueto skip the transform when source
validation fails.
- Check
result.passedto gate downstream processing.
Evolving contracts over time
When schema or rules change:
- Update the schema and steps in the contract YAML.
- Bump the
versionfield. - Test against representative data.
- Communicate changes to
consumers.
Gotchas
- `direction` is metadata, not enforcement. It documents intent
but doesn't change validation behavior.
- `on_violation` only acts in a `Pipeline`.
contract.validate()
returns the validation without warning or raising; check it with all_passed() or assert_passing().
- `short_circuit=True` skips the transform and target validation
if source validation fails. Set to False to always run both (a source with on_violation="raise" then raises after the target is validated).
- A pipeline's `thresholds=` replace the contracts' thresholds;
they aren't merged. Thresholds don't decide whether a boundary passes: any failing test unit fails it.
- Schema type strings are backend-specific. Use the dtype names
from your backend (e.g., "Int64" for Polars, "int64" for Pandas).
- `to_validate()` does not call `interrogate()`. Call it yourself
if you add steps. Use validate() for automatic interrogation.
- Only some methods can be contract steps. An unsupported or
misspelled method name raises a ValueError when the Contract is created; a misspelled argument raises a TypeError when it's compiled into a validation.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/define-contracts/SKILL.md
Popularity
- Repository stars
- 483
- Repository forks
- 30
- 7-day trend score
- 31
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/posit-dev/pointblank/define-contracts)