
pg-checkup
io.github.pgcheckup/pg-checkup
Read-only PostgreSQL checkups for your AI assistant. Lists what to fix, in order, with the SQL.
Documentation
Read-only checkup for PostgreSQL. Lists what to fix, in order, with the SQL.
Website · Docs · Checks · Issues
Run it
npx pg-checkup postgres://checkup_reader@host/db
Node 18+ and PostgreSQL 12+. It connects like psql: a URL, -h -U -d, PG* variables, or DATABASE_URL in .env.
No database at hand? Run it on a demo database in your browser.
What it finds
- Dead rows, bloat, and tables vacuum never reaches
- Missing, invalid, unused and duplicate indexes
- Queries that take most of the time, sequential scans, sorts that spill to disk
- Blocked queries and long transactions
- Sequences close to their limit
- Tables without row-level security, slow or overlapping policies,
SECURITY DEFINERfunctions withoutsearch_path - Disk used by pg_cron history, pg_net responses and large values (TOAST)
Findings come in three groups: fix now, fix next, watch. When one problem causes another, the cause comes first. All checks.
Safe on production
- The session is read-only, and each query times out after 15 seconds.
- It reads statistics views and the catalog. It never reads table rows.
pg-checkup sqlprints every query it runs.
Use a login that can only read statistics. pg-checkup role prints this:
create role checkup_reader login password '...';
grant pg_monitor to checkup_reader;
How it works
The saved file holds statistics, settings, and table and role names. It never holds table rows or the connection string.
GitHub Actions
npx pg-checkup schedule --summary --write
Writes .github/workflows/pg-checkup.yml. Add a DATABASE_URL secret. Each run puts the findings in the run summary and compares them with the last run. --fail-on warning fails the run when something new appears.
For AI agents
npx pg-checkup --json --no-input
JSON on stdout, findings sorted by priority, nothing to type. See AGENTS.md or pgcheckup.com/docs/agents.
Commands
pg-checkup URL run a checkup and save it to a file
pg-checkup show FILE read a saved checkup (--md, --json, --all)
pg-checkup compare A B what was fixed, what is new
pg-checkup baseline URL save schema, grants and policies before a migration
pg-checkup verify FILE URL what changed after the migration
pg-checkup doctor URL test the connection and the login's access
pg-checkup role SQL for a statistics-only login
pg-checkup sql every query it runs
pg-checkup upload FILE optional: a web report with the fix SQL
--json prints the result as JSON. --no-input never prompts. Exit code 1 means a --fail-on match.
Not included
- No writes to your database, and no table rows read.
- No network calls except to your database.
uploadis a separate command and asks first. - No hidden code. Everything that touches the database or the network is readable in
source/.
Sample report · GitHub and CI · License: see LICENSE.
pg-checkup-mcpnpm install pg-checkup-mcp