supabase
Installation
SKILL.md
Supabase
Build a migration-backed, typed Supabase integration with explicit authorization boundaries.
Workflow
- Inspect
supabase/, migrations, generated types, installed Supabase packages/versions, framework/runtime, environment-variable names without printing values, auth/session flow, schemas exposed through the Data API, and existing grants/RLS. - Infer table ownership and tenant relationships from the domain model. Ask only when ownership, collaboration, deletion, retention, or external-auth behavior is ambiguous. Do not add
user_idor four CRUD policies to every table mechanically. - Design keys, foreign keys, constraints, indexes, timestamps, lifecycle/deletion behavior, and server-generated ownership defaults appropriate to each table. Use external provider subject IDs as text unless a local identity mapping is intentionally modeled.
- Create named migrations. Use
supabase migration newor a revieweddb difffor local changes, verify with a local reset/test database, inspectdb push --dry-run, and usedb pushonly when remote deployment is explicitly in scope.migration upis not a substitute for remote deployment. - Secure every exposed object with both Postgres grants and RLS. Scope policies to roles, use indexed predicates, add
with checkfor inserts/updates, review views/functions separately, and set a safesearch_pathonsecurity definerfunctions. - Match auth strategy:
- Supabase Auth: use
auth.uid()/auth.jwt()and current SSR session guidance. - Clerk or another supported third-party provider: configure the native integration, pass the provider token through the client, and use the actual JWT
sub/claims. Do not assume an RLS expression alone configures token verification. - Server administration: use a dedicated server-only client with explicit authorization; never expose secret/service credentials.
- Supabase Auth: use
- For current
@supabase/ssr, create a client per request, use the supported cookiegetAll/setAlladapter, await async framework cookie APIs, and add the required proxy/middleware refresh flow. Do not use legacy single-cookie adapters. - Generate TypeScript types after applying migrations to the target used for generation, then run type checks and update typed queries. Avoid
anyand handle{ data, error }explicitly.