pii-sanitize
Detect and redact personally identifiable information (PII) from text files. Each
detected value is replaced with a numbered placeholder like [CREDIT_CARD_1] or
[SSN_2]. All processing is local, zero network calls, Python stdlib only.
Real source repo: agentward-ai/agentward, skill dir agentward-sanitize-skill/
(the openclaw/skills tree URL is an author-namespaced mirror reference). Helper
script lives at agentward-sanitize-skill/scripts/sanitize.py in that repo —
fetch it from there rather than copying it here.
When to use
- User wants to share, paste, log, screenshot, or commit a file that may contain
PII or secrets and asks to clean/redact/sanitize/scrub/anonymize it first.
- Preparing patient notes, support tickets, logs, or reports for an LLM or a
third party while stripping sensitive values.
CRITICAL — PII safety rules (follow these)
- Do NOT read the raw input file directly — it may contain sensitive PII.
- ALWAYS pass
--output FILE so sanitized text is written to disk.
- Only read the OUTPUT file; only show the user the redacted output.
--json and --preview are safe — they never print raw PII to stdout.
- An entity map (raw PII → placeholder) is written to a sidecar
*.entity-map.json only when --output is used. Do NOT read that file.
How to run
Sanitize a file (recommended form):
python3 scripts/sanitize.py patient-notes.txt --output clean.txt
Preview detected categories/offsets without revealing raw values:
python3 scripts/sanitize.py notes.md --preview
JSON summary (no raw PII in stdout):
python3 scripts/sanitize.py report.txt --json --output clean.txt
Limit to specific categories:
python3 scripts/sanitize.py log.txt --categories ssn,credit_card,email --output clean.txt
Supported categories (15)
Financial: credit_card (Luhn-validated), cvv, expiry_date, bank_routing.
Government IDs: ssn, passport, drivers_license.
Credentials: api_key (OpenAI/Anthropic sk-/sk-proj-/sk-svcacct-, GitHub
ghp_, Slack xoxb-/xoxp-, AWS AKIA).
Healthcare/Professional: medical_license, insurance_id.
Contact/Personal: email, phone, ip_address, date_of_birth, address.
Gotchas / accuracy notes
- Many patterns are KEYWORD-ANCHORED to cut false positives: cvv, expiry,
date_of_birth, passport, drivers_license, bank_routing, medical_license,
insurance_id only match when preceded by a label like "CVV:", "DOB:",
"Member ID:". Unlabeled values of these types may be missed.
- SSN excludes invalid area numbers (000, 666, 900-999), group 00, serial 0000.
- Credit cards must pass a Luhn checksum; phone needs 7+ digits; IP octets must
be 0-255 — so some valid-but-odd values can slip through.
- Detection is regex/heuristic, not guaranteed exhaustive. Treat output as a
strong first pass, not a compliance guarantee; still review before release.
- Requires Python 3.11+. No third-party packages.
1---2name: pii-sanitize3description: "Use when asked to redact/sanitize/scrub PII from a file or text before sharing, pasting, logging, or committing — detects credit cards, SSNs, emails, phone numbers, API keys, IP addresses, addresses, DOB, passport/license numbers and replaces each with a numbered placeholder."4version: 1.0.05license: BSL-1.16tags: [pii, sanitize, redact, security, privacy, secrets, gdpr, hipaa, scrub, anonymize]7source: https://github.com/openclaw/skills/tree/main/skills/agentward-ai/sanitize8derived_from: awesomeclaude9prerequisites:10 commands: [python3]11metadata:12 source: https://skillmd.com/skills/aashutosh396/pii-sanitize13---1415# pii-sanitize1617Detect and redact personally identifiable information (PII) from text files. Each18detected value is replaced with a numbered placeholder like `[CREDIT_CARD_1]` or19`[SSN_2]`. All processing is local, zero network calls, Python stdlib only.2021Real source repo: `agentward-ai/agentward`, skill dir `agentward-sanitize-skill/`22(the `openclaw/skills` tree URL is an author-namespaced mirror reference). Helper23script lives at `agentward-sanitize-skill/scripts/sanitize.py` in that repo —24fetch it from there rather than copying it here.2526## When to use27- User wants to share, paste, log, screenshot, or commit a file that may contain28 PII or secrets and asks to clean/redact/sanitize/scrub/anonymize it first.29- Preparing patient notes, support tickets, logs, or reports for an LLM or a30 third party while stripping sensitive values.3132## CRITICAL — PII safety rules (follow these)33- Do NOT read the raw input file directly — it may contain sensitive PII.34- ALWAYS pass `--output FILE` so sanitized text is written to disk.35- Only read the OUTPUT file; only show the user the redacted output.36- `--json` and `--preview` are safe — they never print raw PII to stdout.37- An entity map (raw PII → placeholder) is written to a sidecar38 `*.entity-map.json` only when `--output` is used. Do NOT read that file.3940## How to run4142Sanitize a file (recommended form):43```bash44python3 scripts/sanitize.py patient-notes.txt --output clean.txt45```4647Preview detected categories/offsets without revealing raw values:48```bash49python3 scripts/sanitize.py notes.md --preview50```5152JSON summary (no raw PII in stdout):53```bash54python3 scripts/sanitize.py report.txt --json --output clean.txt55```5657Limit to specific categories:58```bash59python3 scripts/sanitize.py log.txt --categories ssn,credit_card,email --output clean.txt60```6162## Supported categories (15)63Financial: `credit_card` (Luhn-validated), `cvv`, `expiry_date`, `bank_routing`.64Government IDs: `ssn`, `passport`, `drivers_license`.65Credentials: `api_key` (OpenAI/Anthropic `sk-`/`sk-proj-`/`sk-svcacct-`, GitHub66`ghp_`, Slack `xoxb-`/`xoxp-`, AWS `AKIA`).67Healthcare/Professional: `medical_license`, `insurance_id`.68Contact/Personal: `email`, `phone`, `ip_address`, `date_of_birth`, `address`.6970## Gotchas / accuracy notes71- Many patterns are KEYWORD-ANCHORED to cut false positives: cvv, expiry,72 date_of_birth, passport, drivers_license, bank_routing, medical_license,73 insurance_id only match when preceded by a label like "CVV:", "DOB:",74 "Member ID:". Unlabeled values of these types may be missed.75- SSN excludes invalid area numbers (000, 666, 900-999), group 00, serial 0000.76- Credit cards must pass a Luhn checksum; phone needs 7+ digits; IP octets must77 be 0-255 — so some valid-but-odd values can slip through.78- Detection is regex/heuristic, not guaranteed exhaustive. Treat output as a79 strong first pass, not a compliance guarantee; still review before release.80- Requires Python 3.11+. No third-party packages.