agentleFS
michaelalbermichaelalber/ai-toolkit/skills/alembic-migration-manager/SKILL.md

alembic-migration-manager

Skill3 starsChanged 4 months agoMITView on GitHub

Manages the full Alembic migration lifecycle with safety checks and rollback planning. Python analog of ef-migration-manager. Use when creating, reviewing, or applying database migrations in Python projects using SQLAlchemy and Alembic.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    NEVER APPLY WITHOUT SQL REVIEW — alembic upgrade head --sql before alembic upgrade head.

    line 25

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Alembic Migration Manager

"Every migration is a one-way door. Make sure you know what's on the other side. The database is the last line of defense — treat every schema change as if it cannot be undone."

Core Philosophy

Database migrations are the most dangerous routine operation in software development. A bad deployment can be rolled back; a bad migration that drops a column or corrupts data cannot be undone without a backup restore — and restores take time production systems do not have. This skill manages the Alembic lifecycle with the same safety philosophy as ef-migration-manager and sqlx-migration-manager: review the generated SQL before applying, verify the rollback first, and keep each migration to one concern.

Non-Negotiable Constraints:

  1. NEVER APPLY WITHOUT SQL REVIEW — alembic upgrade head --sql before alembic upgrade head.
  2. VERIFIED DOWNGRADE — every upgrade() has a downgrade() tested on a dev database before applying upstream.
  3. DATA PRESERVATION — any migration that could lose data requires explicit confirmation and a backup.
  4. ONE CONCERN PER MIGRATION — add-column + create-index + backfill is three migrations, not one.
  5. IDEMPOTENT-SAFE — migrations are safe to run on a database already at the target state.

Full principle table, KB lookups, command sequences, anti-patterns, discipline rules, and error recovery live in references/conventions.md.

Workflow

PLAN          Identify the model change; assess data-loss risk; identify zero-downtime needs; plan
              the downgrade; decide one migration or several (schema vs. data backfill).
              Run: alembic current · alembic history · alembic check (must be clean).

GENERATE      alembic revision --autogenerate -m "descriptive_name"  (or empty for manual/data).
              STOP and review the generated file — autogenerate misses views/triggers, equivalent
              type changes, custom-named indexes, sequences (see conventions.md).

REVIEW SQL    alembic upgrade head --sql  AND  alembic downgrade -1 --sql. Verify: matches intent,
              no unexpected DROP/data loss, acceptable locks. (Lock detail: dangerous-operations.md.)

TEST ROLLBACK On dev only: upgrade head → verify → downgrade -1 → verify returns to prior state →
              upgrade head again. (Checklists: migration-safety-checklist.md.)

APPLY         alembic upgrade head → alembic current to confirm. Roll back with downgrade -1 if needed.

Exit criteria: alembic check clean before generate; generated file and upgrade/downgrade SQL reviewed; rollback tested on dev; applied and confirmed via alembic current; the revision chain remains linear.

State Block

<alembic-migration-state>
phase: PLAN | GENERATE | REVIEW_SQL | TEST_ROLLBACK | APPLY | COMPLETE
migration_name: [descriptive name]
data_loss_risk: none | low | medium | high
zero_downtime_required: true | false
sql_reviewed: true | false
rollback_tested: true | false
current_revision: [revision ID or "head"]
target_revision: [revision ID or "head"]
last_action: [description]
next_action: [description]
</alembic-migration-state>

Output Template

  • Migration review checklist, rollback verification — references/output-templates.md.
  • Per-operation locking/data-loss detail by database — references/dangerous-operations.md.
  • Pre/post-apply checklists, rollback sequence — references/migration-safety-checklist.md.
  • Principle table, KB lookups, command sequences, anti-patterns, discipline rules, error recovery — references/conventions.md.

Integration with Other Skills

SkillRelationship
python-feature-sliceWhen a feature needs schema changes, use this skill for the migration lifecycle.
python-architecture-checklistMay identify schema design issues before migrations are generated.
python-security-reviewMigration files may carry sensitive defaults/seed data — review for CUI and credentials.
ef-migration-manager / sqlx-migration-managerCross-references for .NET and Rust stacks — identical safety philosophy, different tooling.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.