testapilocally.com

Verifying a database migration with an AI agent

How can an AI agent verify a database migration?

Give it read-only database tools and have it state each expectation as an assertion. With the SignOff Studio MCP server, the agent:

  1. Reads the schema with db_schema (one line per table, so it fits in context) and confirms the new columns, types and nullability.
  2. Checks the data with db_assert. For example, SELECT count(*) FROM orders WHERE archived_at IS NOT NULL expects scalar = 0, and SELECT count(*) FROM users WHERE email_normalized IS NULL expects 0 after a backfill.
  3. Checks the API still works on top of it with verify_api_effect (call the endpoint, then check the row it should have written).
  4. Saves the checks with save_db_check, so CI or the next session can rerun them.

The verify-migration prompt (a slash command in Claude Code and VS Code) walks the agent through these steps.

Can the agent break the database while checking?

Not through the read tools. db_query and db_assert accept only read statements, run them in a read-only transaction (or a read-only SQLite connection, or an always-rolled-back transaction on SQL Server), and run a single statement per call. Writes need db_execute, which works only on connections you marked Allow AI agent writes, never on production-tagged connections, and runs as a dry run (rolled back) unless the agent asks to commit.

Which databases are supported?

PostgreSQL, MySQL/MariaDB, SQL Server, Oracle and SQLite.

How does the agent get the database password?

From the connection's password env key in the workspace .env, or from the SignOff Studio app's vault while it's unlocked. The password goes to the driver only. It's never returned to the model, and it's scrubbed from any output.

Should I run migrations through the agent?

We'd keep running migrations in your usual tool (your framework's migrate command or CI) and use the agent to verify the result. Verification is read-only and repeatable. Running migrations isn't.

See also: Safe read-only SQL access for AI agents · MCP server overview

Updated 2026-11-19 · This page as Markdown · llms.txt