ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
-- Users can only read published posts
CREATE POLICY "Public posts" ON posts FOR SELECT USING (published = true);
-- Users can only edit their own posts
CREATE POLICY "Own posts" ON posts FOR ALL USING (auth.uid() = user_id);
-- Admin can do anything
CREATE POLICY "Admin access" ON posts FOR ALL USING (
EXISTS (SELECT 1 FROM users WHERE id = auth.uid() AND role = 'admin')
);
Common Patterns
auth.uid() — current user's ID
auth.jwt() — full JWT claims
Use WITH CHECK for INSERT/UPDATE validation
Separate SELECT/INSERT/UPDATE/DELETE policies for fine-grained control
1---2name: supabase-rls3description: Supabase RLS4---5# Supabase RLS67## Enable RLS8```sql9ALTER TABLE posts ENABLE ROW LEVEL SECURITY;1011-- Users can only read published posts12CREATE POLICY "Public posts" ON posts FOR SELECT USING (published = true);1314-- Users can only edit their own posts15CREATE POLICY "Own posts" ON posts FOR ALL USING (auth.uid() = user_id);1617-- Admin can do anything18CREATE POLICY "Admin access" ON posts FOR ALL USING (19 EXISTS (SELECT 1 FROM users WHERE id = auth.uid() AND role = 'admin')20);21```2223## Common Patterns24- auth.uid() — current user's ID25- auth.jwt() — full JWT claims26- Use WITH CHECK for INSERT/UPDATE validation27- Separate SELECT/INSERT/UPDATE/DELETE policies for fine-grained control
Run npx skillmds@latest add comeonoliver/supabase-rls in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Supabase RLS It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.