Generate and safety-review an Alembic migration in a FastAPI project that uses this convention (SQLAlchemy 2.0 async, models re-exported from app/db/base.py, alembic env.py with compare_type), catching data-loss operations (drop_column, drop_table, type narrowing, a mass-drop from a model missing in base.py) before they are applied. Use whenever a SQLAlchemy model was added or changed and a migration is needed: "마이그레이션 만들어줘", "User 모델 바꿨는데 스키마 반영해줘", "스키마 diff 떠줘", "generate the alembic revision for the new column", "add a migration for the orders table". Do NOT use this for: applying an already-generated migration in production or CI (a deploy step: `alembic upgrade head`), reverting (`alembic downgrade`), hand-authoring a data-backfill migration, scaffolding a new domain and its model (use fastapi-domain-module), bootstrapping the project (use fastapi-bootstrap), or non-Alembic stacks; TypeORM projects use nestjs-migration, and Prisma/Drizzle/Django have their own tooling.
Ships in backend. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Autogenerated migrations are convenient and dangerous: Alembic diffs your model
metadata against the live database and emits whatever closes the gap, including
drop_column and drop_table. A model that is merely not imported looks
identical to a table that was deleted, so the most destructive migration this
tool can produce is also the easiest one to produce by accident. This skill
generates the migration and forces a review gate before it counts as safe.
{
"name": "create_user", // snake_case verb_subject; Alembic prepends a revision hash
"apiRoot": "apps/api" // directory holding alembic.ini + app/ (default: auto-detect)
}
{
"migrationFile": "app/db/migrations/versions/a1b2c3d4e5f6_create_user.py",
"verdict": "safe" | "needs-review" | "no-changes",
"destructiveOps": [] // e.g. ["drop_column('user', 'legacy_flag')"] — non-empty ⇒ gate STOP
}
Locate the api root — the directory containing alembic.ini and the app/
package. Default to apps/api, fall back to the repo root.
Check preconditions. Autogenerate diffs models against a live database, so both of these must hold or the diff is meaningless:
.env points at — local
docker compose up -d db, a native cluster, a remote dev instance. If it is
unreachable, stop and report. Never hand-write a migration file to work around
a missing database; a fabricated revision hash will corrupt the version chain.uv run alembic current and compare with
uv run alembic heads. If migrations are pending, uv run alembic upgrade head
first — otherwise the new revision re-emits everything the pending ones already
contain.Verify the new model is visible to Alembic. env.py imports
app/db/base.py and nothing else, so target_metadata only knows about models
re-exported there. Before generating, confirm the changed model appears in
app/db/base.py. Checking this before running is much cheaper than diagnosing
the mass-drop migration it causes (step 5).
Generate.
cd <apiRoot> && uv run alembic revision --autogenerate -m "<name>"
Unlike some ORMs, Alembic succeeds and writes a file even when nothing
changed — you get a revision whose upgrade() body is just pass. That is not
a migration, it is chain noise: delete the file, report
verdict: "no-changes", migrationFile: null, and stop.
Review the emitted operations — the gate. Open the new file under
app/db/migrations/versions/ and read upgrade(). Classify every operation:
Operation in upgrade() | Meaning | Verdict |
|---|---|---|
create_table, add_column (nullable or with default), create_index | additive | safe |
alter_column widening a type (String(50) → String(255)) | safe-ish | safe, note it |
drop_column, drop_table | data loss | needs-review |
alter_column narrowing a type, or nullable=False on a populated table | may truncate or fail mid-deploy | needs-review |
drop_constraint + create_constraint recreating the same FK/index | usually a naming-convention artifact | note it, verify intent |
drop_table for tables you did not touch | see below — almost never a real drop | needs-review |
Collect every data-loss or risky operation into destructiveOps.
Decide.
destructiveOps empty → verdict: "safe". Report the file and tell the caller
they can apply it with uv run alembic upgrade head, which is a deploy step and
not this skill's job.destructiveOps non-empty → verdict: "needs-review". Stop. Show the user
each risky operation and ask whether it is intended:
A migration that drops tables you never touched. The model is missing from
app/db/base.py, so target_metadata does not contain it, so Alembic concludes the
table was deleted. The tell is that the drops target unrelated domains while the
change you actually made is nowhere in the file. Fix base.py, delete the revision,
regenerate — never "just remove the drop lines", because the underlying metadata is
still wrong and every future migration will be wrong the same way.
A rename that arrives as drop + add. Alembic has no concept of a column or
table rename; renaming a model attribute emits drop_column('user', 'old') +
add_column('user', 'new'), silently discarding the data. When a drop/add pair
matches a recent rename, flag it and hand-edit the revision to
op.alter_column('user', 'old', new_column_name='new') instead.
An enum change that does nothing. Autogenerate does not diff the values of a
PostgreSQL native enum. Adding a member needs a hand-written
op.execute("ALTER TYPE status ADD VALUE 'archived'"), and on older PostgreSQL that
statement cannot run inside a transaction block — so it belongs in its own
revision, not bundled with table changes.
Base.metadata.create_all() or a "just recreate the schema"
shortcut to avoid writing a migration. It skips the version chain, so the next
autogenerate diffs against a database Alembic believes is at a different revision.env.py and the app share the same database URL from settings, and the Alembic
CLI loads .env itself — so the same environment variables must be present in the
shell you run this from.alembic.ini or app/db/migrations/ is missing, the project was not
bootstrapped with this convention. Stop and point the user at fastapi-bootstrap
rather than running alembic init and guessing at the env.py wiring.What SKILL.md sets; muted values are Claude Code's defaults
/backend:fastapi-migrationfrom backend
npx claudepluginhub siu9068/ggyul-skills --plugin backend11 skills in this plugin
/api-creator-bootstrapGenerates a backend repo's `api-creator` + `test-checker` skill pair: set up, port, or bootstrap the API + test skills here. Generate a project-tailored TDD skill PAIR — `api-creator` (scaffold new APIs) and `test-checker` (audit & fill existing unit tests) — for a backend project: extract the proven gated, test-first methodology and fill in THIS project's own conventions (layers, base classes, auth, DTO/serialization, folder layout, test framework, verify commands). Both skills share one discovered recipe so they stay consistent. Use whenever the user wants to "set up api-creator here", "port the api-creator/test-checker skills to this project", "bootstrap the API + test skills for this repo", or bring one project's API + test conventions into another as reusable skills. Do NOT use this to actually build an API or audit tests in the current project (that is the generated skills' job), nor to edit an existing skill (use skill-creator / skill-ops)./axum-bootstrapScaffolds a Rust axum 0.8 + SeaORM 2.0 + PostgreSQL 16 backend from zero, standalone or apps/api monorepo. House convention: DDD-lite domains with Admin/Client route groups, fail-fast env validation, three utoipa OpenAPI docs with Swagger UI, tracing JSON logs, a Docker image, tests against a real Postgres. Phase 0 decides standalone (Cargo workspace at the repo root) or apps/api in a pnpm monorepo next to packages/contracts. Use when the user wants to start, set up or scaffold a new axum or Rust backend with this stack: "러스트 백엔드 새로 세팅해줘", "axum 프로젝트 만들어줘", "sea-orm 붙여서 rust api 서버 깔아줘", "bootstrap an axum backend", "scaffold a Rust API with SeaORM and Postgres", "set up apps/api in Rust". Do NOT use for: adding a domain to an existing axum project (use axum-domain-module), writing a SeaORM migration (use axum-migration), NestJS or FastAPI backends (nestjs-bootstrap / fastapi-bootstrap), the whole multi-app bootstrap chain (project-setup), or other Rust frameworks such as actix-web, rocket, poem or loco.Other plugins' skills for the same job