agentleFS
imMamdouhaboammarimMamdouhaboammar/anti-slop-engineering/skills/privacy-and-data-lineage-gate/SKILL.md

privacy-and-data-lineage-gate

Skill4 starsChanged 31 days agoMITView on GitHub

Enforces Apple Privacy and Meta Data Infrastructure engineering discipline to protect user data from the system itself. Use when designing user data pipelines, processing PII/sensitive customer data, defining database schemas storing personal information, implementing GDPR/CCPA deletion lifecycles, or instrumenting analytics and telemetry sinks — even if they don't explicitly say "privacy gate". Do NOT use for external network DDoS mitigation, routine UI cosmetic styling, or non-user operational infrastructure.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Mandatory retention TTL: Every database table, collection, and cache key storing user data must declare retention_ttl_days ($\le 90$ days …

    line 56
  2. Very specific:

    Explicit purpose binding: Every schema and pipeline must declare its business purpose (AUTHENTICATION, BILLING, LEGAL_AUDIT, …

    line 57
  3. Very specific:

    Zero PII in URL query strings: Never place user emails, names, or tokens in query parameters where they leak into access logs, browser …

    line 60
  4. Distinctive:

    Before creating or approving code handling customer data, subject the design to this matrix:

    line 78
  5. Very specific:

    Distrust of System Logging: If an unhandled exception fires on this route, will logger.error or APM agents dump raw request payloads or …

    line 80
  6. Distinctive:

    Distrust of Immutable Storage: If this user requests account deletion tomorrow, how do we erase this record from Kafka topic partitions, …

    line 81
  7. Distinctive:

    When a durable architectural record is warranted, save a JSON assessment following the Privacy Record Contract and audit it with:

    line 107

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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

Skill: The Privacy & Data Lineage Gate (Apple Privacy & Meta Data Infra)

While external security shields the system from outside adversaries, this gate protects user data from the system itself: zero internal leaks, cryptographic erasure across immutable ledgers, mandatory retention TTLs, and provenance flow control.

Why This Skill Is Needed & Target State

Modern security teams focus on external attackers: firewalls, rate limiters, token-bucket WAFs, and injection guards. Yet over 90% of privacy violations and regulatory fines stem from internal systemic design defects:

  1. Accidental PII logging when developers pass full user objects or unhandled req.body to logging transports (Datadog, CloudWatch, Sentry).
  2. Telemetry leakage where third-party analytics SDKs (Mixpanel, Google Analytics, Facebook Pixel) receive raw emails, phone numbers, or hardware IDs.
  3. The "Soft-Delete Fallacy" where systems set is_deleted = true, leaving user personal data permanently exposed across immutable Kafka partitions, database WALs, Parquet lakehouses, and disaster recovery backups.
  4. Indefinite data retention where tables accumulate high-precision GPS coordinates, raw IPs, and browsing activity for years without an automated retention TTL or business purpose justification.

The target state is Apple Privacy & Meta Data Infrastructure Rigor: all personal identifiers are encapsulated in compiler-enforced tainted types (Redacted<T>), account deletion guarantees instantaneous $O(1)$ cryptographic erasure (crypto-shredding via KMS key-per-subject), every schema mandates an automated retention TTL with explicit purpose binding, and all data flows are mapped within an audited lineage DAG with strictly fenced telemetry egress.


Activation and Boundaries

SituationBehavior
Designing user data storage, database schemas, or caching layersEnforce purpose binding, data minimization, and mandatory retention_ttl_days with automated GC
Building event-driven architectures, Kafka pipelines, or lakehouse tablesEnforce Key-per-Subject Cryptographic Erasure (Crypto-Shredding) for $O(1)$ GDPR Article 17 erasure
Authoring or refactoring code handling PII (emails, phones, IPs, addresses)Wrap sensitive fields in Redacted<T> branded types; ban unredacted toString(), toJSON(), and log calls
Instrumenting analytics, telemetry, crash reporting, or external third-party SDKsRoute all telemetry through a first-party Egress Gateway with differential privacy and strict allowlists
Reviewing PRs that add user data fields or modify deletion lifecyclesAudit data lineage DAG and reject naive soft-delete patterns or unbounded retention tables
External network DDoS mitigation, token buckets, or firewall configurationsDo not activate; delegate to paranoid-principal-architect and security-review
Routine styling tweaks, documentation formatting, or local non-user scriptsDo not activate; use Anti-Slop Engineering BUILD/FIX gates

The Four Absolute Laws

  1. The Internal Threat Axiom (System as Adversary): Code is treated as an active threat to user data. Never rely on developer vigilance, code review vigilance, or central regex log scrubbers. Personal data must be physically impossible to print, serialize, or transmit without an audited unwrap operation.
  2. The Crypto-Shredding Invariant ($O(1)$ Erasure over Immutable Stores): In distributed append-only architectures (Kafka, Redpanda, Iceberg, WALs, S3 snapshots), physical row deletion is an architectural anti-pattern. Every user must have an isolated Data Encryption Key (DEK). User erasure is executed by destroying the DEK from the KMS, instantly rendering all distributed ciphertext unrecoverable in $O(1)$ time.
  3. The Data Minimization & Retention Mandate: If an operation does not require personal data, it must not be collected. If an operation requires age verification, collect boolean is_over_21, never date of birth. Any table, cache, or message queue storing user data without an explicit purpose binding and automated retention TTL is rejected at the CI gate.
  4. The Provenance & Fenced Egress Law: Every byte of personal data must be traceable across a Directed Acyclic Graph (DAG) from ingestion to cold storage. Direct outbound connections from clients or microservices to third-party analytics are strictly prohibited; all telemetry traverses an egress gateway that strips PII and applies local differential privacy ($\epsilon \le 1.0$).

Invariant Rules

  1. Tainted PII Types everywhere. Wrap emails, phone numbers, IP addresses, physical locations, and national IDs in nominal branded types and Redacted<T> containers.
  2. Ban unredacted serialization. Override toString(), toJSON(), and runtime inspection hooks ([util.inspect.custom]) to output [REDACTED] by default.
  3. Audited unwrapping only. The underlying sensitive value can only be accessed via an explicit .reveal(auditContext) method requiring an actor ID, correlation ID, and authorized business reason.
  4. Crypto-shredding for immutable ledgers. Store user data in event streams and lakehouses encrypted with a user-specific DEK (AES-256-GCM or XChaCha20-Poly1305). User deletion shreds the key in KMS within $\le 5,000\text{ ms}$.
  5. No naive soft-deletes. Setting is_deleted = true without cryptographic shredding or physical storage purging is a blocker defect under GDPR Article 17.
  6. Mandatory retention TTL. Every database table, collection, and cache key storing user data must declare retention_ttl_days ($\le 90$ days default, $\le 730$ days maximum) backed by an automated partition drop cron or TTL index.
  7. Explicit purpose binding. Every schema and pipeline must declare its business purpose (AUTHENTICATION, BILLING, LEGAL_AUDIT, SECURITY_FRAUD_PREVENTION, ANALYTICS_OPT_IN). Cross-purpose joins are rejected at the query admission gate.
  8. Differential privacy on telemetry. Numeric metrics derived from user behavior must inject Laplace/Gaussian perturbation noise with privacy budget $\epsilon \le 1.0$.
  9. Coarse attribute truncation. Truncate IPv4 to /24, IPv6 to /48, and GPS coordinates to coarse geohash ($\ge 20\text{ km}$ precision) before persistence or analytics logging.
  10. Zero PII in URL query strings. Never place user emails, names, or tokens in query parameters where they leak into access logs, browser history, and Referer headers.

Execution Router

Task ShapePrimary WorkflowReference Contract
Designing a new user data pipeline, database schema, or lakehouseArchitect Privacy SystemData Minimization & TTL
Implementing domain entities, DTOs, or models handling sensitive PIIImplement Tainted TypesTainted PII Types
Implementing GDPR Right-to-be-Forgotten or account deletion lifecyclesVerify Cryptographic ErasureCryptographic Erasure
Auditing data flows, event topics, or third-party telemetry integrationsAudit Data LineageLineage & Flow Graphs
Auditing an architectural compliance recordRecord Contractscripts/privacy_guard.py

Mandatory Pre-Execution Privacy Matrix

Before creating or approving code handling customer data, subject the design to this matrix:

  • Distrust of System Logging: If an unhandled exception fires on this route, will logger.error or APM agents dump raw request payloads or personal attributes into Datadog, Sentry, or CloudWatch?
  • Distrust of Immutable Storage: If this user requests account deletion tomorrow, how do we erase this record from Kafka topic partitions, database WAL logs, Parquet files, and S3 glacier backups without rewriting petabytes of storage?
  • Distrust of Retention: Why does this table need to keep this data indefinitely? What automated cron or TTL mechanism purges records once their business purpose expires?
  • Distrust of Third-Party Sinks: Are third-party analytics libraries (Mixpanel, Google, AppsFlyer) receiving raw emails, device UDIDs, or unmasked IPs? Is telemetry routed through an authorized egress gateway?
  • Distrust of Granularity: Did we collect an exact birthdate when a boolean is_over_21 suffices? Did we store 6-decimal GPS coordinates when a city or coarse geohash is enough?

Prohibited Anti-Patterns (Instant Rejection List)

  1. The Soft-Delete Fallacy: Marking database rows with is_deleted = true or deleted_at = NOW() and claiming GDPR erasure compliance while PII remains plaintext in backups and data lakes.
  2. Logging req.body or Unredacted Error Objects: Passing full request payloads or entities containing personal information directly into console.log or logging libraries.
  3. The SHA-256 Telemetry Hash Illusion: Passing SHA-256 hashed emails to third-party ad or tracking networks without per-user secret salting (easily inverted via rainbow tables).
  4. Indefinite Table Retention: Creating database schemas or cache stores holding user identifiers without an explicit retention_ttl_days and automated GC pipeline.
  5. URL Query Parameter PII: Transmitting user emails, telephone numbers, or authentication tokens inside URL query strings (?email=...).
  6. Centralized Regex Scrubber Reliance: Depending solely on centralized regex scrubbing at the log forwarder (Fluentd/Logstash) rather than enforcing type-level redaction at the domain boundary.

Required Output & Review Workflow

Structure all architectural designs, code reviews, and implementations through this 3-phase discipline:

  1. Privacy & Lineage Pre-Mortem: Bullet out the top 3 internal leak vectors, unencrypted immutable stores, and unneeded data attributes.
  2. Hardened Privacy Implementation: Emit production-grade code with tainted types, Redacted<T> wrappers, purpose bindings, automated TTLs, and crypto-shredding interfaces.
  3. Adversarial Erasure & Leak Verification: Provide tests verifying that logging prints [REDACTED], telemetry egress strips PII, and KMS key destruction renders historical ciphertext permanently undecryptable.

When a durable architectural record is warranted, save a JSON assessment following the Privacy Record Contract and audit it with:

npx anti-slop-engineering privacy audit <record.json> --json
# Or scan source code directly for privacy hazards:
npx anti-slop-engineering privacy audit <record.json> --source <source_file> --json

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.