SupabaseBackendSKILL.mdVerified source

Agent Skill

Postgres best practices

Tune queries, RLS, connection pooling, and schema choices before a build slows down.

postgressupabasedatabase

Skill specification

Declared by Supabase in the package front matter. Trigger conditions are what the coding agent matches on before it loads the skill.

Postgres best practices SKILL.md front matter fields
Skill namesupabase-postgres-best-practices
Trigger conditionsPostgres 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.
Declared licenseMIT
Version1.1.1
Authorsupabase
OrganizationSupabase

Install supabase-postgres-best-practices

Agent Skills are a shared file format, but each client discovers them from a different directory. Copy the command for your agent, then start a new session so the skill is picked up.

Codex

.agents/skills/supabase-postgres-best-practices/SKILL.md

Codex reads `.agents/skills/` as its primary location, which is also the cross-platform default other clients honour.

Project install

mkdir -p .agents/skills/supabase-postgres-best-practices && curl -fsSL 'https://raw.githubusercontent.com/supabase/agent-skills/main/skills/supabase-postgres-best-practices/SKILL.md' -o .agents/skills/supabase-postgres-best-practices/SKILL.md

Personal install

mkdir -p ~/.agents/skills/supabase-postgres-best-practices && curl -fsSL 'https://raw.githubusercontent.com/supabase/agent-skills/main/skills/supabase-postgres-best-practices/SKILL.md' -o ~/.agents/skills/supabase-postgres-best-practices/SKILL.md

Published by Supabase under MIT. Rendered from the package in github.com/supabase/agent-skills/tree/main/skills/supabase-postgres-best-practices.

Supabase Postgres Best Practices

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

PriorityCategoryImpactPrefix
1Query PerformanceCRITICALquery-
2Connection ManagementCRITICALconn-
3Security & RLSCRITICALsecurity-
4Schema DesignHIGHschema-
5Concurrency & LockingMEDIUM-HIGHlock-
6Data Access PatternsMEDIUMdata-
7Monitoring & DiagnosticsLOW-MEDIUMmonitor-
8Advanced FeaturesLOWadvanced-

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

Add the registry badge

Maintainers can link this listing from the skill's own README. Free, no account needed, and it points back at the rendered package for anyone browsing the repo.

Markdown

[![Postgres best practices on tokens&](https://tokensand.com/api/badges/skill/supabase-postgres-best-practices)](https://tokensand.com/agent-skills/supabase-postgres-best-practices)

HTML

<a href="https://tokensand.com/agent-skills/supabase-postgres-best-practices" target="_blank" rel="noopener">
  <img src="https://tokensand.com/api/badges/skill/supabase-postgres-best-practices" alt="Postgres best practices on tokens&" />
</a>

More Supabase Agent Skills

All Agent Skills