Skip to content

Query and migration cost review before every push

Before a branch is pushed, a reviewer looks at every changed database query and migration and asks what it does at production size. It measures plans on a local copy and writes a findings table into the pull request.

EngineeringWorks with Claude Code · CursorCommunity example

What it does

  • Lists every changed query, including ones changed through a function or caller
  • Sizes each query against your largest customer and checks the index it uses
  • Checks migrations for locks, rewrites, backfills and edits to deployed files
  • Measures plans on a seeded local database only
  • Writes a block, fix or note table into the pull request description

Your approval boundaries

Creates drafts

These actions always wait for your yes:

  • Pushing the branch
  • Merging the pull request
  • Running anything against a shared or production database

You decide what happens next.

More about this workflow

This setup is for developers and small engineering teams who want fewer chores. It takes a repeat chore off your plate and hands back something you can check quickly.

First, it lists every changed query, including ones changed through a function or caller. Next, it sizes each query against your largest customer and checks the index it uses. Then it checks migrations for locks, rewrites, backfills and edits to deployed files. After that, it measures plans on a seeded local database only. Finally, it writes a block, fix or note table into the pull request description. It works with your git host, database and CI, each on its own login with limited access.

You get the prep work done and waiting for you. The agent stops and asks for your yes before pushing the branch, merging the pull request and running anything against a shared or production database, and says plainly if a step cannot be undone.

“what a changed query or migration does at production size”
synoet synoet on GitHub · Nov 9, 2026
Before you startGit host · Database accessScoped permissionsClaude Code or Cursor
Explore required tools and model recommendations

Tools and access

  • GitHub

    Handles the git host and ci part of this job. Grant a fine-grained token, read code and write comments.

    API required: Yes. Needs a GitHub App or a fine-grained personal access token scoped to the repos it needs.

  • Supabase

    Handles the database part of this job. Grant a role limited to one table.

    API required: Yes. Needs a Supabase project and an API key. Give the agent a role limited to one table.

Official links only. Not sponsored, no affiliate links.

Model recommendations

Best pick

Claude Opus 5.5

Its maker points to it for long running coding work.

$4 per million input tokens, $20 per million output tokens.

Anthropic docs as of October 11, 2026

Cheaper backup

Claude Sonnet 5.5

Half the price per token and still strong for reviews and docs.

$2 per million input tokens, $10 per million output tokens.

Anthropic docs as of October 11, 2026

Our own picks. Not sponsored, no affiliate links.

Build your prompt

Add your details, then copy the prompt into your tool.

1Your details

Fill these in and the prompt updates as you type.

2Your prompt

4 of 4 still empty
Fill these in before you run it: [TABLE SIZE TIERS] [LARGEST TENANT SIZE] [LOCAL SEED COMMAND] [MIGRATIONS FOLDER] You are the Query and migration cost review before every push agent. Before a branch is pushed, a reviewer looks at every changed database query and migration and asks what it does at production size. It measures plans on a local copy and writes a findings table into the pull request. Use only the details filled in above. If any [BRACKETED] item is still blank or unclear, stop and ask for it first. Do not guess. What you do on your own: - Lists every changed query, including ones changed through a function or caller - Sizes each query against your largest customer and checks the index it uses - Checks migrations for locks, rewrites, backfills and edits to deployed files - Measures plans on a seeded local database only - Writes a block, fix or note table into the pull request description What you must never do without a yes from a person: - Pushing the branch - Merging the pull request - Running anything against a shared or production database Rules: - Before any step on the list above, stop and ask. Say in plain words what you want to do, who it affects, and whether it can be undone. - If something cannot be undone, say so first, in one short line. - Write drafts, not final actions. A person sends, pays, posts, or deletes. - Keep a short log of every action you took and every source you read. - If you are unsure, ask instead of guessing.
View run instructionsPaste into: Claude Code, Cursor

Your answers stay in this browser only.

Run your workflow

Connect your tools with only the access this setup needs, then follow these steps.

Steps

Do these in order. Test on old data before it touches live work.

  1. 1Connect GitHub with its own login, not yours. Grant a fine-grained token, read code and write comments.
  2. 2Connect Supabase with its own login, not yours. Grant a role limited to one table.
  3. 3Paste the prompt where your harness takes instructions. See the note under the Copy button.
  4. 4Do a dry run on old or test data first. Check every draft and every stop point by hand before you let it near live work.
  5. 5Read its log after the first real run. Only widen access once a week of runs looks clean.

Safeguards and trust score

The score describes this example setup’s access, approval boundaries, ability to undo changes, and scope.

Access24 / 30

Writes drafts and notes inside your tools, nothing leaves on its own.

Human approval30 / 30

Waits for a yes on: pushing the branch, merging the pull request, running anything against a shared or production database.

Undo and logs14 / 20

Proposes changes to live records, so the setup needs a change log and a way back.

Scope16 / 20

Runs on its own login across 3 tools. Fewer connections means a smaller blast radius.

How to raise it

  • Undo and logs: Stop it from editing live records. Have it write the change as a proposal you apply, and keep a log of every change with a way to roll it back +3
  • Scope: Cut it down from 3 connected tools to the 2 it needs most, each with its own limited login instead of your full account +2

Do all of these to reach 89, up from 84.

Want help getting there? Get an AI Trust Audit from Pixeldesigns

Reviewed by Trustcase (example setup). How scoring works

Embed badge

Show this trust score on your site or README. It links back here.

Trustcase trust score badge
Markdown
[![Trustcase trust score for Query and migration cost review before every push](https://trustcase.dev/badge/query-and-migration-cost-review-before-every-push.svg)](https://trustcase.dev/use-cases/query-and-migration-cost-review-before-every-push)
HTML
<a href="https://trustcase.dev/use-cases/query-and-migration-cost-review-before-every-push"><img src="https://trustcase.dev/badge/query-and-migration-cost-review-before-every-push.svg" alt="Trustcase trust score for Query and migration cost review before every push" height="20"></a>
  • Code review thread replies checked against the branch

    Reads the open review threads on your pull request, checks each finding against the real code and drafts a short reply in your voice. You post, skip or rewrite each one, and only approved replies go up.

  • Weekly manager report from your commits

    Reads a week of your commits across your repos and writes a status report in the exact format your manager asked for. It asks about work git cannot show before you send it.

  • As built docs updated from change evidence

    Takes a diff, deploy result or test result and drafts matching updates to your architecture doc, config guide and change log. It never claims more than the evidence proves, and writes only the edits you approve.

  • Pull request reviewer

    Gives every PR a first pass before a person looks.

Other workflows that use the same tools

  • Local B2B lead finder

    Sales. Searches for local businesses that fit your target, scores each one, and saves them to a database. Contact details get checked before use, since the builder found some emails were made up.

  • Site change tester

    Marketing. Tries small edits to your site, watches whether more visitors stay, and keeps only the changes that help. Good for steady small wins on a landing page.

  • Daily cancellation review

    Support. Each morning it looks at every customer who canceled in the last day and works out why. It checks payments, usage and what they did right before canceling.