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: GDPR Compliance4---5# GDPR Compliance67## Overview89This 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.1011## Instructions1213### PII Audit14151. Scan database schemas (Prisma, SQL migrations, Sequelize models, TypeORM entities) for PII fields. Flag these patterns:16 - Direct identifiers: `email`, `name`, `full_name`, `phone`, `address`, `ssn`17 - Indirect identifiers: `ip_address`, `device_id`, `geo_*`, `lat`, `lng`, `user_agent`18 - Sensitive data: `date_of_birth`, `gender`, `health_*`, `ethnicity`192. Scan application code for PII in logs: search for `console.log`, `logger.*`, `winston.*` calls that include user objects or request IPs.203. Scan third-party integrations: check for API calls that send user data (analytics, email providers, payment processors, CRMs).214. Output a **Data Flow Inventory** as a markdown table:22 | Data Type | Storage Location | Shared With | Legal Basis | Retention Period |2324### Consent Management25261. Define consent categories:27 - `strictly_necessary` — always active, no consent needed28 - `functional` — preferences, language, UI settings29 - `analytics` — usage tracking, performance monitoring30 - `marketing` — ad targeting, remarketing pixels312. Build a consent banner component that:32 - Blocks all non-necessary scripts until consent is granted33 - Provides granular opt-in/opt-out per category34 - Stores consent in a database table (not just cookies)353. Consent record schema:36 ```37 consent_records: id, user_id, version, strictly_necessary (always true),38 functional (bool), analytics (bool), marketing (bool),39 ip_address_hash, created_at40 ```414. On consent change, fire a `consent_updated` event that other services can listen to for enabling/disabling tracking.4243### Data Subject Requests (DSR)4445Implement three endpoints:4647**Data Export (Right of Access / Portability):**48- Collect all data for the user across all tables where their ID appears.49- Include related records (orders, comments, sessions).50- Return as JSON with a clear structure. Optionally offer CSV.51- Redact any third-party secrets or internal IDs that are not user data.5253**Data Deletion (Right to Erasure):**54- Do NOT immediately delete. Use a 30-day cooling-off queue.55- Send confirmation email with a cancel link.56- After 30 days, either anonymize (replace PII with hashed/null values) or hard-delete.57- Cascade to: logs (redact), sessions (delete), third-party (trigger deletion APIs where available).58- Keep anonymized records for aggregate analytics if needed.5960**Consent History:**61- Return all consent records for the user, ordered by date.62- Include version numbers to show what the user agreed to and when.6364### Retention Policies65661. Define retention periods per data type based on purpose:67 - Session data: 90 days68 - IP addresses: 30 days (anonymize by zeroing last octet)69 - Soft-deleted accounts: 30 days then hard delete70 - Audit logs: 1 year (legal requirement)71 - Marketing data: until consent withdrawn722. Build a scheduled job that runs daily and enforces these policies.733. Always implement dry-run mode first: log what would be affected without deleting.7475### Privacy Policy Generation76771. Use the Data Flow Inventory to auto-generate a privacy policy that lists:78 - What data is collected79 - Why (legal basis for each type)80 - How long it is kept81 - Who it is shared with82 - User rights and how to exercise them832. Use plain language — avoid legal jargon where possible.843. Include placeholder sections for: company name, DPO contact, supervisory authority.8586## Examples8788### Example 1 — PII detection in Prisma schema8990**Input:** "Audit this Prisma schema for PII."91```prisma92model User {93 id String @id @default(uuid())94 email String @unique95 name String96 phone String?97 createdAt DateTime @default(now())98 orders Order[]99}100```101102**Output:**103```104PII fields found in model User:105- email (direct identifier) — requires legal basis, retention policy106- name (direct identifier) — requires legal basis107- phone (direct identifier) — requires legal basis, consider encryption at rest108109Recommendations:1101. Add a `deletedAt` field for soft-delete support1112. Add a `consentVersion` field to track which privacy policy version the user agreed to1123. Consider encrypting `phone` at rest using application-level encryption113```114115### Example 2 — Data deletion cascade116117**Input:** "Build a deletion handler for a user account."118119**Output:**120```js121async function handleDeletionRequest(userId) {122 // 1. Create deletion request record123 await db.deletionRequest.create({124 data: { userId, status: 'pending', expiresAt: addDays(new Date(), 30) }125 });126127 // 2. Send confirmation email with cancel link128 await emailService.send(userId, 'deletion-confirmation', {129 cancelUrl: `${BASE_URL}/api/privacy/cancel-deletion?token=${token}`130 });131132 // 3. After 30 days (triggered by cron job):133 // await db.user.update({ where: { id: userId }, data: {134 // email: `deleted-${hash}@anonymized.local`,135 // name: 'Deleted User', phone: null136 // }});137 // await db.session.deleteMany({ where: { userId } });138 // await analyticsService.deleteUser(userId);139}140```141142## Guidelines143144- **GDPR compliance is not just technical.** Always recommend the client consult a legal professional for their specific jurisdiction.145- **Default to opt-out.** In the EU, analytics and marketing require explicit opt-in. Never pre-check consent boxes.146- **Anonymize over delete when possible.** Anonymized data is no longer personal data and can be kept for analytics.147- **Log every DSR.** Regulators may ask for proof that requests were handled within the 30-day deadline.148- **Test deletion cascades thoroughly.** Missing a single table or third-party integration means non-compliance.