Database Migration Review
A database loop for Cloudflare D1/Drizzle and other SQL projects where migrations must be safe, indexed, and reviewable.
Use loop copies the kickoff prompt. Copy Markdown and Download loop include the complete Markdown page with context, source attribution, anchors, and guardrails. Cursor / Claude Code buttons prepare the shorter kickoff prompt only.
Supported agents
Goal
Ensure database changes are safe for development and production migration paths.
Feedback gate
pnpm db:generateStop condition
Migration SQL is reviewed and no unexpected destructive operations remain.
Give the agent these inputs before it starts the loop. This keeps discovery bounded and prevents vague retries.
The loop assumes these commands or integrations are available. Missing tools should be reported as blockers, not ignored.
Two separate pieces: the kickoff prompt starts the loop, while the downloaded Markdown carries the complete reference page.
1. Copy or download
Use the kickoff for a fast agent run. Download the full Markdown when you need source, context, and attribution in one file.
2. Paste into the agent
Start a fresh agent session in the target repo and provide the requested project context if the loop asks for it.
3. Let it self-pace
The agent should act, check evidence, retry only when the gate fails, and stop at the stated exit condition.
The diagram shows the order. This checklist keeps only the action, command, and failure handling needed during a real pass.
1. Inspect schema diff
Find table, column, and index changes.
2. Generate migration
Use production migration generation rather than guessing SQL.
pnpm db:generate3. Review destructive operations
Check for DROP/ALTER data-loss risks and D1 compatibility.
4. Verify index coverage
Ensure public listing/detail filters have indexes.
This is the text copied by Use loop. It is intentionally shorter than the Markdown export.
Review database schema and migration changes for D1 compatibility, destructive operations, indexes, and rollback risk. Generate but do not apply production migrations without approval.
Goal: Ensure database changes are safe for development and production migration paths.
Check command: pnpm db:generate
Exit condition: Migration SQL is reviewed and no unexpected destructive operations remain.
Max iterations: 4
Guardrails:
- Do not weaken, skip, delete, or rewrite the validation command to force success.
- Do not claim completion until the stated exit condition is actually satisfied.
- If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
- Do not apply production migrations without human review. Do not run destructive SQL automatically.Quality
89/100
Safety
93/100
Expected output
Migration review report with destructive risk, D1 compatibility, and index coverage.
Related loops
Browse allRollback Readiness Check
Before risky release, confirm rollback path, database migration reversibility, and feature flag escape hatches.
Kickoff preview
Audit release rollback readiness: risky files, migrations, previous deployment path, data safety, and feature flags. Do not execute destructive commands. Goal: Know how to safely revert the release before shipping it. Check command: git diff --name-only main...HEAD Exit condition: Rollback path is documented and destructive/irreversible changes are explicitly acknowledged. Max iterations: 3 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not run destructive migrations or rollback commands without explicit user confirmation.
Cloudflare Worker Smoke Test
Verify a Cloudflare Workers deployment, D1 binding, static assets, and route behavior with targeted smoke checks.
Kickoff preview
Run the Cloudflare build, verify the deployed Worker URL, D1-dependent pages, sitemap, robots, and static assets. Report exact failures. Goal: Prove the Cloudflare Worker deployment is serving critical routes with correct bindings. Check command: pnpm cf:build Exit condition: Cloudflare build and deployed smoke checks pass. Max iterations: 4 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not expose Cloudflare tokens or account IDs in public output.
Environment Variable Audit
Compare env templates, runtime config, deployment secrets, and code references to catch missing or leaked variables.
Kickoff preview
Audit all environment variable references, classify public vs secret scope, compare env templates and deployment config, and report missing or unsafe variables. Goal: Ensure required env vars exist in the right place and secrets are not exposed client-side. Check command: rg -n "process.env|import.meta.env|VITE_" src .env.example wrangler.example.jsonc Exit condition: All referenced env vars are documented and correctly scoped. Max iterations: 3 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Never move server-only secrets into public `VITE_` variables.
Ship PR Until Green
Implement a scoped change, open or update a pull request, inspect CI, and continue until all required PR checks pass.
Kickoff preview
Take this branch to a green pull request. Implement the requested change, run local verification, open or update the PR, run `gh pr checks`, inspect failures, fix root causes, and repeat until every required check passes or you hit the iteration cap. Goal: Open or update a pull request and stop only when all required PR checks are green. Check command: gh pr checks Exit condition: All required pull request checks are successful and the PR is ready for review or merge. Max iterations: 10 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not disable required checks, edit loops to skip jobs, or remove tests to make CI green. - Do not merge the PR unless the user explicitly asked for merge authority.