Guide
What you get: One SQL migration with uuid keys, timestamps, foreign keys, checks, indexes for every FK and filter, RLS policies per role using (select auth.uid()), privileged logic in security definer functions with search_path '', plus one-line policy explanations and isolation queries. Best for Supabase/Postgres developers designing a multi-user feature..
Before you start
- Describe the feature and every role with what it may do (fill feature and user_roles)
- A local Supabase or Postgres to apply the migration and run the isolation queries
Worked example (Nov 14, 2026, Claude Code 2.1.318 (claude-opus-5-5); Codex 0.151.0 (gpt-5.6-sol))
Input
feature=shared shopping lists (owner can invite members); user_roles=owner (full control, invites/removes members, deletes the list), invited members (read the list, add/tick off/delete items, not delete the list or manage members), every other signed-in user (no access).
Result
Claude Code: 3 tables, private.has_list_access()/is_list_owner() security definer helpers, an invite_list_member RPC, 11 policies. Codex: 3 tables, private.user_owned_list_ids()/user_member_list_ids() helpers, 18 policies, a trigger limiting members to changing completion state.
We applied each migration to Postgres 16 with a Supabase-like stub and ran 23 checks per schema as owner, member, outsider and anon: all passed for both (members read and tick items but can't rename or delete the list or invite; the outsider sees and changes nothing; anon is denied; removing a member revokes access; deleting the list cascades). No security definer function lacks search_path, no FK lacks an index, every table has RLS. Claude Code wrote the migration to supabase/migrations/; Codex returned it in the reply.
How to check it worked
- Apply the migration locally and run the isolation queries as two real users
- Check every security definer function has search_path set
- Check members can't do the owner-only actions
Common problems
- Policies that query the same table recurse; both tools used security definer helpers to avoid it
- A role described vaguely gets guessed permissions; spell out what each role may do
Log in to join the discussion.