---
title: Supabase Postgres Best Practices Skill for Claude Code
canonical: https://skillselion.com/skills/supabase/agent-skills/supabase-postgres-best-practices
content_type: text/markdown
description: "supabase-postgres-best-practices is a performance optimization guide covering Postgres query performance, connection management, security, schema design."
---

# Supabase Postgres Best Practices Skill

Title: Supabase Postgres Best Practices Skill for Claude Code

> supabase-postgres-best-practices is a performance optimization guide covering Postgres query performance, connection management, security, schema design.

Canonical: https://skillselion.com/skills/supabase/agent-skills/supabase-postgres-best-practices

supabase-postgres-best-practices is a performance optimization guide covering Postgres query performance, connection management, security, schema design, and concurrency with rule categories prioritized by impact.

Postgres performance optimization guide organized into 8 priority categories. Provides detailed SQL examples, query plan analysis, and specific metrics for query performance, connection management, security, schema design, and concurrency tuning.

## Key facts

- Installs: 487,441
- GitHub stars: 3,096
- Author: supabase
- Repository: supabase/agent-skills
- Works in Grok Bot: SKILL.md frontmatter name `supabase-postgres-best-practices` and a description are valid. The instructions do not depend on Claude Code hooks, slash commands, the Task or subagent tool, or the Claude CLI. Checked 2026-11-17.
- Install command: `npx skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practices`
- Last updated: November 12, 2026

## What Supabase Postgres Best Practices does

Optimize Postgres queries and schema designs for performance at scale

How do you optimize Postgres queries on Supabase?

Performance-aligned SQL, schema designs, and database configuration recommendations grounded in Supabase Postgres rules.

Best for: Developers writing or reviewing Postgres SQL, indexes, and connection settings on Supabase or compatible Postgres deployments.

Not for: Non-Postgres databases, one-off CRUD without performance concerns, or teams needing migration tooling instead of query guidance.

- 8 priority categories from critical (query perf, connection mgmt) to incremental
- Detailed examples with incorrect vs correct SQL, query plans, and metrics
- Rules for indexes, RLS, concurrency, and Postgres-specific features

## SKILL.md

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

- 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

## Deep dive: how does supabase-postgres-best-practices actually work?

We read the skill at commit `8331f91` of supabase/agent-skills, compared it line by line against vercel-labs/agent-skills at `b8caa26`, and verified our catalog copy matches the Supabase repository byte for byte.

## supabase-postgres-best-practices at a glance

1. **It shares its structure with a Vercel skill**, down to byte-identical headings and a 22-word opening.
2. **Vercel got there first**, by twelve days, and neither repository credits the other.
3. **Security is CRITICAL in the table and thin on the shelf**, three rule files out of thirty-one.
4. **The rules teach the wrong version first**, by documented house style rather than by accident.
5. **Its own metadata is six months behind the file**, still declaring version 1.1.1 in July's release.

## 1. It shares its structure with a Vercel skill

Read our [vercel-react-best-practices](/skills/vercel-labs/agent-skills/vercel-react-best-practices#deep-dive) dive and this one will feel like déjà vu. That is not an impression, it is measurable. Three of Supabase's five section headings are byte-identical to Vercel's (`## When to Apply`, `## Rule Categories by Priority`, `## How to Use`), as are the lead-ins `Reference these guidelines when:` and `Each rule file contains:`. Both priority tables carry the same header row, exactly eight rows, and the same tier-eight prefix, `advanced-`.

The opening sentences share twenty-two words in order. Supabase's reads:

> 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.
> Source: SKILL.md, [overview](https://github.com/supabase/agent-skills/blob/8331f910845103c08d51f6ca1d86ebb7d1f745e3/skills/supabase-postgres-best-practices/SKILL.md#L15)

Vercel's says the same thing about React:

> Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 70 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
> Source: vercel-labs/agent-skills SKILL.md, [overview](https://github.com/vercel-labs/agent-skills/blob/b8caa260a420a73042e35521de4b5c8baf6446cc/skills/react-best-practices/SKILL.md#L12)

Nobody writes twenty-two words in that order independently.

## 2. Vercel got there first, by twelve days

The commit history settles the direction. Vercel's react-best-practices SKILL.md was first committed on 2026-01-14. The supabase/agent-skills repository did not exist until 2026-01-16, and its Postgres SKILL.md landed on 2026-01-26. Neither repository credits the other: we grepped both for README, CONTRIBUTING, AGENTS and CLAUDE files and found no mention in either direction. Both ship under MIT, which permits exactly this.

So the honest description is reuse, not coincidence, and nothing about it is improper. What it tells you as a reader is more useful than any accusation: a house style for vendor knowledge skills has emerged, one vendor wrote it down first, and the pattern now travels. Thin index, deep per-rule references, impact tiers as the organizing idea. Expect to meet it again.

## 3. Security is CRITICAL in the table and thin on the shelf

The priority table puts security third, above schema design:

> | 3 | Security & RLS | CRITICAL | `security-` |
> Source: SKILL.md, ["Rule Categories by Priority"](https://github.com/supabase/agent-skills/blob/8331f910845103c08d51f6ca1d86ebb7d1f745e3/skills/supabase-postgres-best-practices/SKILL.md#L33)

Then count the files. Of the thirty-one rules that ship, security gets three. Only `advanced-` (two) is thinner. Schema design, ranked below it at HIGH, gets six. The tier that carries the highest stakes on the page carries under ten percent of the material behind it.

The three that exist are good. `security-rls-basics` is marked CRITICAL, with an impact line reading "Database-enforced tenant isolation, prevent data leaks", and its incorrect example spells out the failure in SQL:

> -- Bug or bypass means all data is exposed!
> select * from orders;  -- Returns ALL orders
> Source: references/security-rls-basics.md, ["Incorrect"](https://github.com/supabase/agent-skills/blob/8331f910845103c08d51f6ca1d86ebb7d1f745e3/skills/supabase-postgres-best-practices/references/security-rls-basics.md#L18-L19)

The privileges rule annotates `grant all privileges` with "Any SQL injection becomes catastrophic" ([line 20](https://github.com/supabase/agent-skills/blob/8331f910845103c08d51f6ca1d86ebb7d1f745e3/skills/supabase-postgres-best-practices/references/security-privileges.md#L20)). Read those three yourself; they are the highest-value fifteen minutes in the bundle. Just know that the CRITICAL label is a statement about consequence, not about how much of this skill is about security.

## 4. The rules teach the wrong version first, on purpose

Every rule file leads with the broken version before the fix, and that is documented policy rather than a habit we inferred: the bundle ships a `references/_contributing.md` that names the convention outright as an error-first structure, alongside a `_template.md` that new rules are cut from.

It is the right call for a reader that pattern-matches. An agent asked to review your existing schema needs to recognize the anti-pattern in code somebody already wrote, which means it has to have seen the anti-pattern, labelled, next to its replacement.

## 5. Its own metadata is six months behind the file

The frontmatter still describes a January release:

> version: "1.1.1"
> Source: SKILL.md, [metadata](https://github.com/supabase/agent-skills/blob/8331f910845103c08d51f6ca1d86ebb7d1f745e3/skills/supabase-postgres-best-practices/SKILL.md#L7)

The changelog shipped in the same bundle has its latest entry at 1.6.0, dated 2026-07-30. Five minor versions and six months separate what the file says about itself from what the file is. The January date is the creation stamp, accurate when written and never touched since. It is harmless, and it is a good reminder for anyone whose freshness checks trust a version string: this one has been wrong for half a year.

**Tools it drives:** none. Like its Vercel counterpart, it is a pure knowledge skill: rules the agent applies to the SQL and schemas it writes.

**Behavior change, before and after:**

| You ask | Without the skill | With the skill |
|---|---|---|
| "Add a tenants table and query it by user" | Application-level `where user_id = $1` filtering | RLS enabled on the table, per the CRITICAL `security-rls-basics` rule |
| "This dashboard query got slow" | Guesswork about indexes | The `query-` tier first: plans, missing indexes, partial indexes, each with a worked example |

**The fine print worth knowing:**

- The frontmatter scopes it to "Postgres running anywhere", and the rules are standard Postgres. Individual files add Supabase-specific notes; the advice is portable, the ecosystem defaults are not neutral.
- Thirty-one rule files is a real library but not a big one. Judge it by the tiers you actually need, and note that security is three of them.

## Should you install supabase-postgres-best-practices?

Install it if an agent writes SQL that reaches production, on Supabase or not. The priority ordering is sound, the error-first rule format is the best teaching shape we have seen in a knowledge skill, and `security-rls-basics` is worth reading even if you never install anything. Skip it if your database work is read-only analytics against someone else's warehouse. Adjust your expectations on depth: eight tiers sounds comprehensive, thirty-one files is what arrives.

```
npx skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practices
```

---

*Previous: [how caveman actually works](/skills/juliusbrussee/caveman#deep-dive). All dives: [the series index](/deep-dives).*

## Supabase Postgres Best Practices FAQ

### Does supabase-postgres-best-practices only work with Supabase?

No. The frontmatter scopes it to "Postgres best practices maintained by Supabase, for Postgres running anywhere", and the rules are standard Postgres: indexes, connection pooling, RLS, locking, schema design. Individual rule files add Supabase-specific notes where the platform differs.

### Eight categories sounds big. How many rules actually ship?

Thirty-one rule files under `references/`, unevenly spread: schema six, query five, connections four, data four, locking four, monitoring three, security three, advanced two. The eight tiers describe priority, not volume.

### How many rule categories does supabase-postgres-best-practices cover?

supabase-postgres-best-practices organizes Postgres guidance into 8 categories, prioritized from critical query performance and connection management to incremental advanced features. Each rule includes incorrect versus correct SQL examples.

### When should developers load supabase-postgres-best-practices?

Load supabase-postgres-best-practices when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations on Supabase. The skill applies during active development and performance troubleshooting.

### Is Supabase Postgres Best Practices safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

## Machine access

- [Sitemap](https://skillselion.com/sitemap.xml)
- [llms.txt](https://skillselion.com/llms.txt)
- [llms-full.txt](https://skillselion.com/llms-full.txt)
- [Developer resources](https://skillselion.com/developers)
- [OpenAPI spec](https://skillselion.com/openapi.json)
- [MCP handshake](https://skillselion.com/.well-known/mcp)
- [API catalog](https://skillselion.com/.well-known/api-catalog)
- [AI catalog](https://skillselion.com/.well-known/ai-catalog.json)
- [Pricing](https://skillselion.com/pricing.md)
- [Auth](https://skillselion.com/auth.md)
- [AGENTS.md](https://skillselion.com/AGENTS.md)
- [Contact](https://skillselion.com/contact)
- [Home](https://skillselion.com/)
