Supabase Schema Reconstructor
Claude Code subagent that rebuilds a missing Supabase schema from your app code. Writes one re-runnable SQL file with tables, FKs, RPCs, triggers, RLS, realtime, storage and seeds, marks every guess, and never touches a live database.
Agent in Database by Melvin Jones Repol
What it does
For Supabase projects that were never given migrations or a schema dump. This agent reads your codebase and rebuilds the database as a single SQL file you can run on an empty test project.
## What it reads (strongest first) - SQL scripts already in the repo (these always win) - Generated types like `database.types.ts` - Docs and schema notes - App code: `.from()`, `.select()` relations, `.insert/.upsert` payloads, `onConflict`, `.rpc()`, realtime channels, storage buckets - Edge Functions in `supabase/functions/` inside one transaction: 1. Lookup and settings tables 2. People / members linked to `auth.users` 3. Core tables, parents before children, circular FKs added afterwards 4. Helper functions and RPCs the app calls 5. Triggers 6. Function privileges (anon only where logged-out pages need it) 7. Row level security on every table 8. Realtime publication (skips safely if missing) 9. Storage buckets and policies 10. Minimal seeds and a bootstrap snippet for your first admin user
Every inferred column, default or policy is marked `-- GUESS`, so you know what to double-check. The file can be run more than once (`if not exists`, `create or replace`, guarded DO blocks). Ask for it and it also writes a `supabase/migrations/<timestamp>_initial_schema.sql`.
## Safety It never connects to a live database: no `db push`, no remote `psql`, no API calls with keys from `.env`. If it finds a better source, like a linked project you could dump from, it tells you instead of using it.
How to use it
The creator has not added setup notes.
Files
Save each file at the path shown, relative to your project root.