Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Supabase + Prisma: Secure, Fast Postgres Backends

    2

    - **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

    10 uses5.0 (1 review)
    Supabase + Prisma: Secure, Fast Postgres Backends

    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 on memberships(user_id) and shipments(org_id, status, created_at desc)
    • updated_at trigger

    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 with search_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=1
    • DIRECT_URL = :5432 for prisma migrate deploy
    • Prisma singleton in lib/prisma.ts; service-role key not used in the client bundle

    Verified

    • supabase db reset on 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 --noEmit clean
    • EXPLAIN ANALYZE list 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_at trigger, explicit foreign keys, constraints, multi-tenant org_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 fixed search_path, keys and DB URLs server-side only, private storage with policies, input validation.
    • Clients & connections: @supabase/ssr with 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

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

    5.0
    1 review
    5
    1
    4
    0
    3
    0
    2
    0
    1
    0

    This skill has been used 10 times.

    Trust & safety

    Security scan

    Security scan passed 9 days ago

    • Free with an Agensi account

    Permissions

    Environment Variables
    Listed9 days ago
    Updated5 days ago

    What's inside

    Frequently Asked Questions

    This skill bridges the gap between Prisma and Supabase by implementing specific patterns for connection pooling (Supavisor) and ensuring Row Level Security (RLS) is correctly enforced, preventing common security leaks found in generic setups.

    It is optimized for use with any LLM-based agent that supports TypeScript development environments, including popular IDE extensions and CLI-based coding assistants.

    You will need an active Supabase project and the Prisma ORM installed; the skill will then guide you through configuring the local CLI and environment variables for seamless migration management.

    The skill provides a complete workflow for schema design, automated RLS policy generation, migration strategies to prevent environment drift, and optimized connection pooling configurations for serverless deployments.

    The skill is designed to handle complex relational schemas, including multi-tenant B2B architectures, nested relational queries, and performance optimization for high-traffic Postgres backends.

    New in Data & Databases

    Free