/major-ai-skills:supabase-rlsfrom major-ai-skills
Design and review Supabase row-level security policies, security-definer functions, storage access, and authorization boundaries. Use for focused RLS reviews.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill complements @supabase with deep Row Level Security (RLS) practice. PostgREST and Storage honor Postgres policies using auth.uid(), JWT claims, and role (anon / authenticated / service_role). Agents design deny-by-default tables, avoid recursive policy traps, push complex authz into carefully audited security definer RPCs, and keep Edge Functions from becoming a silent RLS bypass.
Client (anon key + user JWT)
|
PostgREST / Storage
|
Postgres RLS policies <--- auth.uid() / claims
|
Optional: Edge Function (service role) with explicit authz
security definer RPCs safelyenable row level security on every user-data table; add explicit policies per command (select/insert/update/delete).auth.uid() and stable claim helpers over embedding user ids from client payloads alone.security definer only with fixed search_path, narrow grants, and internal checks - never as a blanket bypass.service_role must re-validate the caller JWT and enforce the same authz rules in code.owner_id, org_id) - RLS runs per row.-- memberships link users to orgs
create table public.org_members (
org_id uuid not null references public.orgs (id) on delete cascade,
user_id uuid not null references auth.users (id) on delete cascade,
role text not null check (role in ('owner', 'member')),
primary key (org_id, user_id)
);
alter table public.org_members enable row level security;
alter table public.documents enable row level security;
create policy "members read memberships"
on public.org_members for select
using (user_id = auth.uid());
create policy "members read org documents"
on public.documents for select
using (
exists (
select 1 from public.org_members m
where m.org_id = documents.org_id
and m.user_id = auth.uid()
)
);
create policy "members insert org documents"
on public.documents for insert
with check (
exists (
select 1 from public.org_members m
where m.org_id = documents.org_id
and m.user_id = auth.uid()
)
);
security definer RPC patterncreate or replace function public.add_org_member(target_org uuid, target_user uuid)
returns void
language plpgsql
security definer
set search_path = public
as $$
begin
if not exists (
select 1 from public.org_members
where org_id = target_org and user_id = auth.uid() and role = 'owner'
) then
raise exception 'not authorized';
end if;
insert into public.org_members (org_id, user_id, role)
values (target_org, target_user, 'member')
on conflict do nothing;
end;
$$;
revoke all on function public.add_org_member(uuid, uuid) from public;
grant execute on function public.add_org_member(uuid, uuid) to authenticated;
// Verify JWT, then use user-scoped client when possible.
// If service_role is required, re-check org membership before writes.
const jwt = req.headers.get("Authorization")?.replace("Bearer ", "");
if (!jwt) return new Response("unauthorized", { status: 401 });
// supabase.auth.getUser(jwt) -> enforce same predicates as RLS
supabase start
supabase db reset
supabase test db
supabase functions serve
supabase db lint
| Pitfall | Why it hurts | Fix |
|---|---|---|
| Policy recursion across tables | Infinite recursion errors | Helper functions / redesign |
service_role in mobile apps | Full bypass of RLS | Anon + user JWT only |
| RLS without indexes | Slow queries at scale | Index predicate columns |
| Storage policies forgotten | Public bucket leaks | Mirror table authz intent |
using (existing row) vs with check (new row) thoughtfully on updates.grant on tables/functions after every migration.exists policies can still force schema redesign.@supabase - platform overview, CLI, basic client usage@postgresql - indexing and SQL fundamentals@prisma - app ORM that must coexist with RLS (use user-scoped keys)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job