# Redact before you paste

A small script that blacks out the personal bits of a text or CSV file before it goes into an AI chat, plus a one-page paste-safety checklist. From lesson 01-03 of Distru's No Bullshit AI Course (learnai.distru.com). CC0 1.0: copy it, change it, no credit needed. Version 1.0, September 2026.

- `redact.py`: standard-library Python, no install. Replaces emails, phone numbers, SSN-shaped numbers, street addresses, customer/patient IDs and state license numbers with placeholders; names you list become initials. Writes a redacted copy and a `.map.json` you can use to put the real values back. No AI inside; the same input always gives the same output.
- `sample-input.csv`: four fake wholesale rows to try it on. Every name, number and licence in it is invented.
- `names.txt`: the names in the sample, one per line, for `--names`.
- `paste-safety-checklist.md`: the three piles (paste / redact first / never) as a checklist.

Run it:

    python3 redact.py sample-input.csv --dry-run --names names.txt   # shows counts and a before/after list; writes nothing
    python3 redact.py sample-input.csv --names names.txt             # writes sample-input.redacted.csv and sample-input.map.json
    python3 redact.py --self-test                                    # checks every pattern on canned text

Paste the `.redacted` file. Keep the `.map.json` out of the chat window; it is the key.

What it does not do: find names it was not told about (there is no name detector, only your list), or change what the vendor does with what you paste. Read your tier's data policy; the checklist has the two-minute version. Metrc tags are kept by default because reconciliation needs them; pass `--tags` to shorten them to their last four.

To fit your data, edit the `PATTERNS` table at the top of `redact.py` (add your state's licence prefix, your customer-ID format), then run `--self-test` again. Tested September 2026 with Python 3.9 and 3.12 on the sample file above.
