Production-Ready Rule
•
supabase/**/*.{sql,ts}, lib/supabase/**/*.{ts,tsx}
Supabase & Postgres RLS Security .cursorrules (.mdc)
Security-focused .cursorrules and .cursor/rules/*.mdc guidelines for Supabase. Mandate Row Level Security (RLS) policies, prevent key leaks, and enforce typed queries.
.cursor/rules/supabase.mdc
---
description: Supabase database security, Row Level Security (RLS), and typed SDK standards
globs: supabase/**/*.{sql,ts}, lib/supabase/**/*.{ts,tsx}
alwaysApply: false
---
# Supabase & Database Security Standards
## Row Level Security (RLS) Discipline
- Every new public schema table MUST explicitly enable RLS:
ALTER TABLE table_name ENABLE ROW LEVEL SECURITY;
- Always define explicit policies for SELECT, INSERT, UPDATE, and DELETE.
- Avoid USING (true) unless public read access is explicitly intentional.
## SDK & Key Management
- NEVER import or reference SUPABASE_SERVICE_ROLE_KEY inside client-side components.
- Always use the typed Supabase client generated from supabase gen types typescript.
⭐
Using this rule in your open-source project? Reference in your README:
https://cursor.pacebowl.com/rules/supabase
Frequently Asked Questions & Implementation Notes
How do these rules protect against data leaks?
Every time the AI creates or modifies a table, it is instructed to append ALTER TABLE ... ENABLE ROW LEVEL SECURITY and generate non-permissive policies.
Does it prevent exposing the service role key?
Yes, service keys are strictly forbidden in client components and restricted to secure server runtimes.