Skill: messy CSV cleanup plan
Plan messy CSV cleanup with schema, null handling, and validation before agents rewrite your data.
What to do first

Schema First
- Never let the agent overwrite the raw file. Cleaned outputs and reject logs sit beside it.
- Define the target schema and null policy per column before any transform runs.
- Treat the run as unfinished until you have: cleaned file + validation report + rule log.
Hand a messy CSV to an agent with “just clean this” and it will often succeed at the wrong job: overwrite the only copy, fill nulls with averages you never approved, drop “weird” rows with no reject list, and leave mojibake in names. The sheet looks tidy. Forensic value is gone.
This skill makes the plan the first deliverable: profile → schema → reject/repair rules → transform → validate. The agent may write a script, but it may not invent values or erase the raw file. Works as a chat prompt or a SKILL.md next to your data folder.
Part 1: Profile, then lock the schema
Do not transform the file yet.
1. Profile each column: inferred type, null rate, top odd values (max 5).
2. Propose a target schema (name, type, required?, null policy).
3. For each dirty pattern, propose REJECT or REPAIR with an explicit rule.
4. Stop for my approval. Do not invent fill values unless I approve a rule.
FILE PATH or SAMPLE:
[paste path or first 30 rows]
Part 2: Transform with a validation loop

Validate Loop
Approved schema and rules below. Transform the CSV.
Rules:
1. Read raw; write cleaned beside it (never overwrite raw).
2. Write rejects to reject.csv with reason codes.
3. No silent fills. Approved fill rules only; log every fill.
4. After transform, validate: row counts in/out, null rates, type checks,
sample 10 edge rows.
5. Deliver: cleaned file path, reject.csv, validation report, rule log.
SCHEMA + RULES:
[paste]
Part 3: Silent damage board

Silent Traps
Read the board. Each card is a stop rule the skill must encode.
Save it as a skill file
# Skill: csv-cleanup-plan
## When
- Cleaning messy CSV / spreadsheet imports
## Inputs (ask if missing)
- Raw path, target schema (or "propose"), null policy preferences
## Hard rules
1. Schema + null policy before transforms.
2. Never overwrite raw; write cleaned + reject beside it.
3. No invented fills unless user approved a rule.
4. Validation report required (counts, rejects, samples).
## Steps
1. Profile → propose schema/rules → stop for approve.
2. Transform with reject.csv + fill log.
3. Validate; deliver report + rule log.
## Done when
- Raw preserved; cleaned + reject + validation + rules present.
Test before you trust it
- Duplicate primary keys. Pass: skill demands an explicit dedupe rule before merge.
- “Just make it work.” Pass: still blocks until schema is approved.
- Mixed date formats. Pass: proposes one parse policy; does not silently coerce.
Related: deps audit before merge (same “plan before irreversible change” habit for packages). Skill shape notes: write Cursor skills.
Common mistakes
- Using the old “cleaned” export as the new raw. Keep an immutable raw folder.
- Filling nulls with column means for training data. That leaks future information and invents facts.
- Dropping rejects to hit a row quota. Quotas belong in the report, not in silent filters.
You are done when raw is untouched, every dropped or filled cell has a reason in the log, and the validation report matches the files on disk.
Share