GDPR Compliance
Overview
This skill helps AI agents implement GDPR compliance across web applications. It covers the full lifecycle: auditing where personal data lives, building consent management, handling data subject requests (access, deletion, portability), enforcing retention policies, and generating documentation.
Instructions
PII Audit
- Scan database schemas (Prisma, SQL migrations, Sequelize models, TypeORM entities) for PII fields. Flag these patterns:
- Direct identifiers:
email, name, full_name, phone, address, ssn
- Indirect identifiers:
ip_address, device_id, geo_*, lat, lng, user_agent
- Sensitive data:
date_of_birth, gender, health_*, ethnicity
- Scan application code for PII in logs: search for
console.log, logger.*, winston.* calls that include user objects or request IPs.
- Scan third-party integrations: check for API calls that send user data (analytics, email providers, payment processors, CRMs).
- Output a Data Flow Inventory as a markdown table:
| Data Type | Storage Location | Shared With | Legal Basis | Retention Period |
Consent Management
- Define consent categories:
strictly_necessary — always active, no consent needed
functional — preferences, language, UI settings
analytics — usage tracking, performance monitoring
marketing — ad targeting, remarketing pixels
- Build a consent banner component that:
- Blocks all non-necessary scripts until consent is granted
- Provides granular opt-in/opt-out per category
- Stores consent in a database table (not just cookies)
- Consent record schema:
consent_records: id, user_id, version, strictly_necessary (always true),
functional (bool), analytics (bool), marketing (bool),
ip_address_hash, created_at
- On consent change, fire a
consent_updated event that other services can listen to for enabling/disabling tracking.
Data Subject Requests (DSR)
Implement three endpoints:
Data Export (Right of Access / Portability):
- Collect all data for the user across all tables where their ID appears.
- Include related records (orders, comments, sessions).
- Return as JSON with a clear structure. Optionally offer CSV.
- Redact any third-party secrets or internal IDs that are not user data.
Data Deletion (Right to Erasure):
- Do NOT immediately delete. Use a 30-day cooling-off queue.
- Send confirmation email with a cancel link.
- After 30 days, either anonymize (replace PII with hashed/null values) or hard-delete.
- Cascade to: logs (redact), sessions (delete), third-party (trigger deletion APIs where available).
- Keep anonymized records for aggregate analytics if needed.
Consent History:
- Return all consent records for the user, ordered by date.
- Include version numbers to show what the user agreed to and when.
Retention Policies
- Define retention periods per data type based on purpose:
- Session data: 90 days
- IP addresses: 30 days (anonymize by zeroing last octet)
- Soft-deleted accounts: 30 days then hard delete
- Audit logs: 1 year (legal requirement)
- Marketing data: until consent withdrawn
- Build a scheduled job that runs daily and enforces these policies.
- Always implement dry-run mode first: log what would be affected without deleting.
Privacy Policy Generation
- Use the Data Flow Inventory to auto-generate a privacy policy that lists:
- What data is collected
- Why (legal basis for each type)
- How long it is kept
- Who it is shared with
- User rights and how to exercise them
- Use plain language — avoid legal jargon where possible.
- Include placeholder sections for: company name, DPO contact, supervisory authority.
Examples
Example 1 — PII detection in Prisma schema
Input: "Audit this Prisma schema for PII."
model User {
id String @id @default(uuid())
email String @unique
name String
phone String?
createdAt DateTime @default(now())
orders Order[]
}
Output:
PII fields found in model User:
- email (direct identifier) — requires legal basis, retention policy
- name (direct identifier) — requires legal basis
- phone (direct identifier) — requires legal basis, consider encryption at rest
Recommendations:
1. Add a `deletedAt` field for soft-delete support
2. Add a `consentVersion` field to track which privacy policy version the user agreed to
3. Consider encrypting `phone` at rest using application-level encryption
Example 2 — Data deletion cascade
Input: "Build a deletion handler for a user account."
Output:
async function handleDeletionRequest(userId) {
// 1. Create deletion request record
await db.deletionRequest.create({
data: { userId, status: 'pending', expiresAt: addDays(new Date(), 30) }
});
// 2. Send confirmation email with cancel link
await emailService.send(userId, 'deletion-confirmation', {
cancelUrl: `${BASE_URL}/api/privacy/cancel-deletion?token=${token}`
});
// 3. After 30 days (triggered by cron job):
// await db.user.update({ where: { id: userId }, data: {
// email: `deleted-${hash}@anonymized.local`,
// name: 'Deleted User', phone: null
// }});
// await db.session.deleteMany({ where: { userId } });
// await analyticsService.deleteUser(userId);
}
Guidelines
- GDPR compliance is not just technical. Always recommend the client consult a legal professional for their specific jurisdiction.
- Default to opt-out. In the EU, analytics and marketing require explicit opt-in. Never pre-check consent boxes.
- Anonymize over delete when possible. Anonymized data is no longer personal data and can be kept for analytics.
- Log every DSR. Regulators may ask for proof that requests were handled within the 30-day deadline.
- Test deletion cascades thoroughly. Missing a single table or third-party integration means non-compliance.
1---2name: gdpr-compliance3description: >-4 Automate GDPR and privacy compliance for web applications. Use when someone5 asks to "make the app GDPR compliant", "add cookie consent", "handle data6 deletion requests", "audit PII", "data subject access request", or "privacy7 policy generator". Covers PII auditing, consent management, data subject8 request endpoints, retention policies, and privacy policy generation.9license: Apache-2.010compatibility: "Any web stack. Examples use Node.js/Prisma but patterns apply to any framework."11metadata:12 source: https://skillmd.com/skills/eliferjunior/gdpr-compliance13 author: terminal-skills14 version: "1.0.0"15 category: development16 tags: ["gdpr", "privacy", "compliance", "data-protection"]17---1819# GDPR Compliance2021## Overview2223This skill helps AI agents implement GDPR compliance across web applications. It covers the full lifecycle: auditing where personal data lives, building consent management, handling data subject requests (access, deletion, portability), enforcing retention policies, and generating documentation.2425## Instructions2627### PII Audit28291. Scan database schemas (Prisma, SQL migrations, Sequelize models, TypeORM entities) for PII fields. Flag these patterns:30 - Direct identifiers: `email`, `name`, `full_name`, `phone`, `address`, `ssn`31 - Indirect identifiers: `ip_address`, `device_id`, `geo_*`, `lat`, `lng`, `user_agent`32 - Sensitive data: `date_of_birth`, `gender`, `health_*`, `ethnicity`332. Scan application code for PII in logs: search for `console.log`, `logger.*`, `winston.*` calls that include user objects or request IPs.343. Scan third-party integrations: check for API calls that send user data (analytics, email providers, payment processors, CRMs).354. Output a **Data Flow Inventory** as a markdown table:36 | Data Type | Storage Location | Shared With | Legal Basis | Retention Period |3738### Consent Management39401. Define consent categories:41 - `strictly_necessary` — always active, no consent needed42 - `functional` — preferences, language, UI settings43 - `analytics` — usage tracking, performance monitoring44 - `marketing` — ad targeting, remarketing pixels452. Build a consent banner component that:46 - Blocks all non-necessary scripts until consent is granted47 - Provides granular opt-in/opt-out per category48 - Stores consent in a database table (not just cookies)493. Consent record schema:50 ```51 consent_records: id, user_id, version, strictly_necessary (always true),52 functional (bool), analytics (bool), marketing (bool),53 ip_address_hash, created_at54 ```554. On consent change, fire a `consent_updated` event that other services can listen to for enabling/disabling tracking.5657### Data Subject Requests (DSR)5859Implement three endpoints:6061**Data Export (Right of Access / Portability):**62- Collect all data for the user across all tables where their ID appears.63- Include related records (orders, comments, sessions).64- Return as JSON with a clear structure. Optionally offer CSV.65- Redact any third-party secrets or internal IDs that are not user data.6667**Data Deletion (Right to Erasure):**68- Do NOT immediately delete. Use a 30-day cooling-off queue.69- Send confirmation email with a cancel link.70- After 30 days, either anonymize (replace PII with hashed/null values) or hard-delete.71- Cascade to: logs (redact), sessions (delete), third-party (trigger deletion APIs where available).72- Keep anonymized records for aggregate analytics if needed.7374**Consent History:**75- Return all consent records for the user, ordered by date.76- Include version numbers to show what the user agreed to and when.7778### Retention Policies79801. Define retention periods per data type based on purpose:81 - Session data: 90 days82 - IP addresses: 30 days (anonymize by zeroing last octet)83 - Soft-deleted accounts: 30 days then hard delete84 - Audit logs: 1 year (legal requirement)85 - Marketing data: until consent withdrawn862. Build a scheduled job that runs daily and enforces these policies.873. Always implement dry-run mode first: log what would be affected without deleting.8889### Privacy Policy Generation90911. Use the Data Flow Inventory to auto-generate a privacy policy that lists:92 - What data is collected93 - Why (legal basis for each type)94 - How long it is kept95 - Who it is shared with96 - User rights and how to exercise them972. Use plain language — avoid legal jargon where possible.983. Include placeholder sections for: company name, DPO contact, supervisory authority.99100## Examples101102### Example 1 — PII detection in Prisma schema103104**Input:** "Audit this Prisma schema for PII."105```prisma106model User {107 id String @id @default(uuid())108 email String @unique109 name String110 phone String?111 createdAt DateTime @default(now())112 orders Order[]113}114```115116**Output:**117```118PII fields found in model User:119- email (direct identifier) — requires legal basis, retention policy120- name (direct identifier) — requires legal basis121- phone (direct identifier) — requires legal basis, consider encryption at rest122123Recommendations:1241. Add a `deletedAt` field for soft-delete support1252. Add a `consentVersion` field to track which privacy policy version the user agreed to1263. Consider encrypting `phone` at rest using application-level encryption127```128129### Example 2 — Data deletion cascade130131**Input:** "Build a deletion handler for a user account."132133**Output:**134```js135async function handleDeletionRequest(userId) {136 // 1. Create deletion request record137 await db.deletionRequest.create({138 data: { userId, status: 'pending', expiresAt: addDays(new Date(), 30) }139 });140141 // 2. Send confirmation email with cancel link142 await emailService.send(userId, 'deletion-confirmation', {143 cancelUrl: `${BASE_URL}/api/privacy/cancel-deletion?token=${token}`144 });145146 // 3. After 30 days (triggered by cron job):147 // await db.user.update({ where: { id: userId }, data: {148 // email: `deleted-${hash}@anonymized.local`,149 // name: 'Deleted User', phone: null150 // }});151 // await db.session.deleteMany({ where: { userId } });152 // await analyticsService.deleteUser(userId);153}154```155156## Guidelines157158- **GDPR compliance is not just technical.** Always recommend the client consult a legal professional for their specific jurisdiction.159- **Default to opt-out.** In the EU, analytics and marketing require explicit opt-in. Never pre-check consent boxes.160- **Anonymize over delete when possible.** Anonymized data is no longer personal data and can be kept for analytics.161- **Log every DSR.** Regulators may ask for proof that requests were handled within the 30-day deadline.162- **Test deletion cascades thoroughly.** Missing a single table or third-party integration means non-compliance.