Help us improve
Share bugs, ideas, or general feedback.
From lgpd-skills
Designs a versioned, append-only consent ledger Prisma schema compliant with LGPD Articles 8, 9, and 18. Integrates with Better Auth and other auth libraries for consent capture and revocation.
npx claudepluginhub goul4rt/lgpd-skillsHow this skill is triggered — by the user, by Claude, or both
Slash command
/lgpd-skills:lgpd-consent-schemaThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implementação técnica do consentimento como base legal (Art. 7º, I e Art. 11, I), versionado, auditável e revogável.
Designs a versioned, append-only consent ledger Prisma schema compliant with LGPD Articles 8, 9, and 18. Integrates with Better Auth and other auth libraries for consent capture and revocation.
Guides building GDPR Article 7(1)-compliant consent record-keeping systems with mandatory fields like timestamp, purpose, mechanism, and Kantara Consent Receipt spec for audits.
Embeds privacy protections (data minimization, consent, encryption, retention) into app architecture, databases, and APIs from the start. References GDPR, CCPA, LGPD.
Share bugs, ideas, or general feedback.
Implementação técnica do consentimento como base legal (Art. 7º, I e Art. 11, I), versionado, auditável e revogável.
status=REVOKED.Ver assets/consent-schema.prisma.
Better Auth permite adicionar campos custom e hooks beforeCreate. Use para:
// auth.ts
export const auth = betterAuth({
database: prismaAdapter(db, { provider: "postgresql" }),
user: {
additionalFields: {
dateOfBirth: { type: "date", required: true }, // ECA Digital
parentalConsentRef: { type: "string", required: false },
}
},
hooks: {
user: {
create: {
before: async (user, ctx) => {
// 1. Validar idade (ECA Digital se aplicável)
// 2. Não criar registro de consentimento aqui — fazer em /api/consent/grant
// porque consentimento exige UX dedicada (não pode ser "enterrado" no signup)
return user;
}
}
}
}
});
Princípios:
lgpd-eca-digital-minors).Exemplo de payload do endpoint /api/consent/grant:
{
"userId": "usr_abc123",
"policyVersionId": "policy_v3.2",
"purposes": [
{ "purpose": "marketing_email", "granted": true },
{ "purpose": "personalization", "granted": false },
{ "purpose": "analytics", "granted": true }
],
"evidence": {
"ip": "192.0.2.1",
"userAgent": "...",
"locale": "pt-BR",
"channel": "web",
"uiSnapshotHash": "sha256:..."
}
}
Endpoint /api/consent/revoke:
async function revokeConsent(userId: string, purpose: string) {
// 1. Cria registro com status=REVOKED, revokedAt=now
await prisma.consentRecord.create({
data: {
subjectId: userId,
purpose,
status: "REVOKED",
revokedAt: new Date(),
// ... mesma policyVersionId do consentimento ativo
}
});
// 2. Propaga para operadores (Datadog, Mixpanel, etc.)
await propagateRevocation(userId, purpose);
// 3. Bloqueia tratamentos futuros
await blockFuturePurpose(userId, purpose);
}
// Verificar se titular consentiu uma finalidade específica
export async function hasActiveConsent(
subjectId: string,
purpose: string
): Promise<boolean> {
const latest = await prisma.consentRecord.findFirst({
where: { subjectId, purpose },
orderBy: { grantedAt: "desc" }
});
return latest?.status === "GRANTED";
}
Sempre use este helper antes de tratar dados em finalidade baseada em consentimento.
Toda mudança material no texto da política de privacidade = nova PolicyVersion. Consentimentos antigos não migram automaticamente — você precisa re-coletar para a nova versão se a mudança afetar finalidades existentes (Art. 8º, § 6º).
Cada operação (grant, revoke, propagate) deve gerar entrada em AuditLogEntry (skill lgpd-audit-logging).
## F3 — Consent schema ✓
- Schema implementado em `prisma/schema.prisma`
- Endpoints: POST /api/consent/grant, POST /api/consent/revoke, GET /api/consent
- Better Auth hooks configurados
- Propagação para operadores: {lista}
- Próximo: lgpd-privacy-policy