kmaruthi2002/universal-llm-skills/data-cleaning-and-validation
Claude Code and agent skill by kmaruthi2002/universal-llm-skills
- community
Checking that the SKILL.md file is still in the repository.
Profile, clean and validate data so it can be trusted: establish types and grain, handle missing values, duplicates and outliers, catch joins that multiply rows, fix encoding and unicode problems, normalise dates, timezones and units, write validation rules and data contracts, and document every transformation reproducibly. Use when data is messy, imported from CSV, Excel, APIs or scraped sources, numbers don't reconcile, a join produces too many rows, someone asks to "clean", "dedupe", "validate", "standardise" or "check the quality of" a dataset, or before any analysis on unfamiliar data. Works in SQL, pandas, R, spreadsheets or pipeline tools. Not for building scheduled pipelines (etl-pipelines) or schema design (database-design).
Install
npx vskill@latest install kmaruthi2002/universal-llm-skills/data-cleaning-and-validationSKILL.md
The same SKILL.md was published earlier as kmaruthi2002/universal-llm-skills/data-cleaning-and-validation.
Data Cleaning and Validation
Cleaning is the work of turning data as it arrived into data that means what everyone assumes it means. Validation is the work of proving it, and of making sure it stays that way. Together they decide whether every downstream number is right. They are unglamorous, they take most of the time in real analytical work, and when skipped they produce results that are confidently wrong.
Scope
This skill covers profiling, cleaning decisions, validation rules, data contracts and transformation documentation, for one-off datasets and for data feeding recurring work. Neighbours:
etl-pipelines— scheduling, orchestration, incremental loads and pipeline operations; this skill supplies the checks those pipelines should run.database-design— designing schemas and constraints that prevent bad data at the source.text-processing-and-regex— detailed pattern-matching and text normalisation.data-analysisandstatistical-analysis— what to do with the data once it is trustworthy.spreadsheet-modeling— when the data lives in and is maintained in a spreadsheet.
Core principles
1. Never modify the raw data
Keep the original input untouched and read-only. Every cleaning step produces a new derived version through code. Why: cleaning decisions are often wrong the first time, and you will need to revisit them. If raw data is overwritten, a mistake becomes permanent and unauditable.
2. Every transformation is a decision; record it
Dropping a row, imputing a value, merging two customer records, converting a currency — each changes the answer. Record what was done, why, and how many records it affected. Why: someone (often you, later) will ask why the numbers differ from the source system. The log of transformations is the answer, and it is also how errors get found.
3. Profile before you clean
Do not start fixing things you have not measured. Profile every column first: type, nulls, distinct values, ranges, patterns. Why: the obvious problem is rarely the only one, and fixing one problem in isolation can hide another (e.g., coercing invalid dates to null makes a parsing bug look like missing data).
4. Fix at the source when you can
A cleaning step downstream is a workaround that must be repeated forever and will drift. If the producer can fix it (form validation, a tracking bug, an export setting), report it to them. Clean locally only as a bridge, and say so.
5. Distinguish errors from surprises
An outlier, a null or an odd category may be a data error, or it may be the most important true fact in the dataset. The same value — an order of $250,000 — is an error in a consumer shop and a normal day in a B2B wholesaler. Investigate before deciding. Why: "cleaning" real but inconvenient values is a way of making the data agree with your expectations.
6. Validation is executable, not a one-time look
Write checks as code that runs every time the data is refreshed and fails loudly. Why: data that was clean last month will not necessarily be clean next month; producers change things without telling consumers.
Process
Step 1 — Establish what the data is supposed to be
Before looking at values, find out:
- The grain. One row per what? What uniquely identifies a row?
- The producer. Which system, form, API or person generated it, and how?
- The expected schema. Column names, types, allowed values, units, required fields — from documentation, API specs, source code or the owner.
- The expected volume. Roughly how many rows per day/week? What is the expected relationship to other tables?
- Known issues. Ask owners, read issue trackers, check prior analyses.
Write the expectations down. Profiling then becomes a comparison of expectation against reality, which is far more effective than staring at values.
Step 2 — Profile
For each column, collect:
| Measure | What it reveals | |
|---|---|---|
| Declared vs inferred type | Numbers stored as text, dates as strings, IDs read as numbers (losing leading zeros) | |
| Null / empty / whitespace-only count | Missingness — and the many disguises it wears | |
| Distinct count and top values with frequencies | Categorical noise, defaults, placeholders (N/A, -, unknown, 0, 1900-01-01, 999999) | |
| Min, max, percentiles | Impossible values, unit errors, sentinel values | |
| String length distribution, character patterns | Truncation, mixed formats, encoding damage | |
| Row counts over time | Gaps, spikes, partial loads, backfills |
For the table as a whole: row count, primary-key uniqueness, duplicate full rows, and relationships (foreign-key match rates to related tables).
Tools: SQL GROUP BY / COUNT(DISTINCT) queries; pandas describe, value_counts, isna().sum(); R summary, skimr; profiling libraries (e.g., ydata-profiling); BI tool column statistics; spreadsheet filters and pivot tables. The tool matters less than doing it for every column.
Step 3 — Classify and decide
For each issue found, decide one of: fix (deterministically correct it), flag (keep it but mark it), exclude (remove it from the analysis, with a count), escalate (ask the owner), or accept (it is real). Record the decision and the number of affected rows. Prioritise issues by how much they could change the answer: a 0.01% encoding glitch in a free-text field matters less than 3% duplicate orders.
Step 4 — Apply transformations in code, in order
Write the cleaning as an ordered, re-runnable script or query chain: raw → typed → standardised → deduplicated → validated → analysis-ready. Each stage should be inspectable. Order matters: trim whitespace before deduplicating; parse timezones before deriving dates; convert units before computing outliers.
Step 5 — Validate the output
Run validation rules (below) on the cleaned output, and reconcile it to the input: rows in = rows out + rows excluded (by reason); key totals (sum of revenue, count of distinct customers) before and after, with every difference explained.
Step 6 — Document and hand over
Produce, in whatever form the project uses (README, notebook section, data catalogue entry, model docs): the source, the grain, the list of transformations with affected counts, the validation rules, known remaining issues, and how to re-run it.
Issue-by-issue guidance
Types
- Read everything as text first when the source is untrusted (CSV, Excel, scraped data), then convert explicitly. Automatic type inference silently destroys data: leading zeros in postcodes, ZIP codes, phone numbers and account IDs; long IDs converted to floats and rounded (anything beyond ~15–16 significant digits); gene names and product codes turned into dates by spreadsheets (e.g.,
MARCH1,1-5). - IDs are strings, even when they look numeric. You never do arithmetic on them.
- Track conversion failures. When coercing text to number or date, count the values that failed to parse and look at them. Silent coercion to null (
errors='coerce',TRY_CAST) is fine only if you inspect what was coerced. - Locale-specific number formats:
1.234,56vs1,234.56; currency symbols; thousands separators; parentheses for negatives in accounting exports; percentages stored as45%,45or0.45. - Booleans arrive as
Y/N,yes/no,true/false,1/0,T/F, blank. Map explicitly; decide what blank means.
Missing values
Missing is not one thing. Distinguish:
| Kind | Example | Typical handling | |
|---|---|---|---|
| Not applicable | "Spouse name" for single people | Keep as a distinct state, not an error | |
| Not collected | Field added to the form in March | Restrict analysis to the period it exists, or model the gap | |
| Unknown / refused | Survey "prefer not to say" | Keep as its own category | |
| Lost in processing | Failed join, pipeline error | Fix the pipeline; do not impute | |
| Disguised | 0, -1, 999, N/A, "", 1900-01-01, 1970-01-01 (Unix epoch zero) | Convert to explicit null after confirming meaning |
Then consider the mechanism: if missingness is related to the outcome (e.g., dissatisfied customers skip the satisfaction survey), dropping missing rows biases results. Options, in increasing sophistication: complete-case analysis (state the bias risk); indicator for missingness plus a fill value (for modelling); simple imputation (median/mode — understates variance, use cautiously); model-based or multiple imputation (when missingness is substantial and plausibly random given observed variables). Never impute an identifier, a target variable you are trying to measure, or a value you will report as a fact.
Report the missing rate for every variable you use.
Duplicates
- Exact duplicates (all columns identical) are usually load errors: double ingestion, retried API calls, overlapping exports. Remove, count, and find the cause.
- Key duplicates (same supposedly-unique ID, different content) mean either the key is not really unique (e.g., order ID reused across regions), or there are versions (updates over time — keep the latest by a reliable timestamp, not by file order), or there is a bug.
- Fuzzy duplicates (same real-world entity, different records: "Acme Corp", "ACME Corporation", "Acme Corp." at slightly different addresses). Resolve with normalisation (case, whitespace, punctuation, common suffixes, unicode normalisation) then matching rules (exact on a strong identifier like email or tax ID; fuzzy similarity on names with blocking on another field). Fuzzy matching has false positives — merging two different people is often worse than leaving a duplicate. Review a sample of matches and of near-misses by hand, and keep the mapping table so merges are reversible.
- Event duplicates in tracking data: client retries, double-fired tags. Deduplicate by event ID if one exists; otherwise by (user, event, timestamp within a small window) — and state the window.
Joins that multiply rows
The single most common source of silently wrong totals. Before every join:
- State the expected cardinality: one-to-one, many-to-one, one-to-many.
- Check key uniqueness on the side that should be unique:
SELECT key, COUNT(*) FROM t GROUP BY key HAVING COUNT(*) > 1. - Count rows before and after. A many-to-one join should not change the row count of the many side. A left join should never reduce it.
- Check match rates: what fraction of keys found a partner? Unmatched rows are either expected (new products not yet in the catalogue) or a key-format mismatch (trailing spaces, case, leading zeros, type differences —
'00123'vs123). - Aggregate before joining when combining two one-to-many relationships to the same parent (e.g., orders and support tickets per customer). Joining both to the customer and then summing produces a cross-product.
Many libraries can assert cardinality (e.g., pandas merge(..., validate="many_to_one")); use that when available. In SQL, wrap critical joins with a count check.
Also watch for slowly changing dimensions: joining facts to a dimension table that keeps history (one row per customer per validity period) without filtering on the effective date multiplies rows.
Outliers and impossible values
Separate three things:
- Impossible values — violate a hard rule: negative ages, quantities, or durations; end before start; percentages over 100; dates in the future for past events; birth years before 1900. These are errors; fix if the correction is deterministic, otherwise null and flag.
- Implausible values — possible but suspicious: a 140-year-old customer, a 30-hour session, a $1M consumer order. Investigate a sample; often they are test data, bots, unit errors (cents vs dollars, ms vs s, kg vs g), or sentinel values.
- Genuine extremes — real and important (whale customers, viral posts). Keep them; use robust statistics or report them separately.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/data-cleaning-and-validation/SKILL.md
Popularity
- 7-day trend score
- 0
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/kmaruthi2002/universal-llm-skills/data-cleaning-and-validation)