Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

Supabase RLS policies

Writes Supabase row level security policies and proves with tests that users cannot see each other's rows.

Claude's review

9/10 Expert Supabase RLS rules with two user pgTAP template and a deliberate break the policy check.

We asked Claude the question you would ask: would I be glad I installed this? We only sell skills it rates 7 or higher.

In detail

Write, review, and test Supabase Row Level Security (RLS) policies so that one user cannot read or change another user's rows. Use when creating or changing tables, policies, views, or security definer functions in a Supabase project, when reviewing a migration that touches RLS, or when asked to prove user isolation with pgTAP tests that sign in as two users.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: supabase-rls-policies
description: 'Write, review, and test Supabase Row Level Security (RLS) policies so that one user cannot read or change another user''s rows. Use when creating or changing tables, policies, views, or security definer functions in a Supabase project, when reviewing a migration that touches RLS, or when asked to prove user isolation with pgTAP tests that sign in as two users.'
---

# Supabase RLS Policies

Write Row Level Security (RLS) policies for Supabase tables, then prove them with pgTAP tests that act as two different users. A policy is not finished until a test shows that a second user cannot read, change, delete, or create rows that belong to the first user.

## When to Use This Skill

- Creating a table in an exposed schema (by default `public`)
- Adding or changing a policy, a view, or a `security definer` function
- Reviewing a migration or pull request that touches RLS
- Answering whether users or tenants are isolated from each other

## Workflow

1. **List the access rules first.** For each table, write down which role (`anon` or `authenticated`) may run which operation (`select`, `insert`, `update`, `delete`) on which rows. Confirm the list with the user before writing SQL. Each rule gets one test.
2. **Write the migration.** Enable RLS, add one policy per operation, and index every column the policies filter on.
3. **Write a pgTAP test file** for the table under `supabase/tests/`, using the template below.
4. **Run `supabase test db`** and read every line of output.
5. **Break the policy on purpose, on a local database only.** Copy the test file and add a temporary policy with `using (true)` right after `begin;`, for example `create policy "tmp_open" on public.notes for select to authenticated using (true);`. Run `supabase test db` against the local stack from `supabase start`, confirm at least one test fails, then delete the copy. Do the same with a temporary `for update` and a `for delete` policy. The file ends with `rollback`, so the temporary policy is undone even when the run fails or stops early. Never put a temporary policy in a migration, and never run this against a shared or production database. Do not drop the real policy to do this: with no policy every read is denied, so denial tests still pass and prove nothing.
6. **Do not change a policy just to make a test pass.** Report which assertion failed and which policy it covers, and let the user decide which one is wrong.

## Rules for Every Table

### Enable RLS and name the role

- Run `alter table ... enable row level security` on every table in an exposed schema. Once RLS is on and no policy exists, the API returns no rows.
- Add a `to` clause to every policy. Without it the policy applies to `PUBLIC`, which means every role, including `anon`.
- `auth.uid()` returns `null` when the request has no signed in user. `to authenticated` keeps anonymous requests from reaching the check at all.

### One policy per operation, with the owner checked on writes

```sql
alter table public.notes enable row level security;

create policy "notes_select_own" on public.notes
  for select to authenticated
...

From github's repository, MIT licence.

Related skills

  • Checked

    PostgreSQL schema explorer

    Explores an unfamiliar PostgreSQL database read only before writing SQL, so answers about your data are right.

    by timescale 1.9k
    7/101 credit
  • Checked

    HTTP API design review

    Designs or reviews HTTP endpoints, auth, pagination and versioning, so API changes do not break your clients.

    by AmazingAng 770
    7/101 credit
  • Checked

    Firebase Data Connect

    Builds and deploys Firebase Data Connect backends on PostgreSQL with secure queries and type safe SDKs.

    by firebase 533
    7/101 credit
  • Checked

    App performance tuning

    Measures first, then fixes slow pages, Core Web Vitals and N+1 database queries across your whole app.

    by addyosmani 122k
    7/101 credit
  • Checked

    Safe Postgres migrations

    Plans and tests PostgreSQL schema changes with lock levels in mind, so live tables change without downtime.

    by timescale 1.9k
    8/101 credit
  • Checked

    Supabase auth and database

    Builds with Supabase auth, database, storage and edge functions while avoiding common security traps.

    by supabase 3.2k
    8/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added