Loading...
Loading...
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.
npx skill4agent add codeminer42/skills privacy-by-design-railsruby .claude/skills/privacy-by-design-rails/scripts/scanner.rb --files <relevant files>references/references/pii-definition.md| Principle | Rails Feature | File |
|---|---|---|
| Log + inspect filtering | | references/log-and-output-protection.md |
| Per-model PII declaration | | references/log-and-output-protection.md |
| Job arg protection (ActiveJob) | | references/log-and-output-protection.md |
| Job arg protection (Sidekiq) | Server middleware + pass IDs only | references/log-and-output-protection.md |
| PII redaction in logs | | references/log-and-output-protection.md |
| IP anonymization | | references/log-and-output-protection.md |
| Error reporter scrubbing | Scrub PII from Sentry/Rollbar/etc. | references/log-and-output-protection.md |
| APM/monitoring scrubbing | Scrub PII from AppSignal/NewRelic/etc. | references/log-and-output-protection.md |
| Data minimization | Strong parameters + serializers | references/data-minimization.md |
| Searchable encryption | | references/encryption.md |
| Non-searchable encryption | | references/encryption.md |
| Password hashing | | references/encryption.md |
| Key rotation | | references/encryption.md |
| Secrets management | | references/secrets-management.md |
| Security auditing | bundler-audit, Brakeman, pdscan | references/secrets-management.md |
| HTTPS enforcement | | references/session-security.md |
| Session security | Signed cookies / Bearer tokens | references/session-security.md |
| Consent management | Immutable append-only audit trail | references/consent-management.md |
| Consent enforcement | Controller concern gating actions | references/consent-management.md |
| Consent-gated exports | | references/consent-management.md |
| Anonymization | Replace PII with | references/anonymization.md |
| Pseudonymization | HMAC hash preserving analytics links | references/pseudonymization.md |
| DSAR workflow | Access / Rectification / Erasure | references/dsar.md |
| Data retention | Solid Queue scheduled jobs | references/data-retention.md |
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| Mistake | Fix |
|---|---|
| Deleting records with dependents for right to erasure | Prefer anonymization when the record has dependents — preserves referential integrity. Some authorities prefer true deletion, so check local requirements |
| Storing consents as a boolean flag | Use immutable append-only records for audit trail |
| Exposing sequential IDs in APIs | Use UUIDs as public identifiers |
| Manual data retention | Automate with Solid Queue scheduled jobs |