What the agent does
The agent reads the database and the page together. In a project shaped like Razikus/supabase-nextjs-template, supabase/config.toml has [realtime] enabled = true, and supabase/migrations/20250130181641_todo_list.sql creates public.todo_list with id, created_at, title, urgent, description, done, done_at and an owner uuid referencing auth.users, enables row level security, and adds one policy, Owner can do everything, for authenticated where owner = auth.uid(). No migration adds the table to the supabase_realtime publication, so Postgres never streams its changes. In nextjs/package.json the app runs next ^15.4.8 with React 19, @supabase/supabase-js ^2.47.10 and @supabase/ssr ^0.5.2, with next lint and next build as its only checks.
nextjs/src/app/app/table/page.tsx is a client component that builds a client with createSPASassClientAuthenticated from src/lib/supabase/client.ts, loads rows with getMyTodoList(1, 100, 'created_at', filter) from the SassClient wrapper in src/lib/supabase/unified.ts, and after every createTask, removeTask and updateAsDone calls loadTasks() again to refetch the whole list. A second tab, or the same user on a phone, sees nothing until it reloads.
The agent writes a migration that runs alter publication supabase_realtime add table public.todo_list and sets replica identity full on the table, so a DELETE event carries the old row's owner and the policy can be checked against it. In unified.ts it adds subscribeToMyTodoList(ownerId, handlers) to SassClient, which opens a channel on postgres_changes for schema: 'public', table: 'todo_list' with the filter owner=eq.<ownerId>, dispatches INSERT, UPDATE and DELETE payloads typed with the Database['public']['Tables']['todo_list']['Row'] type from src/lib/types.ts, and returns the channel so the caller can remove it. The page gains a useEffect that subscribes once the user from useGlobal is known, applies each payload to the tasks state in place, respecting the current done filter, and calls removeChannel on cleanup. The three loadTasks() calls after writes go away; the initial load stays.
Then it checks the change the way the repository can: npm run lint and npm run build in nextjs, which type-checks the new handler against the generated Database type, and the Supabase CLI's local stack from supabase/config.toml to apply the migration and confirm todo_list is listed in pg_publication_tables for supabase_realtime. It runs the app against that stack, opens the table page in two browser windows as the same user, adds and completes a task in one, and records the other updating without a reload for the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add Realtime updates to the todo list in this Supabase and Next.js project and open a pull request. Read supabase/config.toml, supabase/migrations/20250130181641_todo_list.sql, nextjs/package.json, nextjs/src/app/app/table/page.tsx, nextjs/src/lib/supabase/client.ts, nextjs/src/lib/supabase/unified.ts, nextjs/src/lib/types.ts and nextjs/src/lib/context/GlobalContext.tsx first. Add a migration that adds public.todo_list to the supabase_realtime publication and sets replica identity full on it. In unified.ts add a subscribeToMyTodoList method on SassClient that opens a postgres_changes channel on public.todo_list filtered to owner=eq.<user id>, calls typed handlers for INSERT, UPDATE and DELETE, and returns the channel. In table/page.tsx subscribe in a useEffect once the user is known, update the tasks state from each payload respecting the done filter, remove the channel on cleanup, and delete the loadTasks calls that follow createTask, removeTask and updateAsDone while keeping the initial load. Run npm run lint and npm run build in nextjs, apply the migration on the local Supabase stack and confirm the table is in pg_publication_tables, then open the page in two windows as one user and record one window updating from the other. Put the command output and the recording in the pull request. Do not change the row level security policy.",
"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 that adds one file under supabase/migrations, adds a method to nextjs/src/lib/supabase/unified.ts and changes nextjs/src/app/app/table/page.tsx. The description shows the next lint and next build output, the pg_publication_tables row for todo_list, and a recording of two windows in which a task added in one appears in the other.
The repository has no CI workflow, so the pull request's checks are the ones the agent ran. The description lists them in order so a reviewer can repeat them: apply the migration, start the app, open the page twice.
A reviewer checks that the subscription filter and the row level security policy agree, so one user never receives another user's rows, that replica identity full is acceptable for a table of this size, and that the state update on UPDATE handles a task moving across the done filter. Then they decide whether the storage page needs the same treatment, which the pull request leaves alone.
Run it on every new table in the app
The same request applies to any table a page polls or refetches. Send one POST /o/{org}/sessions per table or page, naming the migration and the page file in input, and each run reads that table's policy and the page's state shape before writing the subscription, so a table without an owner column gets a filter on whatever column the policy uses.
Give the API key a webhook_url and Rush POSTs run.completed when each turn finishes, with the session_url to read the pull request link from, so a handler on your server can post it where that page's owners review.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
Realtime has three places to go wrong, the publication, the policy and the client filter, and a page that silently receives nothing looks exactly like a page that works. The agent runs the local Supabase stack in its sandbox, queries the publication, and drives two browser windows, and the queries and the recording stay in the run's record, so the pull request shows rows arriving rather than code that should make them arrive.
The repository has no test suite and no CI, so the proof has to be made by hand each time. In Rush the agent makes it once in its own sandbox and attaches it, and the same request body works for every page in the app that still refetches after a write.
Frequently asked questions
Why does the migration need replica identity full?
By default Postgres sends only the primary key in a DELETE event. Realtime checks row level security against the event's columns, so without the old row's owner the delete never reaches the subscriber. Setting replica identity full includes the whole old row.
Will a user see other users' tasks?
No. The channel filter is owner=eq.<user id>, and the Owner can do everything policy means Realtime, which authorises postgres_changes with the signed-in user's token, drops any row the user cannot select. The two checks agree; the reviewer confirms that in the policy and the filter side by side.
What happens to the done filter?
The handler applies each payload against the filter the page has: a task marked done while the page shows open tasks is removed from the list, and an insert that does not match is ignored. The initial getMyTodoList call still runs when the filter changes.
Does this change the row level security policy?
No. The policy stays as it is, and the migration only adds the table to the publication and changes its replica identity. The prompt forbids policy changes so the pull request cannot widen access by accident.