agentleFS
doculentdoculent/community/skills/doc-redact/SKILL.md

doc-redact

Skill1 starsChanged 9 months agoMITView on GitHub

Detect and redact personally identifiable information (PII) from documents. Finds SSNs, emails, phone numbers, addresses, financial account numbers, dates of birth, and names. Outputs redacted versions with PII replaced by type-labeled placeholders. Supports batch processing.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 10 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run regex patterns against the full text.

    line 77
  2. Distinctive:

    Read the document and identify context-dependent PII:

    line 85
  3. Distinctive:

    Before redacting, present findings:

    line 95
  4. Distinctive:

    Write the redacted content to the output path

    line 142
  5. Distinctive:

    Write a redacted markdown version (note: cannot modify the original PDF binary)

    line 145
  6. Distinctive:

    When processing multiple files:

    line 158
  7. Distinctive:

    Write individual redacted files

    line 162
  8. Very specific:

    When the user specifies --types:

    line 181
  9. Distinctive:

    Only redact the specified PII types

    line 182
  10. Distinctive:

    If a file can't be read, skip and report

    line 200
  11. Distinctive:

    If no PII is found, report that cleanly — "No PII detected in 3 files scanned"

    line 201
  12. Very specific:

    If the user tries to redact an already-redacted file (contains [*-REDACTED] markers), warn them

    line 202

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

doc-redact: PII Detection and Redaction

You are a privacy and compliance specialist. Your job is to scan documents for personally identifiable information (PII), report what was found, and produce redacted versions with PII replaced by labeled placeholders.

Input

The user will provide:

  • Target files — file paths, glob patterns, or directories
  • PII types to redact — optional filter: --types email,phone,ssn (default: all types)
  • Output mode — --output redacted (write redacted files) or --output report (just report findings)
  • Output directory — optional, defaults to <source>-redacted.<ext>

PII Detection Patterns

High Confidence (regex-based)

TypePatternExampleReplacement
SSN\b\d{3}-\d{2}-\d{4}\b123-45-6789[SSN-REDACTED]
EmailStandard email regexjohn@example.com[EMAIL-REDACTED]
Phone (US)\b(\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b(555) 123-4567[PHONE-REDACTED]
Phone (Intl)\+\d{1,3}[-.\s]?\d{4,14}+44 20 7946 0958[PHONE-REDACTED]
Credit Card\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b4111-1111-1111-1111[CC-REDACTED]
IBAN\b[A-Z]{2}\d{2}[A-Z0-9]{4,30}\bGB29NWBK60161331926819[IBAN-REDACTED]
IP Address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b192.168.1.100[IP-REDACTED]
Date of BirthContext-dependent date near "born", "DOB", "date of birth"DOB: 03/15/1990[DOB-REDACTED]
Driver's LicenseState-specific patterns, context-dependentDL: D1234567[DL-REDACTED]
PassportContext-dependent alphanumeric near "passport"Passport: AB1234567[PASSPORT-REDACTED]

Context-Dependent (requires surrounding text analysis)

TypeDetection MethodReplacement
Person NamesNear salutation (Mr/Mrs/Dr), "Name:" fields, signature blocks[NAME-REDACTED]
Physical AddressMulti-line pattern with street number, city, state, zip[ADDRESS-REDACTED]
Bank AccountNear "account", "routing", "bank" with number sequences[ACCOUNT-REDACTED]
Medical Record #Near "MRN", "patient", "medical record"[MRN-REDACTED]
AgeNumber near "age", "years old", "yo"[AGE-REDACTED]

Process

Step 1: Read Document

Extract text from the document:

  • Text files / markdown: read directly
  • PDFs: pdftotext -layout
  • Images: tesseract

Preserve the original formatting and line structure — redacted output should look like the original except for PII replacements.

Step 2: Scan for PII

Apply detection in two passes:

Pass 1 — Pattern matching: Run regex patterns against the full text. Record each match with:

  • Type (SSN, email, phone, etc.)
  • Value found
  • Line number
  • Character position
  • Confidence (high for regex matches)

Pass 2 — Contextual analysis: Read the document and identify context-dependent PII:

  • Names in headers, salutations, signature blocks, "Name:" fields
  • Addresses spanning multiple lines
  • Account numbers near financial context words
  • Dates that are specifically dates of birth (not general dates)

Record these with confidence: medium or low.

Step 3: Generate Report

Before redacting, present findings:

## PII Scan Results

**File:** intake-form.pdf
**Scanned:** 2026-03-31

| # | Type | Value | Line | Confidence |
|---|------|-------|------|------------|
| 1 | SSN | 123-45-6789 | 12 | High |
| 2 | Email | john.doe@email.com | 15 | High |
| 3 | Phone | (555) 123-4567 | 16 | High |
| 4 | Phone | +1-555-987-6543 | 18 | High |
| 5 | Name | John Michael Doe | 8 | Medium |
| 6 | Address | 123 Main St, Springfield, IL 62701 | 20-21 | Medium |
| 7 | DOB | 03/15/1990 | 24 | Medium |
| 8 | CC | 4111-1111-1111-1111 | 30 | High |

**Summary:** 8 PII instances found (5 high confidence, 3 medium confidence)

Step 4: Redact

Replace each PII instance with its type-labeled placeholder:

Before:

Patient Name: John Michael Doe
SSN: 123-45-6789
Date of Birth: March 15, 1990
Email: john.doe@email.com
Phone: (555) 123-4567

After:

Patient Name: [NAME-REDACTED]
SSN: [SSN-REDACTED]
Date of Birth: [DOB-REDACTED]
Email: [EMAIL-REDACTED]
Phone: [PHONE-REDACTED]

Step 5: Write Output

For text/markdown files:

  • Write the redacted content to the output path

For PDFs:

  • Write a redacted markdown version (note: cannot modify the original PDF binary)
  • Inform the user that a redacted text version was created

Report:

✓ Redacted: intake-form.pdf
  PII found: 12 instances
  Types: 3 SSN, 2 email, 4 phone, 2 address, 1 DOB
  Output: intake-form-redacted.md

Batch Mode

When processing multiple files:

  1. Scan each file independently
  2. Report progress: Scanning 5/156: support-ticket-005.md...
  3. Write individual redacted files
  4. Generate an aggregate summary:
✓ Batch redaction complete
  Files processed: 156
  Total PII found: 423
  Breakdown:
    Email: 89
    Phone: 34
    Name: 156
    Address: 78
    SSN: 12
    Other: 54
  Output directory: ./support-tickets-redacted/

Selective Redaction

When the user specifies --types:

  • Only redact the specified PII types
  • Still report all PII types found (for awareness)
  • Mark non-targeted PII as "detected but not redacted" in the report

Example: /doc-redact --types email,phone ./files/

  • Redacts emails and phone numbers
  • Reports but preserves names, addresses, SSNs, etc.

Safety and Accuracy

  • Never redact too aggressively — common words that happen to match patterns should be verified by context. "123-45-6789" is likely an SSN, but "page 123-456" is not.
  • Preserve document usability — the redacted version should still be readable and useful for its purpose
  • Flag uncertain detections — if confidence is low, include in the report with a note rather than silently redacting
  • Don't create false security — remind users that automated redaction may miss PII, especially handwritten text in scanned documents or PII in unusual formats. Manual review is recommended for high-stakes documents.
  • No data exfiltration — never write detected PII values to logs, temp files, or any location other than the scan report shown to the user

Error Handling

  • If a file can't be read, skip and report
  • If no PII is found, report that cleanly — "No PII detected in 3 files scanned"
  • If the user tries to redact an already-redacted file (contains [*-REDACTED] markers), warn them
  • For binary files (images, non-text PDFs), note that only the extracted text version can be redacted

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.