Claude Skill

data-cleaning

Clean, profile, validate, reshape, and document messy tabular, text, JSON, and relational data through an evidence-first, reproducible workflow. Use when preparing data for analysis, reporting, modeling, ingestion, migration, or matching. Do not use for statistical modeling, dash

LLM Mart · 0 points · 16 views 0 listing impressions 0 install-command copies
Download magnus919-agent-skills-data-cleaning-1809013.zip · 24 KB

Install

skills CLI npx skills add https://github.com/magnus919/agent-skills/tree/main/data-cleaning
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install magnus919-agent-skills@llmmart
Git git clone https://github.com/magnus919/agent-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole magnus919/agent-skills collection as a plugin from our marketplace. Git is the plain clone.

README

data-cleaning

A practical, evidence-first workflow for turning messy data into trustworthy, reviewable datasets.

Why Install This Skill

Messy data is not solved by a handful of dropna() calls. This skill helps an agent discover what is wrong, decide what may safely change, preserve what was observed, and demonstrate that the result still matches the intended grain and meaning.

It works across CSV, JSON, text, DataFrames, SQL extracts, and pipeline boundaries. It combines a repeatable methodology with tool-selection guidance, reusable plans and reports, and a dependency-free profiling script that produces machine-readable evidence before mutation.

What You Get

Path Purpose
SKILL.md Core workflow and completion gate
references/ Methodology, operations, validation, tools, sources
templates/ Cleaning plan, decision log, transformation log, exception register, schema contract, quality report
scripts/profile_dataset.py Read-only CSV/TSV/JSONL profiler
scripts/reconcile_dataset.py Read-only key, row-count, and aggregate reconciliation
scripts/test_* Deterministic tests for bundled scripts
evals/evals.json Output-quality evaluation cases

Quick Start

python3 scripts/profile_dataset.py input.csv --output profile.json
python3 scripts/profile_dataset.py input.csv --max-rows 10000

The profiler does not edit the input. Use its report to fill templates/cleaning-plan.md, then validate the transformed output against templates/schema-contract.yml or a project-specific contract.

For AI-assisted data work, the boundary workflow helps keep uncertain proposals out of trusted datasets. Use the companion record to retain validation and review evidence.

Triggers

  • Clean or standardize CSV, JSON, text, spreadsheet exports, or DataFrames
  • Diagnose missing values, duplicates, malformed types, dates, encodings, or categories
  • Design a reusable cleaning pipeline or data-quality contract
  • Choose among pandas, Polars, pyjanitor, Pandera, Great Expectations, OpenRefine, Frictionless, dbt tests, or Spark-scale tools
  • Review whether cleaning is reproducible, safe, or leakage-free

Requirements

  • Python 3.9+ for the bundled script
  • No external dependency for first-pass profiling
  • Optional ecosystem tools require their own installations

Skill manifest

Data cleaning

Treat cleaning as a controlled transformation of an observed dataset, not cosmetic editing. Preserve raw input, state the target use and grain, make every lossy decision explicit, and prove that the cleaned output satisfies a contract.

When a model proposes data transformations, load the AI boundary workflow and use the companion record.

Route by task

Need Read next
End-to-end method, scope, and stopping rules references/methodology.md
Choose a library or platform references/tool-selection.md
Missingness, duplicates, types, ranges, categories, dates, joins references/operations.md
Text, identifiers, Unicode, and entity resolution references/text-and-entity.md
Schemas, contracts, validation, drift, scale references/validation-and-scale.md
CLI, OpenRefine, monitoring, and interactive remediation references/cli-and-interactive-tools.md
Source claims and version-sensitive caveats references/sources.md
Plan, logs, exceptions, contracts, or reports templates/cleaning-plan.md, templates/transformation-log.jsonl, templates/exception-register.csv, templates/schema-contract.yml, templates/quality-report.md
Lightweight profile or reconciliation Run python3 scripts/profile_dataset.py --help or python3 scripts/reconcile_dataset.py --help

Available Scripts

Script Purpose Invocation
scripts/profile_dataset.py Dependency-free first-pass profiling of a CSV, TSV, or JSONL input without modifying it: missingness, cardinality, type candidates, duplicates, ranges, and value anomalies. Run it at workflow step 3 (Profile before changing) as the evidence-gathering pass before designing any cleaning decision. python3 scripts/profile_dataset.py data.csv --output profile.json
scripts/reconcile_dataset.py Reconciliation between a before and after delimited dataset: row counts, key uniqueness/overlap, and per-column sums (--sum), keyed by --key, writing a machine-readable report. Run it during Validate twice / Review to prove grain preservation and quantify exactly what a transformation changed. python3 scripts/reconcile_dataset.py raw.csv cleaned.csv --key id --sum amount --output reconciliation.json
scripts/test_profile_dataset.py Pytest suite covering the profiler's behavior on representative inputs. Run it after modifying the profiler or when auditing its output; CI discovers it automatically. python3 -m pytest scripts/test_profile_dataset.py
scripts/test_reconcile_dataset.py Pytest suite covering the reconciler's keying, summing, and reporting behavior. Run it after modifying the reconciler or when auditing its output; CI discovers it automatically. python3 -m pytest scripts/test_reconcile_dataset.py

Default workflow

  1. Frame: identify the decision, owner, source, privacy constraints, unit of observation, keys, expected grain, time window, and acceptance threshold. Do not silently infer a business rule from a suspicious value.
  2. Freeze evidence: record source path/URI, retrieval time, file size/hash where feasible, encoding, delimiter, schema, row/column counts, and software versions. Keep raw data read-only and write to a new output.
  3. Profile before changing: inspect missingness, sentinel values, duplicates, cardinality, type candidates, ranges, invalid dates, whitespace/Unicode anomalies, cross-field relationships, and drift. Use the bundled profiler for a dependency-free first pass.
  4. Design decisions: classify each finding as preserve, standardize, repair, impute, quarantine, reject, or escalate. Record rationale, rule, affected rows, confidence, reversibility, and owner.
  5. Transform in layers: prefer deterministic named steps: parse → canonicalize → type/coerce → validate → deduplicate → resolve entities → impute/quarantine → reshape. Keep raw, staged, rejected, and final datasets distinct.
  6. Validate twice: run structural checks before and after transformation. Validate row/grain preservation, key uniqueness, referential integrity, allowed values, units, bounds, null policy, and expected distributions. Tests should identify failing records.
  7. Review and release: compare before/after metrics, inspect samples of every changed class, obtain domain approval for semantic or lossy changes, publish the report and provenance, and make the run reproducible.

Non-negotiable controls

  • Never overwrite raw data or silently drop rows, columns, categories, outliers, or unmatched entities.
  • Separate invalid, missing, not applicable, not collected, and withheld when the domain distinguishes them.
  • Parse dates and numbers with an explicit locale, timezone, unit, and error policy. Count parse failures; do not silently turn them into nulls.
  • Normalize text conservatively. Retain original and normalized values plus confidence when matching or repairing.
  • Fit imputers, encoders, normalization parameters, and deduplication rules only on the permitted training/reference partition. Avoid leakage across time or evaluation boundaries.
  • Treat profiling as evidence for investigation, not permission to auto-fix. An anomaly can be a real event.
  • Use quarantine for records that cannot be repaired safely. “Clean” means accepted by a stated contract, not “no rows remain.”

Completion gate

A cleaning task is complete only when the output, transformation/decision log, validation evidence, provenance, and unresolved issues exist; raw data remains intact; acceptance checks pass; and a reviewer can reproduce or audit the result. If semantic ambiguity remains, stop at quarantine or escalation rather than inventing a value.

When not to use

Do not use this skill for inferential statistics or model selection, which belong to data-scientist; for ETL orchestration, storage, or production data-quality operations, route to data-engineering; or for operating a named validation or database platform, route to that tool's skill. This skill supplies cleaning judgment and artifacts those workflows consume.

Prerequisites

  • Python 3.9+ with the standard library only for both bundled scripts (per compatibility); ecosystem tools (OpenRefine, pandas-backed tooling) are optional accelerators covered in references/cli-and-interactive-tools.md.
  • A raw input you can keep read-only plus write access to a separate output location — every script reads without modifying its input.
  • The templates above when the task warrants formal artifacts: a cleaning plan, transformation log, exception register, schema contract, or quality report.
  • pytest only when running the bundled test suites.

Limitations

  • The bundled profiler and reconciler are first-pass evidence tools: they surface anomalies and quantify deltas but do not decide preserve/repair/impute/quarantine — those classifications stay with the workflow's decision step.
  • Both scripts handle delimited text and JSONL; binary formats, relational databases, and nested document stores need other tooling.
  • Profiling output is evidence for investigation, never permission to auto-fix; an anomaly can be a real event.
  • A passing reconciliation proves structural preservation on the checked keys and sums only — semantic correctness of values still requires the review and release gate.
Files (agent-skills)
  • evals
    • evals.json 7.4 KB
      Loading…
    • trigger-cases.json 414 B
      Loading…
  • references
    • ai-repair-review.md 3 KB
      Loading…
    • cli-and-interactive-tools.md 1.4 KB
      Loading…
    • methodology.md 2 KB
      Loading…
    • operations.md 2 KB
      Loading…
    • sources.md 2.6 KB
      Loading…
    • text-and-entity.md 1.8 KB
      Loading…
    • tool-selection.md 1.5 KB
      Loading…
    • validation-and-scale.md 1.2 KB
      Loading…
  • scripts
    • profile_dataset.py 5.2 KB
      Loading…
    • reconcile_dataset.py 3.6 KB
      Loading…
    • test_profile_dataset.py 1.6 KB
      Loading…
    • test_reconcile_dataset.py 1.9 KB
      Loading…
  • templates
    • ai-repair-ledger.csv 222 B · in bundle
    • cleaning-plan.md 1 KB
      Loading…
    • decision-log.csv 183 B · in bundle
    • exception-register.csv 148 B · in bundle
    • quality-report.md 783 B
      Loading…
    • schema-contract.yml 943 B
      Loading…
    • transformation-log.jsonl 237 B · in bundle
  • README.md 2.4 KB
    # data-cleaning
    
    A practical, evidence-first workflow for turning messy data into trustworthy, reviewable datasets.
    
    ## Why Install This Skill
    
    Messy data is not solved by a handful of `dropna()` calls. This skill helps an agent discover what is wrong, decide what may safely change, preserve what was observed, and demonstrate that the result still matches the intended grain and meaning.
    
    It works across CSV, JSON, text, DataFrames, SQL extracts, and pipeline boundaries. It combines a repeatable methodology with tool-selection guidance, reusable plans and reports, and a dependency-free profiling script that produces machine-readable evidence before mutation.
    
    ## What You Get
    
    | Path | Purpose |
    |---|---|
    | `SKILL.md` | Core workflow and completion gate |
    | `references/` | Methodology, operations, validation, tools, sources |
    | `templates/` | Cleaning plan, decision log, transformation log, exception register, schema contract, quality report |
    | `scripts/profile_dataset.py` | Read-only CSV/TSV/JSONL profiler |
    | `scripts/reconcile_dataset.py` | Read-only key, row-count, and aggregate reconciliation |
    | `scripts/test_*` | Deterministic tests for bundled scripts |
    | `evals/evals.json` | Output-quality evaluation cases |
    
    ## Quick Start
    
    ```bash
    python3 scripts/profile_dataset.py input.csv --output profile.json
    python3 scripts/profile_dataset.py input.csv --max-rows 10000
    ```
    
    The profiler does not edit the input. Use its report to fill `templates/cleaning-plan.md`, then validate the transformed output against `templates/schema-contract.yml` or a project-specific contract.
    
    For AI-assisted data work, the [boundary workflow](references/ai-repair-review.md) helps keep uncertain
    proposals out of trusted datasets. Use the [companion record](templates/ai-repair-ledger.csv) to retain
    validation and review evidence.
    
    ## Triggers
    
    - Clean or standardize CSV, JSON, text, spreadsheet exports, or DataFrames
    - Diagnose missing values, duplicates, malformed types, dates, encodings, or categories
    - Design a reusable cleaning pipeline or data-quality contract
    - Choose among pandas, Polars, pyjanitor, Pandera, Great Expectations, OpenRefine, Frictionless, dbt tests, or Spark-scale tools
    - Review whether cleaning is reproducible, safe, or leakage-free
    
    ## Requirements
    
    - Python 3.9+ for the bundled script
    - No external dependency for first-pass profiling
    - Optional ecosystem tools require their own installations
    
  • SKILL.md 8.1 KB
    ---
    name: data-cleaning
    description: >-
      Clean, profile, validate, reshape, and document messy tabular, text, JSON, and
      relational data through an evidence-first, reproducible workflow. Use when
      preparing data for analysis, reporting, modeling, ingestion, migration, or
      matching, including AI-suggested repair, entity-match review, score calibration
      limits, and reversible repair ledgers. Do not use for statistical modeling, dashboard design, or operating
      a named data platform; route those tasks to data-scientist, data-engineering,
      or the relevant tool skill.
    license: MIT
    compatibility: Works with any Agent Skills client. The bundled profiler requires Python 3.9+ and the standard library; ecosystem tools are optional.
    metadata:
      domain: data-quality-and-cleaning
      source: primary-docs-plus-orientation-article
    ---
    
    # Data cleaning
    
    Treat cleaning as a controlled transformation of an observed dataset, not cosmetic editing. Preserve raw input, state the target use and grain, make every lossy decision explicit, and prove that the cleaned output satisfies a contract.
    
    When a model proposes data transformations, load [the AI boundary workflow](references/ai-repair-review.md)
    and use [the companion record](templates/ai-repair-ledger.csv).
    
    ## Route by task
    
    | Need | Read next |
    |---|---|
    | End-to-end method, scope, and stopping rules | `references/methodology.md` |
    | Choose a library or platform | `references/tool-selection.md` |
    | Missingness, duplicates, types, ranges, categories, dates, joins | `references/operations.md` |
    | Text, identifiers, Unicode, and entity resolution | `references/text-and-entity.md` |
    | Schemas, contracts, validation, drift, scale | `references/validation-and-scale.md` |
    | CLI, OpenRefine, monitoring, and interactive remediation | `references/cli-and-interactive-tools.md` |
    | Source claims and version-sensitive caveats | `references/sources.md` |
    | Plan, logs, exceptions, contracts, or reports | `templates/cleaning-plan.md`, `templates/transformation-log.jsonl`, `templates/exception-register.csv`, `templates/schema-contract.yml`, `templates/quality-report.md` |
    | Lightweight profile or reconciliation | Run `python3 scripts/profile_dataset.py --help` or `python3 scripts/reconcile_dataset.py --help` |
    
    ## Available Scripts
    
    | Script | Purpose | Invocation |
    |---|---|---|
    | `scripts/profile_dataset.py` | Dependency-free first-pass profiling of a CSV, TSV, or JSONL input without modifying it: missingness, cardinality, type candidates, duplicates, ranges, and value anomalies. Run it at workflow step 3 (Profile before changing) as the evidence-gathering pass before designing any cleaning decision. | `python3 scripts/profile_dataset.py data.csv --output profile.json` |
    | `scripts/reconcile_dataset.py` | Reconciliation between a before and after delimited dataset: row counts, key uniqueness/overlap, and per-column sums (`--sum`), keyed by `--key`, writing a machine-readable report. Run it during Validate twice / Review to prove grain preservation and quantify exactly what a transformation changed. | `python3 scripts/reconcile_dataset.py raw.csv cleaned.csv --key id --sum amount --output reconciliation.json` |
    | `scripts/test_profile_dataset.py` | Pytest suite covering the profiler's behavior on representative inputs. Run it after modifying the profiler or when auditing its output; CI discovers it automatically. | `python3 -m pytest scripts/test_profile_dataset.py` |
    | `scripts/test_reconcile_dataset.py` | Pytest suite covering the reconciler's keying, summing, and reporting behavior. Run it after modifying the reconciler or when auditing its output; CI discovers it automatically. | `python3 -m pytest scripts/test_reconcile_dataset.py` |
    
    ## Default workflow
    
    1. **Frame:** identify the decision, owner, source, privacy constraints, unit of observation, keys, expected grain, time window, and acceptance threshold. Do not silently infer a business rule from a suspicious value.
    2. **Freeze evidence:** record source path/URI, retrieval time, file size/hash where feasible, encoding, delimiter, schema, row/column counts, and software versions. Keep raw data read-only and write to a new output.
    3. **Profile before changing:** inspect missingness, sentinel values, duplicates, cardinality, type candidates, ranges, invalid dates, whitespace/Unicode anomalies, cross-field relationships, and drift. Use the bundled profiler for a dependency-free first pass.
    4. **Design decisions:** classify each finding as preserve, standardize, repair, impute, quarantine, reject, or escalate. Record rationale, rule, affected rows, confidence, reversibility, and owner.
    5. **Transform in layers:** prefer deterministic named steps: parse → canonicalize → type/coerce → validate → deduplicate → resolve entities → impute/quarantine → reshape. Keep raw, staged, rejected, and final datasets distinct.
    6. **Validate twice:** run structural checks before and after transformation. Validate row/grain preservation, key uniqueness, referential integrity, allowed values, units, bounds, null policy, and expected distributions. Tests should identify failing records.
    7. **Review and release:** compare before/after metrics, inspect samples of every changed class, obtain domain approval for semantic or lossy changes, publish the report and provenance, and make the run reproducible.
    
    ## Non-negotiable controls
    
    - Never overwrite raw data or silently drop rows, columns, categories, outliers, or unmatched entities.
    - Separate invalid, missing, not applicable, not collected, and withheld when the domain distinguishes them.
    - Parse dates and numbers with an explicit locale, timezone, unit, and error policy. Count parse failures; do not silently turn them into nulls.
    - Normalize text conservatively. Retain original and normalized values plus confidence when matching or repairing.
    - Fit imputers, encoders, normalization parameters, and deduplication rules only on the permitted training/reference partition. Avoid leakage across time or evaluation boundaries.
    - Treat profiling as evidence for investigation, not permission to auto-fix. An anomaly can be a real event.
    - Use quarantine for records that cannot be repaired safely. “Clean” means accepted by a stated contract, not “no rows remain.”
    
    ## Completion gate
    
    A cleaning task is complete only when the output, transformation/decision log, validation evidence, provenance, and unresolved issues exist; raw data remains intact; acceptance checks pass; and a reviewer can reproduce or audit the result. If semantic ambiguity remains, stop at quarantine or escalation rather than inventing a value.
    
    ## When not to use
    
    Do not use this skill for inferential statistics or model selection, which belong to `data-scientist`; for ETL orchestration, storage, or production data-quality operations, route to `data-engineering`; or for operating a named validation or database platform, route to that tool's skill. This skill supplies cleaning judgment and artifacts those workflows consume.
    
    ## Prerequisites
    
    - Python 3.9+ with the standard library only for both bundled scripts (per `compatibility`); ecosystem tools (OpenRefine, pandas-backed tooling) are optional accelerators covered in `references/cli-and-interactive-tools.md`.
    - A raw input you can keep read-only plus write access to a separate output location — every script reads without modifying its input.
    - The templates above when the task warrants formal artifacts: a cleaning plan, transformation log, exception register, schema contract, or quality report.
    - `pytest` only when running the bundled test suites.
    
    ## Limitations
    
    - The bundled profiler and reconciler are first-pass evidence tools: they surface anomalies and quantify deltas but do not decide preserve/repair/impute/quarantine — those classifications stay with the workflow's decision step.
    - Both scripts handle delimited text and JSONL; binary formats, relational databases, and nested document stores need other tooling.
    - Profiling output is evidence for investigation, never permission to auto-fix; an anomaly can be a real event.
    - A passing reconciliation proves structural preservation on the checked keys and sums only — semantic correctness of values still requires the review and release gate.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.