writing-migrations
Skill by marmelab
Generates Supabase SQL migrations at deploy time from a session branch diff. It is meant for a developer agent dispatched by an orchestrator to produce the schema counterpart of app changes.
Install writing-migrations
Built from the published package, never by AI.
git clone --depth 1 https://github.com/marmelab/atomic-crm /tmp/atomic-crm && mkdir -p ~/.claude/skills && cp -r /tmp/atomic-crm/.claude/skills/writing-migrations ~/.claude/skills/writing-migrationsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/marmelab/atomic-crm /tmp/atomic-crm && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/atomic-crm/.claude/skills/writing-migrations ~/.gemini/antigravity-cli/skills/writing-migrationsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill turns the code changes in a session branch into the minimal SQL migration that makes the Supabase schema match what the app expects. It computes the net diff from the session-base to session branch range, picks out schema-relevant changes such as entity types, fake-data generators and dataProvider resource registrations, and ignores CSS, layout, copy and tests.
The skill regenerates a single net migration on each run, replacing any migration the same session created earlier that has not been deployed. It writes idempotent SQL with IF NOT EXISTS guards, RLS for new tables, and grants for new objects. It also recreates views with CREATE OR REPLACE and places new columns last. It is written for the deploy-time migration round of a session, not for ordinary feature tickets.
Written from the project's SKILL.md and checked against it.
What it can do
- Net session diffComputes the full session change from the session-base to session two-dot range.
- Schema-relevant filterKeeps only changes that imply a database schema change and skips CSS, layout, copy and tests.
- Single net migrationReplaces earlier unpushed migrations from the same session with one migration covering the whole net change.
- Idempotent SQLWrites statements guarded with IF NOT EXISTS or IF EXISTS, with correct column types and foreign keys.
- RLS and grantsEnables RLS with policies on new tables and adds GRANTs for new tables, views and sequences.
- Safe view recreationRecreates affected views with CREATE OR REPLACE and appends new columns at the end of the select list.
What you need
- A Supabase project with supabase/migrations and supabase/schemas directories
- A git repository with session branches and a session-base anchor
- Git worktree access for the session branch
Try asking
- Generate the deploy-time Supabase migration from this session's branch diff.
- Check whether this session's diff needs any schema migration or report no migration.
- Recreate the companies_summary view with a new importance column at the end.
Good to know
- Only for the deploy-time migration round, dispatched by the orchestrator, not ad hoc feature work.
- Does not edit TS, TSX or CSS files; it only writes SQL under supabase/migrations/.
- Once a migration is pushed or promoted it is immutable, so later changes need a new forward migration.
- Dropping a view with CASCADE is reserved for column removal or rename cases.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .claude/skills/writing-migrations/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to writing-migrations
All alternatives →Creates, configures and manages datasets on the Hugging Face Hub, including SQL-based querying and transformation. Built for people who edit dataset content and metadata directly, alongside the HF MCP server.
Diagnoses and repairs gbrain's Postgres access when a command or MCP result shows a GBRAIN_DB_ACCESS marker, or when the operator reports the brain database is down. It runs the hardcoded gbrain db-repair ladder and verifies the result with a re-probe.
Manages clusters, instances, and backups for AlloyDB for PostgreSQL. Built for creating, configuring, and administering AlloyDB databases, not general PostgreSQL or Cloud SQL instances.
Writes, reviews and migrates Supabase logs queries against the ClickHouse logs table served by the logs.all.otel endpoint. Built for developers who write Logs Explorer SQL or convert older BigQuery logs queries.
Diagnoses and fixes slow Paperclip PostgreSQL queries using Cloud and Neon evidence, local benchmarks, regression tests, and a pull request with passing checks. Built for engineers working on Paperclip.
Guides AI assistants through Prisma 8 projects built on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo. It covers data contracts, migrations, typed queries and runtime setup for developers on Prisma 8.
Compare with hugging-face-datasets, db-repair or alloydb-basics
writing-migrations: common questions
When should the writing-migrations skill be used?
The source says it is loaded when a developer dispatch asks for the deploy-time migration after a session's app changes have merged to the session branch. Per-ticket feature developers do not write SQL with it.
What happens if the session has no schema changes?
The skill writes no file and reports NO_MIGRATION_NEEDED. The source says an empty migration should not be written.
Why does the skill regenerate one migration instead of adding new ones?
The source says the user does not want to push N migrations per change, so each session carries one migration covering the net change from session-base.
How do I install writing-migrations?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is writing-migrations free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is writing-migrations safe to use?
It scores 78 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to writing-migrations?
Similar skills: hugging-face-datasets, db-repair, alloydb-basics, clickhouse-logs-queries.
