What problem does it solve?
This Skill prevents multi-tenant data leaks and billing bugs by standardizing how you handle JWT-to-DB access, RLS policies, webhook verification/idempotency, and credit ledger correctness in an AI SaaS backend.
Core Features & Use Cases
- Three-client database pattern: Separate anonymous, user-scoped (JWT attached), and service-role admin usage to avoid accidental RLS bypass and cross-tenant exposure.
- RLS policy templates: Owner-only access, public read with owner write, and org/tenant-scoped membership checks designed to be enforced consistently across tables.
- Payment webhook hardening: Verify webhook signatures against the raw request body and enforce replay protection via event deduplication.
- Credit ledger design with refunds: Implement atomic credit deductions, logged usage, and auto-refund when streamed AI responses fail to produce usable output.
- Admin allowlist gating: Use environment-variable admin allowlists and auditable admin mutations to reduce privilege mistakes.
Quick Start
Ask an AI engineer to generate an end-to-end multi-tenant backend plan for your Postgres RLS schema and webhook handlers based on this Skill.