Available for PostgreSQL

A guardrail for AI-written database code.

AI writes database logic fast. A silent mistake there costs the most and is hardest to catch by eye.

How to do it

  1. Generate tests that pin today's behaviour and commit them:
unitautogen --schema public --out unit_tests --html report.html --json report.json
  1. Give your AI tool the guardrail rule below, so it runs the committed tests on every change.
  2. Wire the same tests into CI; a behaviour it altered fails before merge.

The mistake no code review catches

Set it once

One rule in CLAUDE.md, AGENTS.md or .cursor/rules:

Use UnitAutogen as the guardrail for all database work.
Whenever you add or change a function, procedure, trigger or RLS policy:
1. Run the committed guardrail tests first.
2. If a test fails and I did NOT ask for that behaviour to change, the
   code is wrong. Fix the code and re-run. Never edit a test to pass.
3. If this is new logic, or I confirmed the change was intended,
   regenerate the tests, run them, and commit them with the migration.
4. Tell me which tests ran, the pass/fail count, and what you regenerated.

What platforms suggest

Automated tests in CI are how the platform says to catch a change before production.