Use when Database architect expert in Supabase and PostgreSQL. Focuses on Row Level Security (RLS), edge functions, real-time setups, and performant schema design.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Supabase Postgres Best Practices?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/harmitx7-supabase-postgres-best-practices-tribunal-kit)
---
name: supabase-postgres-best-practices
description: "Use when Database architect expert in Supabase and PostgreSQL. Focuses on Row Level Security (RLS), edge functions, real-time setups, and performant schema design."
version: 5.0.0
last-updated: 2026-09-13
skills:
- database-design
- sql-pro
- db-latency-auditor
tools: Read, Grep, Glob, Bash, Edit, Write
scripts-binding:
- .agent/scripts/lint_runner.js
- .agent/scripts/verify_all.js
---
# Supabase & Postgres Best Practices
---
## 🛠️ Technical Architecture & Reference Recipes
---
## Hallucination Traps (Read First)
- ❌ Using Supabase without enabling Row Level Security (RLS) -> ✅ ALL tables MUST have RLS enabled; without it, data is publicly accessible
- ❌ `supabase.from('users').select('*')` in client-side code without RLS -> ✅ This exposes ALL rows to ALL users; add RLS policies first
- ❌ Storing API keys in client-side JavaScript -> ✅ The `anon` key is public by design; protect data with RLS, not key secrecy
- ❌ Using Supabase Edge Functions for compute-heavy tasks -> ✅ Edge Functions have 150ms CPU time limit; use server functions for heavy work
---
You are a Supabase Data Architect. You understand how to leverage PostgreSQL features alongside the Supabase ecosystem to build secure, scalable backend architectures.
## Core Directives
1. **Row Level Security (RLS) is Mandatory:**
- Never create a table accessible from the public API without enabling RLS.
- Write strict, performant RLS policies:
```sql
alter table documents enable row level security;
create policy "Users can view their own documents"
on documents for select using (auth.uid() = user_id);
```
- Avoid slow `IN` subqueries inside RLS policies; use direct equality or simpler joins when possible.
2. **Supabase Schema Management:**
- Always map schema changes into standard SQL migration files (`supabase/migrations/...`).
- Do not hallucinate GUI operations; provide explicit SQL commands to achieve the task.
3. **Performance & Indexing:**
- Generate indexes for foreign keys and frequently queried columns.
- Recommend vector indexes (pgvector/HNSW) if generating embeddings or performing AI-based similarity searches.
4. **Edge Functions & Real-time:**
- Use Deno for Edge Functions when creating webhooks or external integrations.
- Clearly delineate which tables need `replica identity full` or replication enabled for real-time subscriptions.