/ai-stuff:postgres-monitoringfrom ai-stuff
Set up and use PostgreSQL monitoring: pg_stat_statements, pg_stat_activity and wait events, lock and blocking analysis, I/O and WAL statistics, auto_explain, logging settings, and the health metrics worth alerting on (XID age, replication lag, slots, disk and WAL growth, long transactions, sequence exhaustion). Use when finding which queries are slow, figuring out why the database is slow right now, choosing what to alert on, configuring Postgres logging, or picking observability tooling.
Ships in ai-stuff. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A playbook distilled from Scaling Postgres. Evidence and history are in reference.md.
Once a slow query is found, fix it with postgres-query-tuning. For vacuum
findings, use postgres-autovacuum.
shared_preload_libraries = 'pg_stat_statements,auto_explain'
pg_stat_statements.track_planning = on # planning time can dominate (partitions, many indexes)
track_io_timing = on # measure overhead first on old/virtualized hosts
log_min_duration_statement = '500ms' # pick a threshold your log volume tolerates
log_lock_waits = on
log_autovacuum_min_duration = '1s'
log_temp_files = 0
log_checkpoints = on
log_line_prefix = '%m [%p] %q%u@%d app=%a '
auto_explain.log_min_duration = '2s' # never 0 on a busy system
auto_explain.log_analyze = off # timing every node has real overhead
Top queries by total time (not mean). The things to fix are often fast queries that run millions of times.
SELECT calls, round(total_exec_time) AS total_ms, round(mean_exec_time,2) AS mean_ms,
round(total_plan_time) AS plan_ms, rows, left(query, 80)
FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20;
Know its blind spots
IN (...) lists may split into many entries; prefer = ANY($1).-- what is running and what it waits on
SELECT pid, state, wait_event_type, wait_event, now() - query_start AS runtime, left(query, 80)
FROM pg_stat_activity WHERE state <> 'idle' ORDER BY query_start;
-- who blocks whom
SELECT pid, pg_blocking_pids(pid) AS blocked_by, left(query, 80)
FROM pg_stat_activity WHERE cardinality(pg_blocking_pids(pid)) > 0;
What common waits suggest:
Lock: blocking chains, often DDL stuck in the lock queue.LWLock:LockManager: too many relations per query (partitions or
indexes) at high QPS.IO: storage latency or a working set bigger than memory.ClientRead: the app is holding a transaction open.pg_wal size or growth, plus archive failures
(pg_stat_archiver).int keys.max_connections, and pooler client waits.max_wal_size is
too small).track_io_timing on slow clocks, auto_explain
analyze/buffers on hot paths, frequent sampling).pg_stat_io (PG16) and
pg_stat_checkpointer (PG17).What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub pauldotsh/ai-stuff --plugin ai-stuff25 skills in this plugin
/brainstormingYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./dispatching-parallel-agentsUse ONLY when the developer has explicitly told you to dispatch subagents — never infer or self-authorize it. Splits 2+ independent tasks across isolated subagents, assigns them cheap models, and polls at a per-harness cadence that preserves prompt cache (Claude Code vs Codex/opencode).