Who it is forA platform or DevOps engineer who wants database checks on every migration pull request.
The problemSchema problems often reach production because nothing checks the migration before merge.
The outcomeA CI job that exits non-zero on critical schema findings and can emit SARIF for the GitHub Security tab.
What you need first
- A PostgreSQL server version 14 to 18 that you can reach over the network
- A login role with the pg_monitor role and no write grants (pgbot init generates the setup SQL)
- The pgbot binary, installed with the curl install script or npx @pgbot/cli
- Optional: pg_stat_statements for the queries section, and hypopg on PostgreSQL 16+ for advise
Steps
- Create a disposable Postgres database for the CI job and give the job a read-only role connection string through a CI secret.
- Run
pgbot lintto check the schema with no writes to the database. (inferred, check the README) - Run
pgbot inspect --profile=schema --fail-on=criticalto make the exit code the CI gate. (inferred, check the README) - Add
--format=sarifto the inspect command to produce output for the GitHub Security tab. - Read the exit codes in CI: 0 clean, 1 warn, 2 critical, 3 connection or execution failure, 64 usage error.
Prompt for your agent
Use the pgbot tool from the pgrundev/pgbot repository in CI by running `pgbot inspect --profile=schema --fail-on=critical --format=sarif` against <ci-database-url>. Report the exit code and the number of findings in the SARIF output. Verify that exit code 3 is reported as a connection failure rather than as a finding.
Caveat. The schema profile only runs catalog-derived findings, so it does not replace checks that need live workload statistics.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for pgrundev/pgbot and "Gate schema migrations in CI with a Postgres lint"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer