Skill Press

No. 12 · supabase-postgres-best-practices

Supabase Postgres Best Practices

A field guide from Supabase

Supabase

When to use it

Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector/semantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.

Rank
No. 12 of 971
Installs
501,329
Runs in
Claude
Length
242 words · 1 min
Files
37
License
MIT

Get this skill

Download the skill folder (.zip, 34 KB) ↓ · SKILL.md only ↓

Agent prompt

Paste into a coding agent with terminal access. Check the upstream requirements for the skill you’re installing.

Prompt
Install the "supabase-postgres-best-practices" Agent Skill by Supabase, from https://github.com/supabase/agent-skills.

1. Fetch the whole folder skills/supabase-postgres-best-practices — SKILL.md plus every script, reference, and asset beside it, not just SKILL.md. For example:
   skill_checkout=$(mktemp -d)
   git init "$skill_checkout"
   git -C "$skill_checkout" fetch --depth 1 https://github.com/supabase/agent-skills.git c9be0e931b7930f7d02126d04774d904c381e7d7
   git -C "$skill_checkout" checkout --detach FETCH_HEAD
2. Copy it into your skills directory as a folder named "supabase-postgres-best-practices":
   - Claude Code: ~/.claude/skills/supabase-postgres-best-practices/ (all projects) or .claude/skills/supabase-postgres-best-practices/ (this project only)
   - Another agent: the directory you load Agent Skills from (folders containing a SKILL.md)
3. Check that supabase-postgres-best-practices/SKILL.md exists and its frontmatter says name: supabase-postgres-best-practices.
4. Read SKILL.md, then tell me in two or three sentences what the skill does and when it will trigger, and list any dependencies it mentions (Python packages, npm packages, CLIs) that aren't installed yet. Don't install them without asking.

skills CLI

One command; the skills.sh installer detects your agents (Claude Code, Cursor, Codex, and more).

Terminal
npx skills add https://github.com/supabase/agent-skills/tree/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices --skill supabase-postgres-best-practices
This skill on skills.sh ↗

Claude.ai

Upload the .zip as a custom skill.

  1. In Settings → Capabilities, turn on “Code execution and file creation”.
  2. Download the .zip above.
  3. Go to Customize → Skills, click + → Create skill → Upload a skill, and choose it.
Anthropic’s guide to using skills ↗

Contents

  1. When to Apply
  2. Rule Categories by Priority
  3. How to Use
  4. References

The skill, in full

Comprehensive performance optimization guide for Postgres, maintained by Supabase. Contains rules across 8 categories, prioritized by impact to guide automated query optimization and schema design.

When to Apply

Reference these guidelines when:

  • Writing SQL queries or designing schemas
  • Implementing indexes or query optimization
  • Reviewing database performance issues
  • Configuring connection pooling or scaling
  • Optimizing for Postgres-specific features
  • Working with Row-Level Security (RLS)

Rule Categories by Priority

Priority Category Impact Prefix
1 Query Performance CRITICAL query-
2 Connection Management CRITICAL conn-
3 Security & RLS CRITICAL security-
4 Schema Design HIGH schema-
5 Concurrency & Locking MEDIUM-HIGH lock-
6 Data Access Patterns MEDIUM data-
7 Monitoring & Diagnostics LOW-MEDIUM monitor-
8 Advanced Features LOW advanced-

How to Use

Read individual rule files for detailed explanations and SQL examples:

references/query-missing-indexes.md
references/query-partial-indexes.md
references/_sections.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect SQL example with explanation
  • Correct SQL example with explanation
  • Optional EXPLAIN output or metrics
  • Additional context and references
  • Supabase-specific notes (when applicable)

References

  • https://www.postgresql.org/docs/current/
  • https://supabase.com/docs
  • https://wiki.postgresql.org/wiki/Performance_Optimization
  • https://supabase.com/docs/guides/database/overview
  • https://supabase.com/docs/guides/auth/row-level-security

More in Databases & Storage

All Databases & Storage skills →

From supabase/agent-skills at c9be0e9, MIT. Install counts from skills.sh.