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.

Version 1.0License: MITUpdated

Download zipSKILL.md

Typographic cover for the Codema Supabase RLS audit skill. The headline Supabase RLS audit sits on a dark field with a Security label, a line about finding missing Row Level Security policies, two stylized SKILL.md cards and the codema. wordmark.

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 anon that the app does not need.
  • There is one policy per operation the app uses (select, insert, update, delete). It flags for all policies.
  • Policies name a role, for example to authenticated.
  • Insert and update policies on user-owned tables have with check. Missing with check is a FAIL.
  • auth.uid() is written as (select auth.uid()). A bare auth.uid() is a WARN.
  • Policies do not use user_metadata for 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:

markdown
---
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

  1. List tables in exposed schemas (usually public). Use migrations in supabase/migrations/, or with a read-only connection run:
sql
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;
  1. List policies:
sql
select schemaname, tablename, policyname, roles, cmd, qual, with_check
from pg_policies where schemaname = 'public' order by tablename, cmd;
  1. 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 anon that the app does not need.
  • One policy per operation the app uses (select, insert, update, delete). Flag for all policies.
  • Roles named. Policies should target a role, for example to authenticated. WARN when no role is given.
  • with check on insert and update. An update policy without with check can let a user reassign a row. FAIL if missing on user-owned tables.
  • (select auth.uid()) wrapped in select so Postgres can cache it per statement. WARN if bare auth.uid().
  • No user_metadata in 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 definer functions in exposed schemas and check they set a safe search_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

  1. Summary: tables audited, FAIL count, WARN count.
  2. Table of findings: table, check, result, evidence (policy name or migration file).
  3. Proposed fix as a new migration file (never edit an applied migration), clearly marked NOT APPLIED.
  4. Proposed pgTAP tests.
  5. 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.

Sources

  1. Codema.ai, supabase-rls-audit SKILL.md (version 1.0)
  2. Claude Code docs, Extend Claude with skills
  3. OpenAI Codex docs, Build skills
  4. Cursor docs, Agent Skills