kw-check-migrations-supabase
Check Migrations & Edge Functions — Supabase
Review and apply pending Supabase migrations and deploy edge functions with explanation and confirmation.
Workflow
Run both checks in sequence, then present a unified summary.
Part A — Database Migrations
A1. Detect pending migrations
Run npx supabase db push --dry-run to list migrations not yet applied to the remote database. If it fails, fall back to npx supabase migration list and compare local vs remote status.
If no pending migrations, note it and move to Part B.
A2. Read and explain each migration
For each pending migration file in supabase/migrations/:
- Read the SQL file
- Provide a concise explanation: what it does, what table/column it affects, and why (use SQL comments as context)
- Flag any destructive operations (DROP, DELETE, TRUNCATE) with a warning
A3. Present migrations
## Pending migrations ({count})
1. **{filename}** — {one-line summary}
{2-3 sentence explanation}
2. **{filename}** — {one-line summary}
{explanation}
Part B — Edge Functions
B1. Check if edge functions exist locally
Check if supabase/functions/ exists and contains function directories. If the directory does not exist or is empty, note "No local edge functions" and skip to the summary.
B2. Compare local vs remote
- Run
npx supabase functions listto get deployed functions. - For each local function directory in
supabase/functions/:- If it does NOT appear in the remote list → mark as new (pending first deploy).
- If it appears in the remote list → download and diff (see B3).
- For functions that appear only in remote (not local) → mention as info ("deployed but no local source").
B3. Diff existing functions
For each function that exists both locally and remotely:
- Download the remote version to a temp directory:
npx supabase functions download <name> --output /tmp/supabase-fn-diff/<name> - Diff the local directory against the downloaded version:
diff -rq supabase/functions/<name> /tmp/supabase-fn-diff/<name> - Classify:
- Changed: diff found differences → mark as pending deploy, show a summary of what changed
- Up to date: no differences → mark as synced
- Clean up the temp directory after all comparisons.
B4. Present edge functions
## Edge functions ({counts})
### New (not yet deployed)
- **{name}** — {brief description from index.ts}
### Changed (local differs from remote)
- **{name}** — {summary of changes}
### Up to date
- {name}, {name}
### Remote only (no local source)
- {name}
Omit any section that has zero items.
Part C — Summary & Confirmation
Present a unified summary:
## Summary
- Migrations: {count} pending
- Edge functions: {new_count} new, {changed_count} changed
{If nothing pending in either category: "Everything is up to date." → stop}
Then ask what to deploy:
---
What would you like to deploy?
1. Migrations only
2. Edge functions only
3. Everything
4. Cancel
---
Part D — Deploy
Based on user selection:
- Migrations: run
npx supabase db pushand report result. If any migration fails, report which one and the error. - Edge functions: deploy each selected function one by one with
npx supabase functions deploy <name>and report success/failure for each.
Report final status when done.
Important
- Never deploy without showing the user what will be applied first
- Always read actual SQL files, not just filenames
- Destructive SQL operations (DROP TABLE, DELETE FROM, TRUNCATE) deserve explicit warnings
- For edge function diffs, always clean up temp files after comparison
- The commands use
npx supabasesince the CLI may not be installed globally - If
supabase functions downloadfails for a function, report it as "unable to diff" rather than failing the whole check
More from kwazema/claude-skills
kw-gsd-fortify
>
10kw-cubic
>
9kw-stack-audit
>
9kw-code-cleanup
Add a code quality cleanup phase to the current GSD milestone. Use when the user says "code cleanup", "cleanup phase", "limpieza de codigo", "add cleanup phase", or wants to add lint/refactoring/quality checks as a milestone phase.
9kw-update-skills
>
9kw-vite-checker-setup
>
9