When to use it
- Adding a table or column
- Writing RLS policies
- Shipping a schema change without breaking production
What it looks like
Add an invoices table linked to teams, where only team members can read their invoices.
list_tableslist_migrationsget_costconfirm_cost+5 moreMigration add_invoices_table: invoices (id, team_id → teams on delete cascade, amount_cents, status, due_at, created_at), RLS on, a SELECT policy for team members via team_members, and an index on team_id. Apply it to the "dev" branch first?
The SKILL.md file
name: supabase-schema-changeMake a database schema change in Supabase safely by designing the migration with RLS policies and indexes, applying it on a branch first, regenerating TypeScript types and checking advisors. Use when the user asks to add a table or column, change the schema, write a migration or add RLS policies in Supabase.
Steps
- Read the current state with
list_tables, including the columns of related tables, andlist_migrations. - Write the migration SQL:
- tables with a primary key,
created_at timestamptz default now(), and foreign keys with explicit on delete behaviour; alter table … enable row level securityon every new table in an exposed schema, plus policies for each role and action, usually tied toauth.uid();- indexes on foreign keys and on columns used in filters;
- no destructive changes, such as dropping or renaming a column, without calling them out.
- tables with a primary key,
- Prefer a branch. If the project uses branching, apply there first. Creating a branch has a cost: show it with
get_cost, and only after the user accepts it runconfirm_costandcreate_branch. - Show the SQL and the target. After the user's yes, apply it with
apply_migration, using a snake_case name such asadd_invoices_table. - Check the result with
get_advisorsfor security and performance, for example missing RLS or unindexed foreign keys, and fix what it flags with another approved migration. - Regenerate types with
generate_typescript_typesand update the app's types file when the repo is open. - To ship a branch, use
merge_branch, after the user approves.
Supabase tools it uses
list_tableslist_migrationsget_costconfirm_costAsks firstcreate_branchAsks firstapply_migrationAsks firstget_advisorsgenerate_typescript_typesmerge_branchAsks first
Tool list from supabase-community/supabase-mcp source.
FAQ
Does it add Row Level Security?
Yes. Every new exposed table gets RLS enabled and explicit policies, and the advisors check confirms it.
Can it test on a branch first?
Yes, if your project uses Supabase branching. It shows the branch cost before creating one.