- Home
- Skills
- Data & Databases
- Supabase + Prisma: Secure, Fast Postgres Backends
Works with the AI Agents you already use
Supabase + Prisma: Secure, Fast Postgres Backends
- **Migrations in git**: Supabase CLI or Prisma Migrate (dev vs deploy), one migration owner when using both, expand/contract for risky changes, typed client generation.
Free
Supabase + Prisma: Secure, Fast Postgres Backends
Example session with this skill installed
Set up the database for our Next.js SaaS on Supabase: companies with multiple users, each company only sees its own shipments, admins can delete. We use Prisma for server queries.
- Read your context and instructions
- Compiled the supabase + prisma
Setup detected
Next.js 15 App Router, Supabase (auth + Postgres), Prisma for server queries, deployed on Vercel. Migration owner:
Prisma for tables, SQL migrations (--create-only) for RLS, helper function and triggers.
Schema
orgs,memberships (org_id, user_id, role owner|admin|member),shipments (org_id, reference, status, created_by, timestamps),profiles(created by trigger on signup)unique (org_id, reference), indexes onmemberships(user_id)andshipments(org_id, status, created_at desc)updated_attrigger
Security
create policy "members read shipments" on public.shipments
for select to authenticated using ( (select public.is_member(org_id)) );
create policy "admins delete shipments" on public.shipments
for delete to authenticated using ( exists (select 1 from public.memberships m
where m.org_id = shipments.org_id and m.user_id = (select auth.uid())
and m.role in ('owner','admin')) );
- insert/update policies,
is_member()security definer withsearch_path = '', RLS enabled on all 4 tables.
Prisma bypasses RLS, so lib/data/shipments.ts scopes every query by the verified user's org ids (getUser() server-side), and deleteShipment checks the admin role.
Connections
DATABASE_URL= Supavisor transaction pooler :6543?pgbouncer=true&connection_limit=1DIRECT_URL= :5432 forprisma migrate deploy- Prisma singleton in
lib/prisma.ts; service-role key not used in the client bundle
Verified
supabase db reseton a fresh DB: all migrations apply- RLS tests (pgTAP): member sees own org ✔ · other org 0 rows ✔ · anon 0 rows ✔ · insert into other org rejected ✔ · member delete 0 rows ✔ · admin delete ✔
supabase gen types+prisma generate;tsc --noEmitcleanEXPLAIN ANALYZElist query: index scan, 0.4 ms on 50k rows
You need to
Set DATABASE_URL and DIRECT_URL in Vercel, and run prisma migrate deploy in CI.
Connects securely to your tools. The creator never sees your data.
About this skill
Ship a backend that's secure on day one
The most common Supabase/Prisma mistakes are expensive: tables without RLS, the service-role key in the browser, Prisma silently bypassing RLS, db push against production, exhausted connections on serverless and slow policies. This skill prevents them.
What it does
- Reads your setup first: Supabase only, Prisma only, or both; framework, hosting, existing migrations and client code.
- Schema design: uuid keys, timestamps +
updated_attrigger, explicit foreign keys, constraints, multi-tenantorg_id+ memberships, indexes on every FK and policy column, profile row created on signup. - Migrations in git: Supabase CLI or Prisma Migrate (dev vs deploy), one migration owner when using both, expand/contract for risky changes, typed client generation.
- Security: RLS on every exposed table, per-operation policies with
(select auth.uid()), security-definer helpers with fixedsearch_path, keys and DB URLs server-side only, private storage with policies, input validation. - Clients & connections:
@supabase/ssrwith server-side user verification; Prisma pooled URL (Supavisor,pgbouncer=true) + direct URL for migrations, singleton client; reminder that Prisma bypasses RLS so server code must scope queries. - Performance:
EXPLAIN ANALYZE, composite and partial indexes, no N+1, keyset pagination, advisors. - Verified: migrations on a fresh DB, RLS tests for allowed and denied cases, types regenerated, typecheck green.
Includes
- SKILL.md workflow
- references/schema-rls.md - multi-tenant schema, helper function, RLS policies, triggers and RLS test queries (verified on Postgres 16)
- references/clients.md - env vars, Prisma datasource and singleton, Supabase SSR client, typed queries, common errors and fixes
Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI and any SKILL.md-compatible agent.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Requires local Supabase CLI or Prisma setup. Only supports Postgres. Migration execution must be performed by the user in their terminal.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
This skill has been used 10 times.
Trust & safety
Security scan
Security scan passed 9 days ago
- Free with an Agensi account