supabase-postgres-best-practices
π―SkillA set of database rules from Supabase that helps Claude write and fix Postgres tables, queries and security settings correctly. It works for Postgres running anywhere, not only on Supabase.
Installation
npx skills add supabase/agent-skills --skill supabase-postgres-best-practicesRun it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).
Uses skills.sh Β· Node.js 22.20+
After installing
Ask for related work and the agent uses it on its own, or call it yourself.
/supabase-postgres-best-practicesInstall by hand
Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.
Open the skill folder β- This project
.claude/skills/supabase-postgres-best-practices/ - All projects
~/.claude/skills/supabase-postgres-best-practices/
These paths are for Claude Code. For other tools, the command above puts it in the right place.
What this skill does
Overview
Postgres is a widely used open-source database, and Supabase maintains this guide for it. The skill gives Claude rules in 8 categories, ordered by impact, from query speed and connections down to advanced features. Claude should load it before any database change, even a single column, and when it looks into slow queries or data shown to the wrong user.
Key Features
- Get rules for fast queries, such as when to add an index (a lookup structure that speeds up searches).
- Set up row-level security (RLS), the rules that decide which rows each user can see, and test those rules.
- Plan changes to your table structure and migrations, which are scripts that apply those changes.
- Handle connection limits, locking and other problems that appear when many requests hit the database at once.
- Read each rule with a wrong SQL example, a correct one, and Supabase-specific notes when they apply.
Who is this for?
Use it when you ask Claude to add a table, write a migration or set up access rules in a Postgres database. It also helps when your app has slow queries, high CPU, timeouts, or users who can see another user's data.
Summarized by AI from this skill's SKILL.md. Suggest a better one
SKILL.md
View on GitHub β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.
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
| 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
More from this repository4
This skill guides your AI agent through Supabase tasks such as database work, user login, file storage and fixing errors. It makes the agent check current docs first and avoid common security mistakes.
Agent Skills to help developers using AI agents with Supabase
Plugin
Official Supabase agent skills for AI coding agents covering Postgres best practices, query performance, indexing, RLS, connection pooling, and schema design.