Free · MIT · Cursor · Claude Code · Windsurf

Supabase security rules for your AI

AI coding tools scaffold Supabase fast — and ship tables with no RLS, using (true) policies, or the service_role key in the frontend. Drop these rules into your agent and it defaults to the secure pattern — rules are advisory, so still verify (below). Especially now: on Oct 30, 2026 new Supabase tables stop being exposed to the Data API without an explicit grant.

THE RULES

When the agent creates or changes a table in a Supabase public schema, it must do all of this in the same migration:

  1. Enable RLS: alter table public.<table> enable row level security;
  2. A policy per operation, scoped to the user (not just a role): SELECT/DELETE use using (user_id = (select auth.uid())); INSERT uses with check (...); UPDATE needs both. For team data, scope by membership.
  3. Grant explicitly (new tables aren't auto-exposed after Oct 30): grant select, insert, update, delete on public.<table> to authenticated; — grant anon only for genuinely public data. For a serial id the API inserts into, also grant the sequence.

Never:

The anon key is safe in the browser only because RLS limits it — it's not a secret. Full text and every format: the repo.

Install

Pick the file your tool reads — or just drop AGENTS.md, which Cursor, Windsurf and Claude Code all read. Commit it so your whole team's agents share the rules.

curl -o AGENTS.md https://raw.githubusercontent.com/mateuszingano/supabase-security-rules/main/AGENTS.md
Any (recommended)AGENTS.md at the repo root
Cursor.cursor/rules/supabase-security.mdc
Claude CodeCLAUDE.md (or append to yours)
Windsurf.windsurf/rules/supabase-security.md
Older Cursor / Windsurf.cursorrules / .windsurfrules

Rules can't enforce themselves

An agent can ignore a rule — they're advisory. Prove your schema is actually safe:

More: the Supabase RLS guides, the policy generator, and the policy explainer.