29 skills · 8 categories
Claude Code skills for PostgreSQL
PostgreSQL skills that work from real query plans: schema design, indexing, zero-downtime migrations, locking, connection pooling, JSONB, backups and point-in-time recovery. The ORMs and platforms built on Postgres are covered as well.
Start with these
- 1
Postgres Schema Design
Tables where bad data simply cannot land
Claude designs tables from the queries they must serve, then picks a precise type for every column: timestamptz over timestamp, integer cents over floats, identity or UUIDv7 keys. Rules go into NOT NULL, CHECK, UNIQUE and foreign keys with an explicit ON DELETE, foreign keys get indexes, and JSONB is reserved for genuinely variable data. Reviews end with a blocking/should-fix note.
- 2
Postgres Indexing
Every index justified by a plan, every drop by data
Claude designs the narrowest index that serves a named query: equality columns before range columns, partial predicates for queue and soft-delete tables, INCLUDE columns for index-only scans, trigram GIN for ILIKE search. Builds run CONCURRENTLY with a lock timeout and an invalid-index check, and a diagnostic SQL catalog finds unused, duplicate and FK-missing indexes before any drop.
- 3
Zero-Downtime Migrations
Change live tables without a maintenance window
Claude splits risky schema changes into expand, backfill and contract phases that each work with old and new code running side by side. Every ALTER runs with lock_timeout, constraints go in NOT VALID and get validated separately, backfills run as resumable batches outside the DDL, and drops wait for a later deploy and your sign-off. You get a phase-by-phase plan with locks and rollback per step.
All 29 PostgreSQL skills
Grouped by category. Each card opens the full playbook, example prompts and install commands.
Testing 1
Cloud Platforms 4
Supabase Backend
Treat the database as the security boundary it is
Claude builds Supabase projects with the CLI and versioned migrations, enables RLS on every exposed table with per-operation policies that are indexed and tested as two different users, and keeps the secret key off clients. Server auth uses @supabase/ssr with verified users, storage paths are scoped by user folder, and types are regenerated after each schema change.
AWS RDS and Aurora
Right engine, tested failover, no surprise I/O bill
Guides Claude through running PostgreSQL and MySQL on AWS from measured load: choosing RDS, Aurora, or Serverless v2, sizing for the working set, testing failover, and keeping settings in custom parameter groups. It plans major upgrades as blue/green deployments with the logical-replication and PITR caveats, reduces RDS Proxy pinning, and runs a script that compares Aurora Standard and I/O-Optimized from your bill.
PaaS Deploys
Render, Railway or Heroku, configured from the repo
Claude picks the platform that fits the stack, then writes render.yaml, railway.json or a Procfile so services, databases and variables live in the repo. Apps bind to $PORT with real health checks, migrations run once in the release phase and stay backward compatible, database pools fit plan limits, and the free-tier traps such as sleeping instances and expiring databases are called out early.
Fly.io Apps
Machines, volumes and regions configured on purpose
Claude writes fly.toml with real health checks, request concurrency limits and deliberate auto stop settings, runs at least two Machines for anything that must stay up, and explains that each volume lives on one host and needs its own backups. Migrations run as release commands that are safe during rolling deploys, and rollback is a redeploy of a recorded image.
Databases 15
Postgres Schema Design
Tables where bad data simply cannot land
Claude designs tables from the queries they must serve, then picks a precise type for every column: timestamptz over timestamp, integer cents over floats, identity or UUIDv7 keys. Rules go into NOT NULL, CHECK, UNIQUE and foreign keys with an explicit ON DELETE, foreign keys get indexes, and JSONB is reserved for genuinely variable data. Reviews end with a blocking/should-fix note.
Postgres Indexing
Every index justified by a plan, every drop by data
Claude designs the narrowest index that serves a named query: equality columns before range columns, partial predicates for queue and soft-delete tables, INCLUDE columns for index-only scans, trigram GIN for ILIKE search. Builds run CONCURRENTLY with a lock timeout and an invalid-index check, and a diagnostic SQL catalog finds unused, duplicate and FK-missing indexes before any drop.
Zero-Downtime Migrations
Change live tables without a maintenance window
Claude splits risky schema changes into expand, backfill and contract phases that each work with old and new code running side by side. Every ALTER runs with lock_timeout, constraints go in NOT VALID and get validated separately, backfills run as resumable batches outside the DDL, and drops wait for a later deploy and your sign-off. You get a phase-by-phase plan with locks and rollback per step.
Postgres Full-Text Search
Real search in the database you already run
Claude builds a weighted, stored tsvector column with the right language configuration, indexes it with GIN, and parses user input with websearch_to_tsquery so no query can error. Ranking runs only over the matched set, snippets are generated for the final page only, pg_trgm covers names and typos, and the skill states plainly when Elasticsearch or a hosted engine is the better call.
Postgres JSONB
Flexible documents without giving up indexes
Claude decides per attribute whether it belongs in a column, a JSONB document or a child table, then validates documents with CHECK constraints at the database edge. Queries are written with GIN-compatible containment and jsonpath operators, hot keys become indexed expressions or stored generated columns, and expression statistics fix the planner's blind spot for keys inside JSON.
Postgres Row-Level Security
Tenant isolation the database enforces and tests prove
Claude sets up RLS so it cannot be bypassed by accident: a runtime role without BYPASSRLS that does not own the tables, ENABLE plus FORCE on every tenant table, and tenant context passed per transaction with set_config so poolers never leak it. It closes the side doors through views, SECURITY DEFINER functions and foreign keys, and writes SQL tests that fail when one tenant can see another.
SQL Query Tuning
Find the slow plan node, fix the estimate behind it
Claude stops guessing from SQL text and works from the plan. It ranks queries by total time in pg_stat_statements, captures EXPLAIN ANALYZE with real parameters, finds the node where estimates diverge, then applies the smallest fix in order: statistics, query rewrite, index, scoped config. Every change gets a before/after plan comparison with buffer counts and a short tuning note.
Backup and Restore
Backups count only after a timed restore
Claude starts from agreed RPO and RTO targets and picks the mechanism that meets them: logical dumps, physical backups with WAL archiving for point-in-time recovery, or managed PITR plus off-account copies. It restores to a separate instance by default, verifies restored data with queries and smoke tests, alerts on archive failures and backup age, and records each drill's real recovery time.
Connection Pooling
Pools sized to database cores, not request counts
Claude writes down every process that connects and sums its maximum connections against the database limit at full autoscale before touching a setting. Pools are sized from database parallelism, PgBouncer transaction mode is configured with its session-state caveats and prepared statement support, serverless platforms get a proxy, and exhaustion is diagnosed from pg_stat_activity and SHOW POOLS.
Drizzle ORM
Typed SQL, reviewed migrations, zero drift
Claude writes Drizzle schemas as the single source of truth: timezone-aware timestamps, named indexes on every foreign key, types inferred with $inferSelect instead of duplicated interfaces. It keeps push for local prototyping only, reads each generated SQL file for accidental drop-and-add renames, and picks between the core builder and relational queries based on what the result needs.
TimescaleDB Time-Series
Hypertables, rollups and retention sized to your ingest
Claude sizes chunk intervals from ingest volume and memory, picks a columnstore segmentby that matches the dominant filter, and points dashboards at continuous aggregates with refresh windows that cover late data. Retention drops chunks rather than deleting rows, and when TimescaleDB is unavailable it falls back to native range partitioning with BRIN indexes.
Transactions and Locking
Name the race, pick the lock, prove it under load
Claude names the exact anomaly behind a concurrency bug, such as lost update, write skew or double insert, then applies the cheapest mechanism that prevents it: a unique index, a guarded atomic UPDATE, a version check, FOR UPDATE in key order, or Serializable with retries. Every role gets lock and idle-transaction timeouts, and the fix is proven with a real parallel test.
Prisma ORM
Read the SQL Prisma writes before it hits prod
Claude treats Prisma as a SQL generator it must supervise. Models get timestamptz and indexed relation fields, every generated migration.sql is read for silent drops and table rewrites, and production only ever sees migrate deploy. Queries select only needed fields with cursor pagination, transactions stay short, and the setup matches your installed Prisma major, including the Prisma 7 driver-adapter client.
SQLAlchemy ORM
Typed models, owned sessions, loads you chose on purpose
Makes Claude write SQLAlchemy 2.x the way it is meant to be used: Mapped and mapped_column models with named constraints, one Session per request or task with short transactions, select() queries with deliberate selectinload or joinedload, and lazy="raise" to catch accidental lazy loads. It also reviews Alembic autogenerate output for the renames and enum changes it misses, and sets up rollback-per-test fixtures.
ClickHouse Analytics
Sorting keys that skip 99% of granules
Claude designs ClickHouse tables from the dominant queries: a sorting key that prunes granules, coarse monthly partitions, LowCardinality and codecs, and the right MergeTree variant for upserts or rollups. Ingestion is batched or uses async inserts with wait enabled, dedup queries use FINAL or argMax, and EXPLAIN indexes plus system.parts confirm granules read and part counts.
Data Engineering 3
Analytics SQL
Stated grain, no fan-out, numbers that reconcile
Claude writes the metric definition first, comments the grain of every CTE, and checks row counts after each join so duplicate keys cannot inflate totals. It writes explicit window frames, zero-fills missing days with a date spine, adapts date functions to Postgres, Snowflake, BigQuery or DuckDB, and reconciles the result with a direct total and one hand-checked entity.
Data Anonymization
Share data without sharing the people in it
Claude scans every column with a bundled PII detector, classifies direct and quasi-identifiers, and applies a recorded treatment per column: drop, keyed HMAC pseudonyms, generalization, consistent synthetic values or date shifting. It measures k-anonymity before release, builds referentially intact test subsets from production, and re-scans the output so nothing high-risk slips through.
Dimensional Modeling
Declare the grain, conform the dimensions
Claude starts warehouse design with a bus matrix and a one-sentence grain for every fact table, then checks each measure's additivity at that grain. Dimensions get surrogate keys, unknown members and a deliberate SCD type per attribute, special cases use junk, role-playing or bridge dimensions, and the model is reconciled against source totals before anyone builds a dashboard on it.
Architecture 3
CQRS and Event Sourcing
Event-source only what truly needs history
Claude first checks whether event sourcing is justified by audit, temporal queries or domain complexity, and recommends plain CQRS when it is not. When it is, it designs past-tense events with metadata, appends with expected version, folds aggregates with pure evolve and decide functions, and builds idempotent projections with gap-safe checkpoints that can be rebuilt side by side without downtime.
Data Partitioning
Pick shard keys from data, not from hope
Claude only recommends sharding after indexes, replicas, caching and native partitioning are ruled out, then picks the key from measured query patterns and runs a bundled simulator on real key frequencies to show skew, hot keys and how much data moves when a shard is added. It plans cross-shard queries, unique IDs and a rehearsed slot-by-slot resharding procedure before launch.
Multi-Tenancy
No leaks between customers, no noisy neighbors
Claude picks a tenant isolation model per pricing tier, resolves the tenant once from a trusted claim, and carries that context through the database session, jobs, events, caches, storage and logs. Isolation is enforced by row-level security or physical separation that fails closed, noisy tenants are contained with quotas and fair queues, and every endpoint gets a cross-tenant leak test.
Install
Every PostgreSQL skill in one command
Installs into ~/.claude/skills/. Add --project after -- to install into the current repository.
curl -fsSL https://claudeskills.page/install.sh | sh -s -- postgres-schema-design postgres-indexing schema-migrations postgres-full-text-search postgres-jsonb row-level-security supabase-backend sql-query-tuning testcontainers aws-rds-aurora paas-deploys backup-restore connection-pooling drizzle-orm timescale-timeseries transactions-locking cqrs-event-sourcing data-partitioning multi-tenancy prisma-orm sqlalchemy-orm pagination-filtering nix-environments fly-io clickhouse-analytics analytics-sql data-anonymization dimensional-modeling n8n-workflows PostgreSQL skills FAQ
What is the best Claude Code skill for PostgreSQL?
Start with Postgres Schema Design: Tables where bad data simply cannot land. Then add Postgres Indexing and Zero-Downtime Migrations, which cover the next most common PostgreSQL requests.
How do I install all 29 PostgreSQL skills at once?
Pass every name to the installer in one command: curl -fsSL https://claudeskills.page/install.sh | sh -s -- postgres-schema-design postgres-indexing schema-migrations postgres-full-text-search postgres-jsonb row-level-security supabase-backend sql-query-tuning testcontainers aws-rds-aurora paas-deploys backup-restore connection-pooling drizzle-orm timescale-timeseries transactions-locking cqrs-event-sourcing data-partitioning multi-tenancy prisma-orm sqlalchemy-orm pagination-filtering nix-environments fly-io clickhouse-analytics analytics-sql data-anonymization dimensional-modeling n8n-workflows. Add --project to install them into the current repository's .claude/skills/ folder so your team gets them too.
Do these PostgreSQL skills work outside Claude Code?
Yes. Each skill uses only the portable Agent Skills frontmatter, so the same folder works on claude.ai, through the Claude API and in the Agent SDK. Skills that run bundled scripts need an environment with code execution.