# 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/.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 267 repo stars
- Author: przeprogramowani
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/przeprogramowani/ai-rules-builder/tree/HEAD/.cursor/rules/supabase-migrations.mdc
- Updated: 2026-02-20
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/supabase-migrations

## What it 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.

## Requirements
- Works with: Supabase

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/supabase-migrations.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/supabase-migrations.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/supabase-migrations.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/supabase-migrations.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/supabase-migrations.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/przeprogramowani/ai-rules-builder/tree/HEAD/.cursor/rules/supabase-migrations.mdc

## When to use it
- 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
- Create a Supabase migration for a profiles table in `supabase/migrations/`.
- Add separate RLS policies for `anon` and `authenticated` on the new table.
- Write a migration that drops a column and explain the change in comments.

## Similar
- [supabase-admin](https://affpapa.org/en/nevibecode/skills/supabase-admin.md) — skill · 200 installs
- [supabase-production](https://affpapa.org/en/nevibecode/skills/supabase-production.md) — skill · ★ 741 repo stars
- [supabase-rls-policies](https://affpapa.org/en/nevibecode/skills/supabase-rls-policies.md) — skill · ★ 41430 repo stars
- [supabase-schema-architect](https://affpapa.org/en/nevibecode/agents/supabase-schema-architect.md) — subagent · 3839 installs
- [supabase](https://affpapa.org/en/nevibecode/skills/alinaqi-supabase.md) — skill · 651 installs
- [supabase-audit-rls](https://affpapa.org/en/nevibecode/skills/supabase-audit-rls.md) — skill · 1300 installs

From the same set: [przeprogramowani/ai-rules-builder](https://affpapa.org/en/nevibecode/by/przeprogramowani/ai-rules-builder.md) — 24 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
