supabase-migrations — Claude Code rule for Supabase migrations
This rule guides Claude Code when creating Supabase SQL migrations, from timestamped filenames to RLS policies. It applies to files under supabase/migrations/.
AGPL-3.0 ★ 267 updated 2026-02-20
.cursor/rules/supabase-migrations.mdcWhat supabase-migrations does
When asked to create a migration, Claude Code is directed to put it in supabase/migrations/ and use a UTC timestamp followed by a short description in the filename, such as 20240906123045_create_profiles.sql. The timestamp needs to use UTC, which determines the migration’s ordering.
The rule calls for lowercase SQL and comments describing the migration’s purpose, affected tables, and steps. New tables must have RLS enabled. Policies should be separate for each operation and for the anon and authenticated roles, with comments explaining their intent. Destructive changes, including dropping tables or columns, also need detailed comments.
What it helps with
- create a migration in the expected directory
- name a migration with a UTC timestamp
- enable RLS on a new table
- separate access policies by operation and role
- document destructive schema changes
Example prompts for the agent
- Create a Supabase migration for a profiles table in
supabase/migrations/. - Add separate RLS policies for
anonandauthenticatedon the new table. - Write a migration that drops a column and explain the change in comments.
How to install supabase-migrations
Manually: put the files in place
.cursor/rules/supabase-migrations.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/supabase-migrations.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/supabase-migrations.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/supabase-migrations.mdManually: put the files in place
.clinerules/supabase-migrations.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about supabase-migrations
How do I install supabase-migrations in Claude Code?
Add the rule file at .claude/rules/supabase-migrations.md.
What does supabase-migrations do?
It guides Claude Code in writing Supabase migrations, including their file names, SQL style, documentation, and RLS policies.
How should RLS policies be organized?
Use separate policies for each operation and for each of the anon and authenticated roles. Add comments that explain each policy’s purpose.