Skip to content
cccskills
FreePublished on GitHub

saas-lgpd-consent-schema

Design the database schema for a versioned, append-only consent ledger that satisfies LGPD Art. 8 (free, informed, unambiguous consent for a specific purpose) and Art. 9 (information rights). Use when user asks for "consent schema", "consent ledger", "schema de consentimento", "Prisma consentimento", "consent management", or is integrating consent capture with Better Auth, NextAuth, Clerk, or any auth library. Outputs a Prisma schema + integration spec. Also produces the structure needed to support DSAR revocation (Art. 18, IX).

The English summary is being prepared. Showing the original description.

Run score Not tested

See how to install

Files included (2)

  • SKILL.md5.3 KB
  • assets/consent-schema.prisma3.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Consent Schema (Prisma + Better Auth)

Interaction Localization Rule: When locale: pt-BR (or user speaks Portuguese), ALL questions (AskUserQuestion / sk_question), confirmation prompts, and selectable options MUST be translated and presented in Brazilian Portuguese (PT-BR). Any English question text or options in this skill are illustrative examples — NEVER display English questions or options to a Portuguese developer. Internal reasoning, code synthesis, tests, and technical documentation MUST remain in English (except Brazilian statutory compliance documents under .lgpd/).

Implementação técnica do consentimento como base legal (Art. 7º, I e Art. 11, I), versionado, auditável e revogável.

Princípios

  1. Append-only — nunca update destrutivo. Revogar = inserir novo registro com status=REVOKED.
  2. Versionado pela política — todo consentimento aponta para uma versão específica do texto consentido.
  3. Específico por finalidade — uma entrada por (titular, finalidade, versão da política).
  4. Evidência forte — hash do payload (timestamp, IP, user-agent, UI snapshot).
  5. Revogação fácil — Art. 8º, § 5º: "O consentimento pode ser revogado a qualquer momento mediante manifestação expressa do titular, por procedimento gratuito e facilitado."

Schema Prisma de referência

Ver assets/consent-schema.prisma.

Integração com Better Auth

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;
        }
      }
    }
  }
});

Captura de consentimento na UI

Princípios:

  • Não pré-marcar caixas (Art. 8º, § 4º — manifestação livre).
  • Granular por finalidade — uma caixa por finalidade, não "concordo com tudo".
  • Linguagem clara — leiga, sem juridiquês.
  • Link para política — versão exata do texto consentido.
  • Idade — se < 18, fluxo ECA Digital (ver saas-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:..."
  }
}

Revogação

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);
}

Helper de query

// 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.

Versionamento de política

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º).

Audit log

Cada operação (grant, revoke, propagate) deve gerar entrada em AuditLogEntry (skill saas-lgpd-audit-logging).

Status update

## 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: saas-lgpd-privacy-policy

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Turn your AI session into an autonomous SaaS and software engineering studio with 49 specialized agents, 74 workflow skills (/saas-*), 28 director gates, and complete architecture across Next.js, FastAPI, Supabase, Tailwind, and Stripe.

The English summary is being prepared. Showing the original description.

Basinfy/Basinfy-SaaS-Studio3Updated Oct 24, 2026

Brownfield audit — do existing artifacts actually work? Numbered migration plan. Unlike /saas-project-stage-detect, checks compliance not existence.

The English summary is being prepared. Showing the original description.

Basinfy/Basinfy-SaaS-Studio3Updated Oct 24, 2026

Create an ADR documenting a technical decision: context, alternatives considered, consequences.

The English summary is being prepared. Showing the original description.

Basinfy/Basinfy-SaaS-Studio3Updated Oct 24, 2026

Traceability matrix mapping PRD requirements to ADRs. Finds gaps, cross-ADR conflicts, stack compatibility. PASS/CONCERNS/NOT ASSESSED/FAIL.

The English summary is being prepared. Showing the original description.

Basinfy/Basinfy-SaaS-Studio3Updated Oct 24, 2026

Audit assets against naming conventions, file size budgets, format standards. Finds orphaned assets, missing references.

The English summary is being prepared. Showing the original description.

Basinfy/Basinfy-SaaS-Studio3Updated Oct 24, 2026

Author per-asset visual specs, SVG dimensions, and generation prompts from PRDs and design tokens. After design tokens.

The English summary is being prepared. Showing the original description.

Basinfy/Basinfy-SaaS-Studio3Updated Oct 24, 2026

See all skills by Basinfy

Report a problem with this skill