Gdpr compliance

From TerminalSkills/skills · View interactive version

Gdpr compliance is an AI agent skill from the GitHub repository TerminalSkills/skills. Automate GDPR and privacy compliance for web applications. Use when someone asks to "make the app GDPR compliant", "add cookie consent", "handle data deletion requests", "audit PII", "data subject access request", or "privacy policy generator". Covers PII auditing, consent management, data subject r

How to use this skill

Skill file

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

  1. Scan database schemas (Prisma, SQL migrations, Sequelize models, TypeORM entities) for PII fields. Flag these patterns:
  1. Scan application code for PII in logs: search for console.log, logger.*, winston.* calls that include user objects or request IPs.
  2. Scan third-party integrations: check for API calls that send user data (analytics, email providers, payment processors, CRMs).
  3. Output a Data Flow Inventory as a markdown table:

| Data Type | Storage Location | Shared With | Legal Basis | Retention Period |

Consent Management

  1. Define consent categories:
  1. Build a consent banner component that:
  1. Consent record schema:

```

consent_records: id, user_id, version, strictly_necessary (always true),

functional (bool), analytics (bool), marketing (bool),

ip_address_hash, created_at

```

  1. 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):

Data Deletion (Right to Erasure, Article 17):

Consent History:

Retention Policies

  1. Define retention periods per data type based on purpose:
  1. Build a scheduled job that runs daily and enforces these policies.
  2. Always implement dry-run mode first: log what would be affected without deleting.

Privacy Policy Generation

  1. Use the Data Flow Inventory to auto-generate a privacy policy that lists:
  1. Use plain language — avoid legal jargon where possible.
  2. 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:

import crypto from 'node:crypto';

const COOLING_OFF_MS = 30 * 24 * 60 * 60 * 1000;

async function handleDeletionRequest(userId) {
  // 1. Store only a hash of the cancel token; the raw token goes in the email
  const token = crypto.randomBytes(32).toString('base64url');
  const tokenHash = crypto.createHash('sha256').update(token).digest('hex');
  await db.deletionRequest.create({
    data: { userId, tokenHash, status: 'pending', expiresAt: new Date(Date.now() + COOLING_OFF_MS) }
  });

  // 2. Send confirmation email with cancel link
  await emailService.send(userId, 'deletion-confirmation', {
    cancelUrl: `${process.env.APP_BASE_URL}/privacy/cancel-deletion?token=${token}`
  });
}

// 3. Run daily from a cron job for requests past expiresAt and still pending
async function executeDueDeletions() {
  const due = await db.deletionRequest.findMany({
    where: { status: 'pending', expiresAt: { lte: new Date() } }
  });
  for (const req of due) {
    await db.user.update({ where: { id: req.userId }, data: {
      email: `erased+${crypto.randomUUID()}@invalid.example`, // random tombstone, not a hash
      name: 'Deleted User', phone: null
    }});
    await db.session.deleteMany({ where: { userId: req.userId } });
    await analyticsService.deleteUser(req.userId);
    await db.deletionRequest.update({ where: { id: req.id }, data: { status: 'completed' } });
  }
}

Keep the deletionRequest rows (status, timestamps, no PII) as the DSR log. Only raw tokens belong in the email; the database stores the hash.

Guidelines

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.