跳到正文
cccskills
免费在 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).

中文简介正在准备中。当前显示原文说明。

实测评分 未实测

查看安装方法

包含的文件(2)

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

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

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.

中文简介正在准备中。当前显示原文说明。

Basinfy/Basinfy-SaaS-Studio32026年10月24日 更新

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

中文简介正在准备中。当前显示原文说明。

Basinfy/Basinfy-SaaS-Studio32026年10月24日 更新

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

中文简介正在准备中。当前显示原文说明。

Basinfy/Basinfy-SaaS-Studio32026年10月24日 更新

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

中文简介正在准备中。当前显示原文说明。

Basinfy/Basinfy-SaaS-Studio32026年10月24日 更新

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

中文简介正在准备中。当前显示原文说明。

Basinfy/Basinfy-SaaS-Studio32026年10月24日 更新

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

中文简介正在准备中。当前显示原文说明。

Basinfy/Basinfy-SaaS-Studio32026年10月24日 更新

查看 Basinfy 的全部技能

报告此技能的问题