supabase/agent-skills/skills/supabase-postgres-best-practices
Supabase Postgres rules
Postgres rules maintained by Supabase for schema design, migrations, RLS policies, indexes and queries, and for diagnosing slow queries and locking.
What Supabase Postgres rules does
This skill gives the agent 31 Postgres rules maintained by Supabase. They sit in eight categories ranked by impact. Query performance, connection management, and security and RLS are marked critical, followed by schema design, concurrency and locking, data access patterns, monitoring and diagnostics, and advanced features. The frontmatter tells the agent to load the skill before it writes or changes anything that lives in a Postgres database, and when it diagnoses slow queries, timeouts, connection exhaustion, locking or rows visible to the wrong user.
SKILL.md is a short index. It names each category with its filename prefix, such as query- or conn-, and points the agent to the files in references/ for detail. Each rule file says why the rule matters, pairs an incorrect SQL example with a corrected one, and ends with a link to a PostgreSQL or Supabase page. Typical rules: index the columns used in WHERE and JOIN clauses, put a connection pooler between the application and the database, wrap auth.uid() in a SELECT inside RLS policies, and page with a cursor instead of OFFSET.
The output is SQL, schema changes or review comments that follow these rules. The folder also holds a changelog and three files for contributors: a section list, a rule template and writing guidelines.
Install
npx skills add supabase/agent-skills --skill supabase-postgres-best-practicesRead the security check below before you run it. The repository's own instructions win if they differ.
Security check
What the skill's files do, from reading them. A flag that nobody has checked yet says "Not checked", never "No".
- Runs scripts
- No
- Uses the network
- Yes
- Installs hooks
- No
- Asks for secrets
- No
Checked at commit c9be0e9 on 2026-11-12. All 36 files are Markdown: SKILL.md, CHANGELOG.md and 34 files under references/. The folder ships no scripts, installs no hooks and asks for no secrets or environment variables. The scan marks network use. SKILL.md lists five documentation URLs on postgresql.org and supabase.com without telling the agent to fetch them, and each rule ends with a similar link an agent may open. The only shell command is pnpm test in a contributor checklist. Some SQL examples change server settings (alter system set in conn-limits.md and conn-idle-timeout.md), and one creates a role with a placeholder password. Before installing, skim the rules, and review any SQL the agent proposes before it runs against a real database.
Scan details: SKILL.md instructions include web requests or URLs to fetch. Checked at commit c9be0e931b79.
Use cases
- Review a schema or migration for missing indexes and unsuitable column types.
- Diagnose a slow query with EXPLAIN ANALYZE and pg_stat_statements.
- Write RLS policies that isolate tenants and stay fast on large tables.
- Set up connection pooling and connection limits for an application under load.
Limitations
- The folder holds guidance only: no scripts, linters or automated checks.
- The description names pgvector, pg_cron, pgmq, pg_restore and triggers, but no rule file covers them.
- Some RLS examples use Supabase helpers such as `auth.uid()` and the `authenticated` role.
- SKILL.md frontmatter says version 1.1.1, while CHANGELOG.md lists 1.6.0 as the latest release.
Sources
- supabase-postgres-best-practices skill folderRepositoryPrimarygithub.com
- supabase/agent-skillsRepositoryPrimarygithub.com
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/SKILL.mdRepositoryPrimary
- github.com/supabase/agent-skills/tree/main/skills/supabase-postgres-best-practices/referencesRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/query-missing-indexes.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/conn-pooling.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/security-rls-performance.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/security-rls-basics.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/data-pagination.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/conn-limits.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/conn-idle-timeout.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/security-privileges.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/references/_contributing.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/CHANGELOG.mdRepositoryPrimary
- github.com/supabase/agent-skills/blob/main/LICENSERepositoryPrimary
- github.com/supabase/agent-skills/blob/main/README.mdRepositoryPrimary
- github.com/supabase/agent-skills/tree/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practicesRepositoryPrimary


