---
name: tidy-csv
description: Turn a messy CSV into a clean one — drop empty rows, fix headers, trim whitespace, export tidy.
version: 1.0.0
metadata:
  hermes:
    tags: [data, csv, cleanup]
    category: data
---
# Tidy CSV

## When to use
The user hands over a messy CSV ("clean this up", "run tidy-csv on this file"). This is the
canonical **teach-it-once, reuse-forever** skill: a fiddly task solved one time, saved as
procedural memory so it never has to be re-explained.

## Procedure
1. Read the file. Report its shape: rows, columns, and the header row as you read it.
2. Drop fully empty rows and fully empty columns.
3. Normalise headers: trim whitespace, lowercase, replace spaces with underscores. List any renames.
4. Trim leading/trailing whitespace in every cell.
5. Flag (don't silently fix) anything ambiguous: duplicate headers, mixed types in a column, dates in inconsistent formats.
6. Write the result to `<original>-tidy.csv` and show a 5-row preview.

## Pitfalls
- Never overwrite the original — always write a new `-tidy` file.
- Don't drop rows that merely have *some* blanks; only drop rows that are entirely empty.
- Don't reformat values you were not asked to (e.g. don't reorder columns) — flag, ask, then act.

## Verification
A new `-tidy.csv` exists, the original is untouched, the preview shows clean headers and no
empty rows, and every change beyond whitespace/empties was reported to the user first.
