/pgbot:postgres-diagnosticsfrom pgbot — PostgreSQL diagnostics
Diagnoses PostgreSQL health and performance using the read-only pgbot tool. Covers slow queries, unused indexes, disk usage, bloat, autovacuum, and configuration tuning.
Ships in pgbot — PostgreSQL diagnostics. 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.
None: SKILL.md is the whole skill.
pgbot is a read-only Postgres diagnostic tool. Its findings are computed deterministically (in Go, not by a model) and it never writes to the database. Treat pgbot's output as the source of truth. Your job is to run the right command, then interpret, prioritize, and recommend — never to invent diagnoses or act on the database.
If the pgbot MCP server is connected, call its tools: inspect (start here),
top_queries, vacuum_health, unused_indexes, why. They return stable JSON.
(The logs, waits, activity, erd, and report commands are CLI-only for
now — run them through the shell.)
Otherwise run the CLI. It needs a connection string for a read-capable role
(ideally one with pg_monitor). Pick the command that matches the question:
| Question | Command |
|---|---|
| Open-ended / "is it healthy" | pgbot inspect "$DSN" (health score + worst-first findings) |
| Full detail | pgbot inspect "$DSN" --full |
| "What's eating the database?" | pgbot queries "$DSN" (top by total time; --by-calls to re-rank) |
| "What's using disk / biggest tables?" | pgbot tables "$DSN" (size + seq-vs-index scan = missing-index radar) |
| "Is autovacuum keeping up?" | pgbot vacuum "$DSN" |
| "Which indexes can I drop?" | pgbot indexes "$DSN" |
| "Should I re-tune config?" | pgbot tune "$DSN" |
| "Why is it slow RIGHT NOW?" | pgbot why --duration 10s "$DSN" (live wait sampling → evidence-gated cause: lock contention vs IO vs CPU vs client; refuses to guess on thin evidence) |
| "Who is connected / what's running?" | pgbot activity "$DSN" (live sessions: PIDs, states, waits, ages, scrubbed SQL) |
| "Where does database time go?" | pgbot waits --duration 10s "$DSN" (sampled wait classes + blockers named only with sustained evidence) |
| "What changed since yesterday?" | pgbot why "$DSN" / pgbot diff --since 24h (offline, from stored snapshots) |
| "What's in the server log?" | pgbot logs "$DSN" (--live to follow, --level error or --level audit to filter; needs one extra grant, printed when missing) |
| "What does the schema look like?" | pgbot erd "$DSN" (--mermaid for a renderable diagram, --html > schema.html for an interactive file) |
| Full report for a human to read | pgbot report "$DSN" > report.html (self-contained page: findings, queries, indexes, waits) |
| Machine-readable for parsing | pgbot inspect "$DSN" --json |
Add --timeout 60s for large or remote databases.
Don't stall and don't improvise; each gap has one fix:
pgbot not on PATH: install it — curl -fsSL https://pgbot.dev/install | sh
(or brew install pgrundev/tap/pgbot, or run without installing via
npx @pgbot/cli). Run it through the normal permission prompt so the user
sees the command.$DATABASE_URL, then ask the user for one.
Never guess or assemble credentials yourself.init, run
pgbot init --verify "$DSN" — it checks pg_monitor and pg_stat_statements
and names each fix. Older builds report the same gaps at connect time.
To create the read-only role, generate the SQL with pgbot init (or use the
Setup section of the pgbot README) and hand it to the user to run as
admin — never execute it yourself: pgbot never writes, and neither do you.tables/indexes and the JSON make replication state
visible — check it.)EXPLAIN ANALYZE, no
running the statement "just to time it." Suggest only safe, non-executing
steps (EXPLAIN without ANALYZE is fine; it doesn't run the query).DROP INDEX CONCURRENTLY / ALTER / VACUUM
statement to run themselves.tables: a large table with heavy seq scans and few idx scans is a
likely missing-index candidate — cross-check it against queries (a top query
filtering that table confirms it).queries: share is % of total DB execution time. A single query above
~30% is the real hot path; index-dropping won't touch it.vacuum: due? yes with a stale/never last-autovacuum means autovacuum
is falling behind — the early signal for bloat and, downstream, wraparound.pgbot only ever reads. Nothing leaves the machine except pgbot explain /
pgbot ask, which send the PII-free findings (normalized query text, no
literals) to an LLM and say so first. Use a role with pg_monitor; never paste a
production superuser credential where it can leak.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub pgrundev/pgbot --plugin pgbotOther plugins' skills for the same job