Supabase Fullstack Skill
Goal
Help the user build and maintain Supabase-backed applications safely and consistently across:
- Edge Functions
- SQL schema and migrations
- Auth
- Row Level Security (RLS)
- Database functions / triggers
- Local development and deployment
The output must be production-minded, secure by default, and aligned with Supabase workflows.
When to Use
Use this skill when the task involves any of the following:
- Creating or editing a Supabase Edge Function
- Writing SQL migrations or schema updates
- Designing tables, indexes, constraints, or Postgres functions
- Setting up Supabase Auth flows
- Writing or reviewing RLS policies
- Connecting Edge Functions to Supabase
- Using the Supabase CLI for local development, testing, linking, pushing, or deployment
- Debugging auth, policy, migration, or Edge Function issues
Core Philosophy
- Prefer secure by default designs.
- Prefer migrations and versioned SQL over ad-hoc dashboard-only changes.
- Prefer RLS + JWT-aware access control over trusting the client.
- Prefer small focused Edge Functions over large monolith handlers.
- Prefer least privilege:
- Use
anon access only for client-safe flows.
- Use
service_role only in trusted server environments like Edge Functions when required.
- Keep logic in the right layer:
- SQL for constraints, data integrity, policies, and database-side logic
- Edge Functions for orchestration, webhooks, secret use, and third-party integrations
- Auth for identity and session handling
- Always think about deployability, rollback, and maintainability.
Required Working Style
1. First classify the task
Before writing code, decide whether the user’s request belongs mainly to:
- Edge Function
- SQL / migration
- Auth
- RLS / policy
- Database function / trigger
- Full-stack Supabase flow
If the request spans multiple areas, design the solution in layers.
2. Use the right implementation layer
- Put schema changes in SQL migration files.
- Put access control in RLS policies, not just frontend checks.
- Put third-party API calls and secret-bearing logic in Edge Functions.
- Put reusable DB-side logic in Postgres functions when appropriate.
3. Keep output structured
When responding, use this order unless the user asks otherwise:
- What is being built
- Recommended Supabase architecture
- Files to create or edit
- SQL / Edge Function / Auth code
- Security notes
- Local test steps
- Deploy steps
Edge Functions Rules
When working on Edge Functions:
Assume Supabase Edge Functions are the correct place for:
- webhooks
- server-side API integrations
- secret usage
- privileged server-side orchestration
- scheduled or event-driven logic if applicable
Default to TypeScript unless the workspace clearly uses JavaScript.
Keep functions small and focused:
- validate input
- derive auth context
- run the minimum DB operations needed
- return explicit status codes and JSON
If a function needs Supabase access:
- use environment-provided project values
- be careful with
SUPABASE_SERVICE_ROLE_KEY
- never suggest exposing service role keys to the browser
If user auth is required:
- extract and forward the bearer token where appropriate
- distinguish between user-context operations and admin-context operations
Prefer deterministic error handling:
- check request method
- validate body/query params
- return descriptive but safe errors
When secrets are needed:
- use environment variables
- never hardcode secrets in code samples
SQL and Migration Rules
When writing SQL:
- Prefer migration-ready SQL.
- Use explicit table names, foreign keys, indexes, and constraints.
- Use
snake_case names for tables, columns, indexes, and functions.
- Include
created_at and updated_at where appropriate.
- Use
gen_random_uuid() or project-consistent IDs if suitable.
- Add indexes for:
- foreign keys
- common filters
- unique lookups
- Avoid destructive statements unless explicitly requested.
- If changing existing schema:
- preserve backward compatibility where possible
- note migration risks
- mention data backfill requirements if relevant
- When writing database functions:
- define security context carefully
- explain whether
security definer is appropriate
- avoid unsafe privilege escalation
Auth Rules
When working with Supabase Auth:
Clarify which auth mode is being used if the request implies it:
- email/password
- magic link / OTP
- OAuth
- anonymous / guest
- server-side session usage
Distinguish clearly between:
- client auth flow
- server auth verification
- admin operations
If access depends on a signed-in user:
- use JWT-aware logic
- design tables and RLS around
auth.uid()
Never recommend trusting user identity from raw client input.
For user profile patterns:
- keep auth identity in Auth
- keep app profile data in a separate table if needed
- link profile rows to
auth.users safely
RLS and Policy Rules
When writing policies:
- Default to RLS enabled for user-facing tables.
- Use
auth.uid()-based policies where user ownership is intended.
- Separate policies by action:
- select
- insert
- update
- delete
- Keep policies readable and explicit.
- Explain whether the policy is:
- owner-only
- team-based
- public read
- admin-only
- If using service role in Edge Functions, explain that it bypasses RLS and must be used carefully.
- If the user asks for “public access,” still propose the narrowest safe version.
Full Solution Pattern
For full-stack Supabase features, design using this template:
A. Data model
- tables
- relationships
- constraints
- indexes
B. Access model
- who can read
- who can insert
- who can update
- who can delete
C. Auth model
- how the user signs in
- how identity is represented
- how auth maps to app data
D. Backend orchestration
- whether an Edge Function is needed
- which secrets or external APIs are involved
- whether service role is needed
E. Deployment/testing plan
- local development steps
- migration application
- function deployment
- post-deploy checks
Debugging Procedure
When troubleshooting Supabase issues:
Identify the failure area:
- SQL syntax / migration
- policy denial
- auth/session issue
- function runtime issue
- deployment/config issue
Check assumptions in this order:
- schema exists
- RLS state is correct
- policy matches the action
- auth token/session is present
- environment variables are configured
- function is deployed and invoked correctly
If the problem is permission-related:
- inspect whether request is using anon, user JWT, or service role
- inspect policy conditions
- inspect ownership/team logic
If the problem is Edge Function-related:
- inspect request shape
- inspect secrets
- inspect Supabase client initialization
- inspect whether the function should run as user-context or admin-context
Output Requirements
Whenever useful, provide:
- file paths
- migration filenames
- example SQL
- example TypeScript
- policy snippets
- local test commands
- deployment commands
If the task is broad, split into:
- MVP version
- production-hardening notes
Constraints
- Never expose secrets in client-side code.
- Never place
service_role keys in the browser.
- Do not disable RLS as a shortcut unless the user explicitly wants a temporary debugging step, and even then warn clearly.
- Do not use vague placeholders when a concrete implementation can be inferred.
- Do not push business authorization entirely into frontend code.
- Do not create oversized all-purpose Edge Functions when smaller functions are better.
- Do not recommend dashboard-only manual changes if the user is working in version-controlled code.
Preferred Commands and Workflows
When the user needs operational steps, prefer version-controlled local workflows using the Supabase CLI:
- initialize local project
- start local stack
- create migrations
- serve/test functions locally
- link project
- push migrations
- deploy functions
Examples
Example 1
User: "Create a Supabase Edge Function that receives a Stripe webhook and writes to the database."
Expected approach:
- recommend Edge Function
- verify webhook signature using secret
- use trusted server-side Supabase client
- write minimal DB changes
- explain local env vars and deploy steps
Example 2
User: "Make a tasks table where users can only manage their own tasks."
Expected approach:
- create migration SQL
- enable RLS
- create owner-based select/insert/update/delete policies using
auth.uid()
- mention required auth assumptions
Example 3
User: "Add admin-only access to approve user submissions."
Expected approach:
- define admin model clearly
- avoid trusting frontend role flags
- use SQL policy or Edge Function strategy depending on architecture
- explain tradeoffs
Example 4
User: "Why does my insert work in an Edge Function but fail in the app?"
Expected approach:
- explain likely difference between service-role execution and user JWT/RLS
- compare the two access contexts
- inspect policy logic
1---2name: supabase-fullstack3description: Use this skill when the user is working with Supabase and needs help with Edge Functions, SQL schema or migrations, Auth, Row Level Security, database functions, local CLI workflows, or deployment. Use it for building features, reviewing Supabase code, creating migrations, writing policies, implementing auth-aware server logic, and debugging full Supabase app flows.4---56# Supabase Fullstack Skill78## Goal9Help the user build and maintain Supabase-backed applications safely and consistently across:10- Edge Functions11- SQL schema and migrations12- Auth13- Row Level Security (RLS)14- Database functions / triggers15- Local development and deployment1617The output must be production-minded, secure by default, and aligned with Supabase workflows.1819---2021## When to Use22Use this skill when the task involves any of the following:23- Creating or editing a Supabase Edge Function24- Writing SQL migrations or schema updates25- Designing tables, indexes, constraints, or Postgres functions26- Setting up Supabase Auth flows27- Writing or reviewing RLS policies28- Connecting Edge Functions to Supabase29- Using the Supabase CLI for local development, testing, linking, pushing, or deployment30- Debugging auth, policy, migration, or Edge Function issues3132---3334## Core Philosophy351. Prefer **secure by default** designs.362. Prefer **migrations and versioned SQL** over ad-hoc dashboard-only changes.373. Prefer **RLS + JWT-aware access control** over trusting the client.384. Prefer **small focused Edge Functions** over large monolith handlers.395. Prefer **least privilege**:40 - Use `anon` access only for client-safe flows.41 - Use `service_role` only in trusted server environments like Edge Functions when required.426. Keep logic in the **right layer**:43 - SQL for constraints, data integrity, policies, and database-side logic44 - Edge Functions for orchestration, webhooks, secret use, and third-party integrations45 - Auth for identity and session handling467. Always think about deployability, rollback, and maintainability.4748---4950## Required Working Style5152### 1. First classify the task53Before writing code, decide whether the user’s request belongs mainly to:54- **Edge Function**55- **SQL / migration**56- **Auth**57- **RLS / policy**58- **Database function / trigger**59- **Full-stack Supabase flow**6061If the request spans multiple areas, design the solution in layers.6263### 2. Use the right implementation layer64- Put schema changes in SQL migration files.65- Put access control in RLS policies, not just frontend checks.66- Put third-party API calls and secret-bearing logic in Edge Functions.67- Put reusable DB-side logic in Postgres functions when appropriate.6869### 3. Keep output structured70When responding, use this order unless the user asks otherwise:711. What is being built722. Recommended Supabase architecture733. Files to create or edit744. SQL / Edge Function / Auth code755. Security notes766. Local test steps777. Deploy steps7879---8081## Edge Functions Rules82When working on Edge Functions:83841. Assume Supabase Edge Functions are the correct place for:85 - webhooks86 - server-side API integrations87 - secret usage88 - privileged server-side orchestration89 - scheduled or event-driven logic if applicable90912. Default to TypeScript unless the workspace clearly uses JavaScript.92933. Keep functions small and focused:94 - validate input95 - derive auth context96 - run the minimum DB operations needed97 - return explicit status codes and JSON98994. If a function needs Supabase access:100 - use environment-provided project values101 - be careful with `SUPABASE_SERVICE_ROLE_KEY`102 - never suggest exposing service role keys to the browser1031045. If user auth is required:105 - extract and forward the bearer token where appropriate106 - distinguish between user-context operations and admin-context operations1071086. Prefer deterministic error handling:109 - check request method110 - validate body/query params111 - return descriptive but safe errors1121137. When secrets are needed:114 - use environment variables115 - never hardcode secrets in code samples116117---118119## SQL and Migration Rules120When writing SQL:1211221. Prefer migration-ready SQL.1232. Use explicit table names, foreign keys, indexes, and constraints.1243. Use `snake_case` names for tables, columns, indexes, and functions.1254. Include `created_at` and `updated_at` where appropriate.1265. Use `gen_random_uuid()` or project-consistent IDs if suitable.1276. Add indexes for:128 - foreign keys129 - common filters130 - unique lookups1317. Avoid destructive statements unless explicitly requested.1328. If changing existing schema:133 - preserve backward compatibility where possible134 - note migration risks135 - mention data backfill requirements if relevant1369. When writing database functions:137 - define security context carefully138 - explain whether `security definer` is appropriate139 - avoid unsafe privilege escalation140141---142143## Auth Rules144When working with Supabase Auth:1451461. Clarify which auth mode is being used if the request implies it:147 - email/password148 - magic link / OTP149 - OAuth150 - anonymous / guest151 - server-side session usage1521532. Distinguish clearly between:154 - client auth flow155 - server auth verification156 - admin operations1571583. If access depends on a signed-in user:159 - use JWT-aware logic160 - design tables and RLS around `auth.uid()`1611624. Never recommend trusting user identity from raw client input.1631645. For user profile patterns:165 - keep auth identity in Auth166 - keep app profile data in a separate table if needed167 - link profile rows to `auth.users` safely168169---170171## RLS and Policy Rules172When writing policies:1731741. Default to **RLS enabled** for user-facing tables.1752. Use `auth.uid()`-based policies where user ownership is intended.1763. Separate policies by action:177 - select178 - insert179 - update180 - delete1814. Keep policies readable and explicit.1825. Explain whether the policy is:183 - owner-only184 - team-based185 - public read186 - admin-only1876. If using service role in Edge Functions, explain that it bypasses RLS and must be used carefully.1887. If the user asks for “public access,” still propose the narrowest safe version.189190---191192## Full Solution Pattern193For full-stack Supabase features, design using this template:194195### A. Data model196- tables197- relationships198- constraints199- indexes200201### B. Access model202- who can read203- who can insert204- who can update205- who can delete206207### C. Auth model208- how the user signs in209- how identity is represented210- how auth maps to app data211212### D. Backend orchestration213- whether an Edge Function is needed214- which secrets or external APIs are involved215- whether service role is needed216217### E. Deployment/testing plan218- local development steps219- migration application220- function deployment221- post-deploy checks222223---224225## Debugging Procedure226When troubleshooting Supabase issues:2272281. Identify the failure area:229 - SQL syntax / migration230 - policy denial231 - auth/session issue232 - function runtime issue233 - deployment/config issue2342352. Check assumptions in this order:236 - schema exists237 - RLS state is correct238 - policy matches the action239 - auth token/session is present240 - environment variables are configured241 - function is deployed and invoked correctly2422433. If the problem is permission-related:244 - inspect whether request is using anon, user JWT, or service role245 - inspect policy conditions246 - inspect ownership/team logic2472484. If the problem is Edge Function-related:249 - inspect request shape250 - inspect secrets251 - inspect Supabase client initialization252 - inspect whether the function should run as user-context or admin-context253254---255256## Output Requirements257Whenever useful, provide:258- file paths259- migration filenames260- example SQL261- example TypeScript262- policy snippets263- local test commands264- deployment commands265266If the task is broad, split into:267- MVP version268- production-hardening notes269270---271272## Constraints273- Never expose secrets in client-side code.274- Never place `service_role` keys in the browser.275- Do not disable RLS as a shortcut unless the user explicitly wants a temporary debugging step, and even then warn clearly.276- Do not use vague placeholders when a concrete implementation can be inferred.277- Do not push business authorization entirely into frontend code.278- Do not create oversized all-purpose Edge Functions when smaller functions are better.279- Do not recommend dashboard-only manual changes if the user is working in version-controlled code.280281---282283## Preferred Commands and Workflows284When the user needs operational steps, prefer version-controlled local workflows using the Supabase CLI:285- initialize local project286- start local stack287- create migrations288- serve/test functions locally289- link project290- push migrations291- deploy functions292293---294295## Examples296297### Example 1298User: "Create a Supabase Edge Function that receives a Stripe webhook and writes to the database."299300Expected approach:301- recommend Edge Function302- verify webhook signature using secret303- use trusted server-side Supabase client304- write minimal DB changes305- explain local env vars and deploy steps306307### Example 2308User: "Make a tasks table where users can only manage their own tasks."309310Expected approach:311- create migration SQL312- enable RLS313- create owner-based select/insert/update/delete policies using `auth.uid()`314- mention required auth assumptions315316### Example 3317User: "Add admin-only access to approve user submissions."318319Expected approach:320- define admin model clearly321- avoid trusting frontend role flags322- use SQL policy or Edge Function strategy depending on architecture323- explain tradeoffs324325### Example 4326User: "Why does my insert work in an Edge Function but fail in the app?"327328Expected approach:329- explain likely difference between service-role execution and user JWT/RLS330- compare the two access contexts331- inspect policy logic