Guide
What you get: New tables arrive in a supabase/migrations file with RLS enabled and explicit policies using (select auth.uid()), an index on the foreign key, user-scoped client code (no service-role key) and tests. Best for Supabase developers who want agents to stop shipping tables without RLS..
Before you start
- A project with supabase/ initialised (supabase init) and the Supabase CLI
- Fill test_command (we used npm test with Vitest)
- For type generation the agent needs a running local stack (supabase start) or a linked project
- Cursor: .cursor/rules/supabase.mdc. Claude Code/Codex: the same text in CLAUDE.md / AGENTS.md
Worked example (Nov 14, 2026, Claude Code 2.1.318 (claude-opus-5-5); Codex 0.151.0 (gpt-5.6-sol))
Input
A TypeScript project with one existing migration (profiles with RLS), a userClient(accessToken) helper and generated types. Task: bookmarks (URL, title, optional note) that each signed-in user can add, list newest first and delete; nobody sees anyone else's.
Result
Both: `supabase migration new ...`, `create policy ... for select to authenticated using ((select auth.uid()) = user_id)` plus insert and delete policies, index on (user_id, created_at desc), and src/bookmarks.ts using the user's client.
Not tested in Cursor or Copilot: the rule text was saved verbatim (front matter included) as CLAUDE.md for Claude Code and AGENTS.md for Codex, the files those agents load at startup, plus a copy at its normal path. We applied each migration to Postgres 16 with a Supabase-like stub (anon/authenticated roles, auth.uid(), Supabase default grants): user B saw 0 of A's rows, deleted 0, updated 0, inserting a row owned by A failed with an RLS error, anon saw nothing (Codex also revoked anon grants). Tests and tsc passed. Neither could run `supabase gen types` (no local stack/Docker in the session); both edited the generated types file by hand and said so.
How to check it worked
- Apply the migration locally and query as two different users
- Check every new table has enable row level security and a policy per operation
- Regenerate types with supabase gen types once a local stack is running
Common problems
- supabase gen types needs a running stack or linked project; agents fall back to hand-editing the generated file
- Policies missing for update are fine only if updates aren't meant to happen; say so in the task
Log in to join the discussion.