agentleFS
Codeminer42Codeminer42/skills/privacy-by-design-rails/SKILL.md

privacy-by-design-rails

Skill32 starsChanged 8 months agoMITView on GitHub

Use when building Rails features that handle personal data, adding encryption to models, implementing consent flows, building DSAR endpoints, or adding anonymization/pseudonymization. Also use when reviewing code for compliance with privacy laws like GDPR and LGPD, or when asked about privacy-by-design patterns in Rails.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    When generating or reviewing code that handles personal data, run the scanner first: ruby …

    line 13

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

Privacy by Design with Rails 8

When generating or reviewing code that handles personal data, run the scanner first: ruby .claude/skills/privacy-by-design-rails/scripts/scanner.rb --files <relevant files>

For deeper context on any topic, read the relevant reference file from references/.

What counts as PII? Any data that can identify a person directly or indirectly (GDPR Art. 4, LGPD Art. 5, NIST SP 800-122). This includes data that isn't identifying alone but becomes PII when linked to a person — farm names, animal names with known owners, license plates, vehicle VINs, student IDs, property addresses, social media handles, company names of sole proprietors, device IDs linked to accounts, IP addresses. See references/pii-definition.md for the full definition and linkability test. When in doubt, treat it as PII.

Quick Reference

PrincipleRails FeatureFile
Log + inspect filteringconfig.filter_parameters (covers both)references/log-and-output-protection.md
Per-model PII declarationself.filter_attributes (self-documenting)references/log-and-output-protection.md
Job arg protection (ActiveJob)self.log_arguments = false (set in ApplicationJob)references/log-and-output-protection.md
Job arg protection (Sidekiq)Server middleware + pass IDs onlyreferences/log-and-output-protection.md
PII redaction in logslogstop gemreferences/log-and-output-protection.md
IP anonymizationip_anonymizer middlewarereferences/log-and-output-protection.md
Error reporter scrubbingScrub PII from Sentry/Rollbar/etc.references/log-and-output-protection.md
APM/monitoring scrubbingScrub PII from AppSignal/NewRelic/etc.references/log-and-output-protection.md
Data minimizationStrong parameters + serializersreferences/data-minimization.md
Searchable encryptionencrypts :field, deterministic: truereferences/encryption.md
Non-searchable encryptionencrypts :fieldreferences/encryption.md
Password hashinghas_secure_passwordreferences/encryption.md
Key rotationencrypts :field, previous: [...]references/encryption.md
Secrets managementbin/rails credentials:editreferences/secrets-management.md
Security auditingbundler-audit, Brakeman, pdscanreferences/secrets-management.md
HTTPS enforcementconfig.force_ssl = true + HSTSreferences/session-security.md
Session securitySigned cookies / Bearer tokensreferences/session-security.md
Consent managementImmutable append-only audit trailreferences/consent-management.md
Consent enforcementController concern gating actionsreferences/consent-management.md
Consent-gated exportsConsentGatedExportSerializer for processingreferences/consent-management.md
AnonymizationReplace PII with [ANONYMIZED]references/anonymization.md
PseudonymizationHMAC hash preserving analytics linksreferences/pseudonymization.md
DSAR workflowAccess / Rectification / Erasurereferences/dsar.md
Data retentionSolid Queue scheduled jobsreferences/data-retention.md

Putting It All Together — The User Model

class User < ApplicationRecord
  has_secure_password
  has_many :sessions, dependent: :destroy
  has_many :addresses, dependent: :destroy
  has_many :orders, dependent: :restrict_with_error
  has_many :consents, dependent: :destroy
  has_many :data_subject_requests, dependent: :destroy

  include Anonymizable
  include Pseudonymizable
  include DataExportable
  include HasConsent

  encrypts :email_address, deterministic: true, downcase: true
  encrypts :first_name
  encrypts :last_name
  encrypts :phone
  encrypts :date_of_birth

  self.filter_attributes = %i[
    first_name last_name phone date_of_birth
    email_address password_digest
  ]

  enum :role, { customer: 0, admin: 1 }

  anonymizable :first_name, :last_name, :phone, :date_of_birth
  exportable :uuid, :email_address, :first_name, :last_name, :phone, :date_of_birth

  normalizes :email_address, with: ->(e) { e.strip.downcase }
end

Common Mistakes (not caught by scanner)

MistakeFix
Deleting records with dependents for right to erasurePrefer anonymization when the record has dependents — preserves referential integrity. Some authorities prefer true deletion, so check local requirements
Storing consents as a boolean flagUse immutable append-only records for audit trail
Exposing sequential IDs in APIsUse UUIDs as public identifiers
Manual data retentionAutomate with Solid Queue scheduled jobs

External References

Consult these when you need the latest guidance or to verify patterns against official sources. Use WebFetch when needed — don't fetch all of them upfront.

Rails

GDPR

LGPD (Brazil)

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.