I built a CLI that scaffolds a Next.js web app and an Expo mobile app on one Supabase backend, with checks that a coding agent (Claude Code) and CI must pass before a change lands.
On the Supabase side:
org_id, with FORCE ROW LEVEL SECURITY and one policy per operation.anon, authenticated and service_role, then grants only what its policies need, so new tables don't rely on the default grants that change on 30 October.service_role stays in Edge Functions, and the server uses getUser(), never getSession().Try it: npx next-expo-supabase-agent-harness@latest init
Repo: https://github.com/BhodiSea/next-expo-supabase-agent-harness Docs: https://bhodisea.github.io/next-expo-supabase-agent-harness/
Tom Nicklin introduces a CLI tool that scaffolds a Next.js web app and an Expo mobile app using a single Supabase backend. The setup emphasizes strict Row Level Security (RLS) by revoking default grants and applying specific policies per table. Feedback is requested, particularly from those using RLS-heavy applications in production.
The revoke-all-then-grant-per-table default is the right call. Two things sit outside RLS, so they could be worth a test in the harness:
security_invoker = true (Postgres 15+).One more check that lives outside the repo: after deploy, look at the live site's JS bundle and response headers for a service_role key or other secrets, since generated apps drift over time. I build DeployVet, which does that kind of outside-in check on a live URL. The free check is here if it is useful: https://deployvet.com/?utm_source=github&utm_medium=reply&utm_campaign=firstcustomer
The part worth calling out is the revoke-then-exact-grants habit — it removes the whole class of "the migration ran, then the first API call fails with 42501" that the October 30 Supabase change made everyone feel. Tables created with explicit grants behave the same whether the default-grant behavior changes or not, which is the only durable answer to that class of problem.
If you want that invariant enforced in CI rather than trusted from the agent, an earlier version of what I use checks the public schema on every push and fails when a table has RLS disabled, zero policies, or a permissive using(true) policy that negates a restrictive one — plus a self-test so the guard's own rules are verified: github.com/cekuu35/rls-guard (MIT). Happy to fold anything you've already solved here back into it if it's useful.
One addition to your checklist from the other direction: getUser() over getSession() on the server is right, and the matching database-side check is that RLS policies key off auth.uid() as SECURITY DEFINER (no schema-level auth grants for the executor role) — otherwise the tenant test passes locally and the deployed function reaches for auth.users directly. pgTAP for the two-tenant case catches both, and yours already does.
Feedback welcome, especially from anyone running RLS-heavy apps in production.