agentleFS
Vimalk0703Vimalk0703/shipworthy/skills/security/pii-detection/SKILL.md

pii-detection

Skill6 starsChanged 8 months agoMITView on GitHub

Detect and flag PII (emails, SSNs, credit cards, phone numbers) in code, test fixtures, and logs. Enforce masking before logging and GDPR/CCPA-aware data handling.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never use real PII in tests.

    line 23

≈ “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

PII Detection

PII Patterns to Flag

Any of these in source code, test fixtures, config files, or seed data is a finding:

TypePatternExample
Email\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z]{2,}\bjohn.doe@company.com
SSN\b\d{3}-\d{2}-\d{4}\b123-45-6789
Credit card13-19 digit sequences (validate with Luhn)4111111111111111
Phone\b(\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b(555) 867-5309
IP address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b (in user context)192.168.1.42

Test Fixtures: Use Fake Data

Never use real PII in tests. Use obviously fake values:

// BAD -- looks like real data
const user = { email: "jsmith@gmail.com", ssn: "078-05-1120" };

// GOOD -- clearly synthetic
const user = { email: "test-user@example.com", ssn: "000-00-0000" };

For bulk test data, use libraries like @faker-js/faker with deterministic seeds.

Log Masking Requirements

PII must never reach logs, metrics, or error tracking unmasked.

function maskPII(value: string): string {
  return value
    .replace(/\b\d{3}-\d{2}-\d{4}\b/g, '***-**-****')
    .replace(/\b\d{13,19}\b/g, (m) => '****' + m.slice(-4))
    .replace(/\b[\w.+-]+@[\w.-]+\.\w{2,}\b/g, '****@****');
}

// Apply at the logging boundary, not per-call
logger.info('Processing request', { userId: user.id }); // OK: ID only
logger.info('Processing request', { user });             // BAD: full object

Rules

  1. Log IDs, not objects -- pass userId, not the user record.
  2. Mask at the boundary -- a single log sanitizer, not scattered maskPII calls.
  3. Audit log output -- grep production logs periodically for PII patterns.
  4. Structured logging only -- no string interpolation with user data.

GDPR / CCPA Awareness

  • Purpose limitation -- only collect PII you actually need.
  • Retention policy -- define how long each PII field is kept. Soft-delete is not deletion.
  • Right to deletion -- the system must support purging a user's PII from all stores (DB, caches, logs, backups).
  • Consent tracking -- record what the user consented to and when.
  • Data export -- users can request all data held about them (Article 15 / CCPA right to know).

Data Retention Guidance

Data TypeSuggested Max RetentionNotes
Session tokens24 hoursRotate, don't extend
Access logs with IPs90 daysAnonymize after
Payment card dataDon't storeUse tokenized processor (Stripe, etc.)
User profile PIIUntil account deletion + 30 daysLegal hold exceptions

Code Review Checklist

  • No real PII in test fixtures or seed files
  • Log statements do not include raw user objects
  • PII fields are masked before reaching any logging/error tracking
  • Data retention is defined for any new PII field
  • Deletion/export paths cover the new data

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.