Jorge Turbica / blog · Blog ← All articles ES · Leer en español
Technologies

Skill of the day: supabase-postgres-best-practices, Postgres rules before schema changes

Supabase's skill makes your agent load rules on indexes, RLS, locking and connections before touching Postgres. No scripts; useful, with caveats.

An RLS policy that calls a function per row can run it a million times on a million-row table; wrapping it in a SELECT means it's evaluated once. That's the kind of rule packed into supabase-postgres-best-practices, the Postgres skill maintained by Supabase. It's on the skills.sh Trending list with 1,400 installs, and its repo, supabase/agent-skills, has 3,180 stars and saw commits on December 2, 2026.

What it does

It's an instructions-only skill (MIT licensed, version 1.1.1 in its metadata). Its description tells the agent to load it before touching anything that lives in Postgres: creating or altering tables, migrations, RLS policies, indexes, triggers, functions, queues with pg_cron or pgmq, pgvector search, or pg_restore. Also when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, or rows visible to the wrong user. The description insists it applies "even for a one-column change".

The SKILL.md sorts its rules into eight categories by impact:

PriorityCategoryImpact
1Query performanceCritical
2Connection managementCritical
3Security & RLSCritical
4Schema designHigh
5Concurrency & lockingMedium-high
6Data access patternsMedium
7Monitoring & diagnosticsLow-medium
8Advanced featuresLow

Each rule is a file under references/ with the same shape: why it matters, an incorrect SQL example, the correct one and, where relevant, EXPLAIN output. Some are Postgres 101 (index your WHERE and JOIN columns); others are exactly what agents forget: keep HTTP calls out of the transaction so a FOR UPDATE isn't held for seconds, set a statement_timeout, put a pooler in transaction mode, or keep SECURITY DEFINER functions in a private schema and revoke EXECUTE from public roles.

How to install it

With the skills.sh installer, just this skill:

bash
npx skills add supabase/agent-skills --skill supabase-postgres-best-practices

Or as a Claude Code plugin from the repo's marketplace:

bash
claude plugin marketplace add supabase/agent-skills
claude plugin install postgres-best-practices@supabase-agent-skills

You don't call it yourself: the agent loads it when the task matches the description, say "review the indexes on this table" or "optimize this query".

Risks and limits

Execution risk is minimal: the skill ships no scripts or hooks, declares no tools and doesn't touch the network or credentials; it's Markdown files with SQL examples. What the agent runs afterwards (a CREATE INDEX, a migration) depends on the database permissions you give it, not on the skill.

The limits are about content:

  • It's billed as "Postgres running anywhere", but it has a Supabase accent. The headline RLS example uses auth.uid(), a Supabase function; elsewhere you'll have to swap in your own app's identity mechanism.
  • The description promises more than the index delivers. It mentions migrations, queues and restores, yet none of the eight categories in SKILL.md is about migrations — which is where an agent does the most damage in production (an ALTER TABLE that locks the table, an index built without CONCURRENTLY).
  • Some numbers are rules of thumb. Claims like "100-1000x faster" or the pool-size formula (cores × 2) + spindles are a starting point, not the truth for your workload.

Compared with what you had

Without the skill, the agent falls back on its training data, which is fine for syntax and weak on operational detail: long transactions, slow RLS, a connection per request. The classic alternative is your own checklist in the project's CLAUDE.md: tighter to your schema, but maintained by hand. This skill is a solid common baseline, especially on Supabase; if you're not on Supabase, review the RLS examples before letting the agent copy them.

Sources

Jorge Turbica

Software Engineer and SRE. I write about the real challenges I run into in production.

See portfolio ↗