Skill
Supabase RLS audit skill for coding agents
The Codema.ai Supabase RLS audit skill is a SKILL.md named supabase-rls-audit that checks Row Level Security on tables in exposed schemas. It is read-only: it never runs DDL, never disables RLS and never applies a migration. It reports gaps and proposes SQL for a human to review. It requires a Supabase project. The zip is free, with no account needed.
Codema.ai's supabase-rls-audit skill checks Row Level Security on exposed tables, then reports gaps and proposes migrations without applying them.
The short answer
The Codema.ai Supabase RLS audit skill is a SKILL.md named supabase-rls-audit that checks Row Level Security on tables in exposed schemas. It is read-only: it never runs DDL, never disables RLS and never applies a migration. It reports gaps and proposes SQL for a human to review. It requires a Supabase project. The zip is free, with no account needed.
Background on the format is in What are agent skills? How to write your first SKILL.md. For the wider tooling context, see the coding agents guide.
What the skill does
The stated goal in the file is to prove that each user can only reach the rows they should. The agent should inventory tables in exposed schemas (usually public), either from supabase/migrations/ or with a read-only SQL query against pg_class, then list policies from pg_policies, and list views and whether they set security_invoker.
For each table it records PASS, WARN or FAIL on these checks:
- RLS is enabled. A table in an exposed schema without RLS is a FAIL.
- Grants are not overly broad, including grants to
anonthat the app does not need. - There is one policy per operation the app uses (select, insert, update, delete). It flags
for allpolicies. - Policies name a role, for example
to authenticated. - Insert and update policies on user-owned tables have
with check. Missingwith checkis a FAIL. auth.uid()is written as(select auth.uid()). A bareauth.uid()is a WARN.- Policies do not use
user_metadatafor authorization. That is a FAIL, because users can edit it. - Columns used in policy filters, such as
user_id, have indexes.
It also checks views (which bypass RLS by default, and on Postgres 15+ should be created with (security_invoker = true)) and security definer functions in exposed schemas.
The report has a summary, a table of findings, a proposed new migration marked NOT APPLIED, proposed pgTAP tests (and a check for existing tests under supabase/tests/), and a list of what could not be verified.
The download is supabase-rls-audit.zip, which contains supabase-rls-audit/SKILL.md. The same file is listed on its own in the site manifest, and it is also in the starter skills pack.
When to use it, and when not to
Use it when you ask to audit, review or test Supabase RLS, policies, permissions or data access. The skill requires a Supabase project.
Do not use it to apply migrations, disable RLS, or run DDL; the skill forbids all three. Do not use it as a general code review or a full pre-deploy checklist; those are the AI code review and pre-deploy check skills. If you only have a hosted dashboard and no supabase/migrations/ folder and no read-only connection, the agent will be limited to what it can see, and the report should say so.
What's in the SKILL.md
The front matter, quoted from the file in the repo, is:
---
name: supabase-rls-audit
description: Audits Supabase Row Level Security for every table in exposed schemas, checking RLS is enabled, grants, per-operation policies, with check clauses, auth.uid() usage, views and indexes, then reports gaps and proposes migrations without applying them. Use when the user asks to audit, review or test Supabase RLS, policies, permissions or data access.
compatibility: Requires a Supabase project. Reads migrations in supabase/migrations; optionally uses a read-only database connection or the Supabase MCP server with read_only=true.
metadata:
author: codema
version: "1.0"
---
The body opens with: "Goal: prove that each user can only reach the rows they should. Read-only. Never run DDL, never disable RLS, and never apply a migration. Propose SQL for a human to review."
The zip contains only that SKILL.md. There are no bundled scripts. License: MIT.
How to install it
Download supabase-rls-audit.zip from this page. It is free and does not require an account. Unzip it and confirm that SKILL.md sits directly inside a folder named supabase-rls-audit. Then copy that folder into the skills location for your agent. The paths below come from the official docs.
Claude Code
Claude Code loads a skill from a folder that contains SKILL.md. Copy supabase-rls-audit/ to:
- Project:
.claude/skills/supabase-rls-audit/SKILL.md - Personal:
~/.claude/skills/supabase-rls-audit/SKILL.md
Claude Code discovers the skill automatically. Invoke it with /supabase-rls-audit, or ask "audit my Supabase RLS". Personal skills in ~/.claude/skills/ are not loaded in Cowork or cloud sessions.
Codex
Codex scans .agents/skills from your working directory up to the repository root, and loads personal skills from $HOME/.agents/skills. Copy supabase-rls-audit/ to:
- Project:
.agents/skills/supabase-rls-audit/ - Personal:
$HOME/.agents/skills/supabase-rls-audit/
In Codex CLI or the IDE extension, type $supabase-rls-audit, or run /skills. Codex detects new skills automatically; if one does not appear, restart Codex. A public Codema.ai skills repo is not published yet, so copy the folder by hand rather than using $skill-installer.
Cursor
Cursor discovers skills at startup from .agents/skills/ and .cursor/skills/ in a project, and from ~/.agents/skills/ and ~/.cursor/skills/ for the current user. It also loads the Claude Code and Codex skill directories for compatibility. The front matter name must match the folder name, which it does (supabase-rls-audit).
Copy the folder into one of those locations, start a new Agent chat, and type / to search for supabase-rls-audit. Cursor's docs say a GitHub repo of skills is not imported on its own unless it is packaged as a plugin.
How to vet it
Read the SKILL.md before you install it. Check that name matches the folder, and that the description and the compatibility line match what the body actually does. This skill does not set allowed-tools and does not ship scripts. It may use a database connection or the Supabase MCP server; the front matter says that connection should be read-only, or the MCP server should be set with read_only=true. Confirm that in your own setup before you let the agent connect.
For a written third-party-skill checklist, use the cross-agent security checklist. Install at project level first if you want to keep the skill in one repo.
The file's metadata lists author: codema and version: "1.0". When you install from the public GitHub repo, pin a specific commit so the file can't change under you.
SKILL.md
Supabase RLS audit
Goal: prove that each user can only reach the rows they should. Read-only. Never run DDL, never disable RLS, and never apply a migration. Propose SQL for a human to review.
1. Inventory
- List tables in exposed schemas (usually
public). Use migrations insupabase/migrations/, or with a read-only connection run:
select n.nspname as schema, c.relname as table_name, c.relrowsecurity as rls_enabled
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where c.relkind = 'r' and n.nspname = 'public'
order by 2;
- List policies:
select schemaname, tablename, policyname, roles, cmd, qual, with_check
from pg_policies where schemaname = 'public' order by tablename, cmd;
- List views in exposed schemas and whether they set
security_invoker.
2. Checks per table
For each table, record PASS, WARN or FAIL:
- RLS enabled. A table in an exposed schema without RLS is readable and writable by any role with a grant on it. FAIL if disabled.
- Grants. Policies do not remove existing grants. Flag broad grants to
anonthat the app does not need. - One policy per operation the app uses (select, insert, update, delete). Flag
for allpolicies. - Roles named. Policies should target a role, for example
to authenticated. WARN when no role is given. with checkon insert and update. An update policy withoutwith checkcan let a user reassign a row. FAIL if missing on user-owned tables.(select auth.uid())wrapped inselectso Postgres can cache it per statement. WARN if bareauth.uid().- No
user_metadatain policies. Users can edit it. FAIL if used for authorization. - Indexes on columns used in policy filters (for example
user_id). WARN if missing.
3. Views and functions
- Views bypass RLS by default. On Postgres 15+, they should be created
with (security_invoker = true). FAIL for views over user data without it. - Flag
security definerfunctions in exposed schemas and check they set a safesearch_path.
4. Tests
Check for pgTAP tests under supabase/tests/ (run with supabase test db). For each user-owned table, propose tests for: anon denied, owner allowed, and user B cannot select, update or delete user A's rows.
5. Report
- Summary: tables audited, FAIL count, WARN count.
- Table of findings: table, check, result, evidence (policy name or migration file).
- Proposed fix as a new migration file (never edit an applied migration), clearly marked NOT APPLIED.
- Proposed pgTAP tests.
- What you could not verify (for example grants not visible from migrations).
FAQ
Will this skill change my database?
No. The skill is read-only. It says never run DDL, never disable RLS and never apply a migration. Any proposed fix is a new migration file, clearly marked NOT APPLIED, and it must not edit an already applied migration.
What does it need in the project?
A Supabase project. It reads migrations in supabase/migrations. Optionally it can use a read-only database connection, or the Supabase MCP server with read_only=true. That compatibility line is in the SKILL.md front matter.
What does it check on each table?
Whether RLS is enabled, whether grants are overly broad, whether there is a policy per operation the app uses, whether roles are named, whether insert and update policies have with check, whether auth.uid() is wrapped in a select, whether policies use user_metadata, and whether policy-filter columns are indexed. Views and security definer functions get their own checks.
Does a pass mean my data is locked down?
No. The report includes a section for what the agent could not verify, for example grants that are not visible from migrations. The goal stated in the skill is to prove each user can only reach the rows they should, and to leave that proof for a human to review.
Which agents can load it?
Install paths are documented for Claude Code, Codex and Cursor. The SKILL.md does not list product versions.