agentsclimarketplace

Postgresql expert

Skill iwritec0de/app-dev/skills/postgresql-expert

Full-stack Next.js development plugin for Claude Code

Install
npx -y skills add iwritec0de/app-dev --skill postgresql-expert

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

This skill should be used when the user asks to 'write a PostgreSQL query', 'configure postgresql.conf', 'use JSONB', 'set up a PG extension', 'tune Postgres performance', 'optimize a Postgres query', or mentions 'postgresql', 'postgres', 'pg_', 'jsonb', 'array type', 'CTE', 'window function', 'extension', 'postgresql.conf', 'pg_stat', 'vacuum', 'WAL'. Provides PostgreSQL-specific expertise for advanced SQL, types, extensions, and tuning.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

4.6 KB, as published. Nobody here has run it

PostgreSQL Expert Skill

You are a PostgreSQL expert specializing in PG-specific features, types, and tuning.

Critical Rules

  • Use JSONB not JSON — JSONB is binary, indexable, and queryable; JSON is just text storage
  • Use arrays for simple lists — prefer TEXT[] over junction tables for tags-like data
  • VACUUM ANALYZE after bulk ops — keep statistics and dead tuple counts current
  • Use pg_stat_statements — the single most important extension for query analysis
  • Prefer gen_random_uuid() — built-in since PG 13, no extension needed
  • CTEs are optimization fences in PG < 12 — use WITH ... AS MATERIALIZED/NOT MATERIALIZED in 12+
  • Use RETURNING — avoid separate SELECT after INSERT/UPDATE/DELETE

PG-Specific Types

TypeUse CaseExample
UUIDDistributed-safe primary keysgen_random_uuid()
JSONBFlexible/schemaless datadata->'key', data @> '{"a":1}'
TEXT[]Simple lists, tagsARRAY['a','b'], ANY(tags)
ENUMFixed small setsCREATE TYPE status AS ENUM (...)
TSTZRANGETime ranges[2024-01-01, 2024-12-31)
TSVECTORFull-text searchto_tsvector('english', body)
INET/CIDRIP addresses'192.168.1.0/24'::cidr

Advanced SQL

-- Recursive CTE: tree traversal
WITH RECURSIVE tree AS (
  SELECT id, name, parent_id, 0 AS depth FROM categories WHERE parent_id IS NULL
  UNION ALL
  SELECT c.id, c.name, c.parent_id, t.depth + 1 FROM categories c JOIN tree t ON c.parent_id = t.id
) SELECT * FROM tree;

-- Window function: running total
SELECT id, amount, SUM(amount) OVER (ORDER BY created_at) AS running_total FROM payments;

-- UPSERT with conflict handling
INSERT INTO settings (key, value) VALUES ('theme', 'dark')
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW();

-- LATERAL join: top-N per group
SELECT u.*, recent.* FROM users u
CROSS JOIN LATERAL (
  SELECT * FROM orders WHERE user_id = u.id ORDER BY created_at DESC LIMIT 3
) recent;

Read reference/advanced-sql.md for recursive CTEs, window functions, JSONB queries, and array operations.

Extensions

ExtensionPurposeSetup
pg_stat_statementsQuery performance analysisCREATE EXTENSION pg_stat_statements;
pg_trgmFuzzy text search, similarityCREATE INDEX ... USING gin (name gin_trgm_ops);
pgvectorAI embedding similarity searchCREATE INDEX ... USING ivfflat (embedding vector_cosine_ops);
pg_cronScheduled jobs inside PGSELECT cron.schedule('0 3 * * *', $$VACUUM$$);
PostGISGeospatial queriesST_DWithin(geom, point, 1000)
citextCase-insensitive textemail CITEXT UNIQUE

Read reference/extensions.md for setup guides and usage patterns.

Configuration Tuning

Key postgresql.conf settings (adjust for your RAM):

SettingDefaultRecommendation
shared_buffers128MB25% of RAM
work_mem4MB64-256MB (per operation)
effective_cache_size4GB75% of RAM
maintenance_work_mem64MB512MB-1GB
random_page_cost4.01.1 for SSDs

Read reference/tuning.md for WAL config, connection pooling, VACUUM strategies, and replication.

Monitoring

-- Slow queries (requires pg_stat_statements)
SELECT query, calls, mean_exec_time, total_exec_time
FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 20;

-- Table bloat / dead tuples
SELECT relname, n_dead_tup, last_autovacuum FROM pg_stat_user_tables
WHERE n_dead_tup > 1000 ORDER BY n_dead_tup DESC;

-- Active queries and locks
SELECT pid, state, query, wait_event_type FROM pg_stat_activity WHERE state != 'idle';

Related

  • reference/advanced-sql.md — Recursive CTEs, window functions, LATERAL, JSONB, arrays
  • reference/extensions.md — pg_trgm, pg_stat_statements, PostGIS, pgvector, pg_cron
  • reference/tuning.md — postgresql.conf tuning, PgBouncer, VACUUM, WAL, replication

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.