/data-quality:run-data-quality [pipeline-name]from data-quality
Executes already-defined data quality checks against loaded destination data using dlt. Supports two profiles: running checks via pipeline decorators or writing a standalone script with dlt.attach + dq.run_checks.
Ships in data-quality. 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.
Execute checks against the already-loaded destination data using dq.run_checks(). No source re-extraction happens — this reads only from the destination.
Reference: dlthub data quality docs
Expected from prior steps:
Before writing any script, determine which execution profile applies:
| Profile | Signal | Action |
|---|---|---|
| A — pipeline author | Checks were applied via @dq.with_checks / dq.with_checks(resource, ...) decorators in the pipeline file | Run the existing pipeline script — checks fire automatically during load |
| B — postmortem analyst | No decorator changes; user wants to check existing destination data without re-running the pipeline | Write and run tools/dq_run.py using dlt.attach + dq.run_checks |
If the profile is ambiguous, ask: "Were the checks added to the pipeline code (decorators), or do you want to run them against data already in the destination without re-extracting?"
Profile A — run the pipeline
@dq.with_checks and @dq.with_metrics only store hints in the schema metadata — they do not execute on their own. Results are written to _dlt_checks by dq.data_quality_checks(pipeline.dataset()), which define-data-quality-checks already added to the pipeline file. Instruct the user to run their pipeline script. Show the exact command (infer from session context or ask):
uv run python <pipeline_script>.py
This runs the data load AND the dq.data_quality_checks(...) call in sequence. Both must complete for results to appear.
Wait for the user to confirm the run completed before proceeding to step 2.
Profile B — write and run the data quality script
Confirm the script path. Before writing anything, ask:
Where should I write the data quality run script? (default: tools/dq_run.py)
Use the user's answer as <script_path> for all subsequent steps. If they say "default" or give no answer, use tools/dq_run.py.
Write <script_path>. Use dlt.attach (connects to the existing pipeline, no extraction) and dq.run_checks (reads only from the destination).
import dlt
from dlt.hub import data_quality as dq # https://dlthub.com/docs/hub/data-quality.md
pipeline = dlt.attach(pipeline_name="<pipeline-name>")
load_info = dq.run_checks(pipeline, checks={
"<table>": [
dq.checks.is_unique("<col>"),
dq.checks.is_not_null("<col>"),
# ... all confirmed checks
],
})
print(load_info)
load_info.raise_on_failed_jobs()
Never glob for pipeline files or run the user's original pipeline script. That re-extracts from the source. run_checks is self-contained against the destination.
Pipeline state not found: dlt.attach reads the pipeline state of the active profile, in .dlt/state/<profile>/pipelines (dev unless another profile is pinned). If it raises CannotRestorePipelineException, the active profile has no state for this pipeline. Either another profile is active, the script ran from a folder other than the project root, or the pipeline never ran in this workspace. Check with uv run dlthub profile info and uv run dlthub local pipeline list, then tell the user:
The pipeline state isn't in the active profile (<profile>) of this workspace.
Fix: run your pipeline once from the project root with this profile, or switch
to the profile it ran under (uv run dlthub local profile use <profile>). After
that, the data quality script will work without modification.
Note on case() and NULLs: dq.checks.case("col >= 0") treats NULL as a failing row. If the column is nullable and NULLs are expected, either exclude them in the expression (case("col IS NULL OR col >= 0")) or use is_not_null as a separate check.
Show the written file to the user and ask for explicit confirmation before running:
I've written <script_path> with your checks. Ready to run it?
Do not proceed until the user confirms.
Run the script. Once the user confirms, ask how they run Python scripts if it is not already clear from session context:
python <script_path>
# or, if using uv:
uv run python <script_path>
Capture stdout and stderr in full.
Handle script failure. If run_checks raises an exception or raise_on_failed_jobs() fails:
| Error pattern | Likely cause | Action |
|---|---|---|
DestinationTerminalException containing "database is locked" (DuckDB) | Another process holds the DuckDB file — dlthub dashboard open, a pipeline EL/T run in progress, or a second terminal session | Close the dashboard and any other pipeline processes, then re-run |
DestinationTerminalException (other) | Destination config / credential issue | Ask user to check secrets and destination setup |
LineageFailedException | SQL generation bug in a check (e.g. is_primary_key) | Remove the failing check, use is_unique instead, rewrite <script_path> |
| Any other exception | Infrastructure or code error | Surface the full traceback and stop |
Do not proceed to step 2 (Surface check failures) if the script failed.
Read check results using the library:
import dlt
from dlt.hub import data_quality as dq # https://dlthub.com/docs/hub/data-quality.md
pipeline = dlt.attach(pipeline_name="<pipeline-name>")
results = dq.read_check(pipeline.dataset())
rows = results.fetchall()
cols = results.columns
Consume results with .fetchall() and .columns — do not iterate the Relation directly. Fields: table_name, check_qualified_name, row_count, success_count, success_rate (0.0–1.0; 1.0 = all rows passed). A check passes if success_count = row_count.
If no failures:
All checks passed.
Checks run: <n> — all passed
Moving to review-data-quality for a full metrics review →
If failures are found, present them before proceeding:
<n> check failure(s) detected:
Table: orders
✗ customer_id__is_not_null — 42/500 rows failed (success_rate: 0.92)
✗ amount__case__GT — 3/500 rows failed (success_rate: 0.99)
Table: customers
✓ id__is_unique — passed
✗ email__is_unique — 7 duplicates found (success_rate: 0.99)
Then ask:
How would you like to handle this?
[1] Adjust the check — e.g., the check is too strict for this data
[2] Investigate the source data — the data has a real quality problem
Or say "continue" to proceed to the full review regardless.
If option 1: hand back to define-data-quality-checks with the specific failing checks pre-targeted. Do not re-run the full define flow.
If option 2 or "continue": proceed to review-data-quality with the failure context already in session.
Pass to review-data-quality:
review-data-quality can tailor its deployment recommendationProfile B only — after review is complete, surface the deployment question:
<script_path> ran your checks once against the current data. What would you like to do with it?
[1] Deploy it — run these checks on a schedule on the dltHub platform
[2] Keep it local — re-run manually whenever needed (python <script_path>)
[3] Discard it — the results are in the destination, the script is no longer needed
If the user chooses [1], hand over to dlthub-platform (start at setup-runtime), passing:
<script_path>) as the deployment targetWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dlt-hub/dlthub-ai-harness --plugin data-quality4 skills in this plugin
/define-data-quality-checksUse when the user asks to "define checks", "add validation rules", "what checks should I add", "translate requirements into checks", or wants to map schema hints or business rules to dlthub data quality check and metric calls for a specific pipeline or table. Do NOT use to run checks (use run-data-quality) or to set up the pipeline environment (use setup-data-quality)./review-data-qualityUse when the user asks to "review data quality results", "what failed", "show me data quality results", "analyze check results", "investigate data quality failures", or wants to understand check and metric outcomes from a pipeline run. Do NOT use to run new checks (use run-data-quality)./setup-data-qualityUse when the user asks to "set up data quality", "enable data quality checks", "add data quality to my pipeline", "validate my pipeline data", "I want to check data quality", "check my tables for issues", or wants to start any data quality workflow on a dlt pipeline. Do NOT use for exploring or charting data (use data-exploration toolkit), running existing checks (use run-data-quality), or reviewing results (use review-data-quality).Other plugins' skills for the same job