What the agent does
The agent reads what the database expects before it writes a row. In a project shaped like Razikus/supabase-nextjs-template, supabase/config.toml already has [db.seed] enabled with sql_paths = ['./seed.sql'], but no supabase/seed.sql exists, so supabase db reset applies the migrations and stops at an empty database. The migrations under supabase/migrations/ are the spec: 20250107210416_MFA.sql creates an authenticative schema with is_user_authenticated(), a SECURITY DEFINER function that compares the JWT's aal claim with the user's verified rows in auth.mfa_factors; 20250130165844_example_storage.sql inserts a private files bucket; 20250130181110_storage_policies.sql gives each user the <uid>/ prefix of that bucket for select, insert, update and delete; and 20250130181641_todo_list.sql creates public.todo_list with title, urgent, description, done, done_at and an owner foreign key to auth.users with cascade delete, enables row level security and adds the single policy "Owner can do everything" for authenticated, gated on is_user_authenticated() and owner = auth.uid().
It also reads how the app uses those tables, so the seed exercises real paths. nextjs/src/lib/supabase/unified.ts wraps the client in a SassClient whose getMyTodoList pages through todo_list ordered by created_at and filtered on done, whose createTask inserts a row and updateAsDone sets done, and whose uploadFile, getFiles and shareFile all work under the files/<uid>/ prefix. nextjs/src/app/app/table/page.tsx builds a NewTask with title, trimmed description or null, urgent, owner and done: false, and nextjs/src/app/app/storage/page.tsx lists and uploads into the user's folder. config.toml has enable_confirmations = true under [auth.email], which matters for a seeded login.
The seed the agent writes is one supabase/seed.sql that is safe to run on every reset. It inserts two users straight into auth.users with fixed UUIDs, encrypted_password from crypt() through pgcrypto, email_confirmed_at set so the confirmation requirement does not block sign-in, and the raw_app_meta_data and raw_user_meta_data JSON the auth server expects, plus the matching auth.identities rows with provider_id and provider = 'email' so the password grant finds them. It then inserts a dozen todo_list rows split across the two owners with a mix of urgent, done with a done_at, and null descriptions, so the table page shows every state and getMyTodoList has something to filter. It does not insert storage.objects rows, because the storage API, not SQL, owns object bytes; instead it leaves a comment naming the bucket and the prefix pattern a test upload must follow. Every statement uses on conflict do nothing so the file is idempotent.
Then it proves the seed. The agent starts the local stack with supabase start, runs supabase db reset, and reads the seed step of the output. It signs in as a seeded user through the local auth API with the password from the seed and calls the REST API for todo_list with that session, expecting only that user's rows back, which is the RLS policy working against seeded data, and notes that the MFA gate returns aal1 rows because the seeded users have no verified factors. It adds a short section to the project README on the two accounts and their passwords, marked as local-only, and opens a pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Write supabase/seed.sql for this project. Read every file in supabase/migrations and the Next.js code that reads and writes those tables, then seed two local users in auth.users and auth.identities with confirmed emails and known passwords, and enough public.todo_list rows per owner to show every state the table page renders. Make every statement idempotent. Run supabase start and supabase db reset, sign in as a seeded user against the local auth API and list todo_list through the REST API to confirm the RLS policy returns only that user's rows, document the accounts in the README as local-only, and open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request on its own branch with two files changed: a new supabase/seed.sql and a README section on the seeded accounts. The description lists the users and their fixed UUIDs, the number of todo rows per owner and the states they cover, why no storage objects are seeded, and the exact supabase db reset command that loads it.
The proof is in the session. The trajectory at GET /o/{org}/sessions/{id}/messages keeps the supabase db reset output with its seeding step, the sign-in call against the local auth endpoint, and the REST query whose response holds one owner's rows and not the other's. A reviewer reads the policy working against seeded data rather than a sentence saying it does.
Before merging, a reviewer checks that the passwords and UUIDs are visibly local-only and never match anything in production, that seed.sql is not included in any deploy step, since supabase db push applies migrations only, and that the auth.users columns the insert sets match the version of the auth server in config.toml. They also confirm the file loads twice in a row without an error, which the on conflict clauses are there for.
Run it on every schema migration merged
A team that keeps the local database realistic sends POST /o/{org}/sessions with this prompt whenever a migration lands, with the repository in resources. Each run reads the new migration beside the existing seed, adds rows for a new table or a new column with a default, and leaves the rest of seed.sql as it was, so the pull request is small enough to read at a glance.
An automation with a github trigger on pull_request.closed.merged and branch_patterns set to main starts the run when a pull request merges and appends the event after the prompt, so the agent sees which pull request arrived and whether it touched supabase/migrations/. An automation run has its own max_runs_per_hour cap and is not tied to an API key.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
Writing a seed for Supabase by hand means reading every policy to find the rows it will let through, remembering which auth.users and auth.identities columns the auth server needs for a password login to work, and running the whole local stack to find out. On Rush the run happens in its own cloud sandbox: it runs supabase start and supabase db reset there, with the Postgres 15 the project's config.toml asks for, and your own local stack keeps whatever data you had in it.
The result carries its proof. The pull request holds the seed and the README lines, and the trajectory holds the reset output, the sign-in and the RLS-filtered query, so a reviewer checks the shape of the data rather than whether it loads. Nothing reaches main until the pull request merges, and nothing in a seed ever reaches a hosted project.
Frequently asked questions
Is it safe to insert into auth.users directly?
Locally, yes, and it is the standard way to seed accounts for supabase db reset. The seed sets the columns the auth server reads for a password login, including encrypted_password, email_confirmed_at and the auth.identities row, and the agent confirms it by signing in through the local auth API. The pull request marks the accounts as local-only.
Will the seed run against my hosted project?
No. seed.sql is loaded only by supabase db reset on the local stack, under the [db.seed] setting in config.toml. supabase db push applies migrations and never the seed, and the README section the agent adds says so.
Why are there no files in the storage bucket?
Objects in Supabase Storage are written through the storage API, which stores the bytes and the storage.objects row together; inserting the row alone would list files that cannot be downloaded. The seed leaves a comment with the files/<uid>/ prefix the policies require, so a test upload from the app lands where the policies allow.
What about the MFA policy?
The policy calls is_user_authenticated(), which admits an aal1 session only for a user with no verified factor in auth.mfa_factors. The seeded users have none, so a password login reads their rows. Enrolling a factor is done through the app, and the pull request explains the effect on the seeded accounts.
Can I regenerate the seed when the schema changes?
Yes. Send the same prompt again with the repository in resources; the run reads the current seed.sql and the new migration and adds only what the new schema needs. The automation on merged pull requests described above does this without anyone starting it.
More Supabase jobs
The same job on other stacks
- Add Seed Data to a NestJS TypeORM App (TypeORM)
- Add Seed Data to a Vapor App (Vapor)
- Add Database Seeders to an AdonisJS API (AdonisJS)