alembic-migrations

alembic-migrations is a skill for Claude Code from robhowley/py-pit-skills. It costs 56 tokens per session (1,755 once invoked), scanned A, original, MIT.

A workflow for changing a database structure safely in Python projects that use SQLAlchemy, a library for working with databases, and Alembic, a database migration tool.

In plain words
What is it for?
Use it when adding Alembic, creating or reviewing database migrations, fixing migration problems, or setting up controlled schema changes.
Why use it?
It reduces the risk of lost data, empty migrations, broken migration history, and unsafe schema changes.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the py-pit plugin — 16 skills, 1 hook shipped together

Good fit Use it when adding Alembic, creating or reviewing database migrations, fixing migration problems, or setting up controlled schema changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/robhowley/py-pit-skills/alembic-migrations
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add robhowley/py-pit-skills --skill alembic-migrations
Clone the repo
git clone --depth 1 https://github.com/robhowley/py-pit-skills

Made for: Claude Code.

Or install py-pit, the plugin that ships this one along with the rest of its 16 skills, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for alembic-migrations

README.md
[![agentmods](https://agentmods.dev/badge/skills/robhowley/py-pit-skills/alembic-migrations/github.svg)](https://agentmods.dev/skills/robhowley/py-pit-skills/alembic-migrations)
Your own site
<a href="https://agentmods.dev/skills/robhowley/py-pit-skills/alembic-migrations"><img src="https://agentmods.dev/badge/skills/robhowley/py-pit-skills/alembic-migrations/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for alembic-migrations

Your own site · 80×15
<a href="https://agentmods.dev/skills/robhowley/py-pit-skills/alembic-migrations"><img src="https://agentmods.dev/badge/skills/robhowley/py-pit-skills/alembic-migrations.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,755 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00056 $0.01755
Opus 5 $0.00028 $0.00877
Sonnet 5 $0.00011 $0.00351
Haiku 4.5 $0.00006 $0.00176

Measured 9d ago against content hash d4b6cc4b08bd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

alembic-migrations scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/alembic-migrations/SKILL.md · 384 lines

How it starts

The opening of the file, as written. The whole thing — 384 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Skill: alembic-migrations

Core position

This skill establishes safe, disciplined database migration workflows using Alembic in SQLAlchemy 2.x projects.

Autogenerate output is treated as a draft, never final truth. All migrations must be reviewable, deterministic, and safe for production.

The skill prevents common failures such as:

  • empty autogenerate revisions
  • rename → drop/create data loss
  • broken env.py metadata wiring
  • migration history divergence
  • unsafe schema changes

Py-pit enforcement rules

These rules are always applied when generating or reviewing migrations.

1. Model import guarantee

Alembic only detects models that are imported at runtime.

A canonical module must import every ORM model so metadata is complete.

Do not assume app/. Use the project's existing Base definition -- typically at {pkg_name}/db/base.py (see sqlalchemy-models skill).

Example:

# {pkg_name}/models/__init__.py
from {pkg_name}.models.user import User
from {pkg_name}.models.order import Order

Alembic must reference:

from {pkg_name}.db.base import Base

target_metadata = Base.metadata

This prevents empty migrations, the most common Alembic failure.


2. Rename correction rule

Alembic cannot detect column renames.

If autogenerate emits:

drop_column
add_column

for the same table in one revision, treat it as a rename.

Replace with:

op.alter_column("table", "old_name", new_column_name="new_name")

This prevents silent data loss.


3. Applied migration immutability

Never edit a migration that has already been applied.

Correct pattern:

revision A (applied)
revision B (fix)

Never:

edit revision A

Editing applied migrations breaks migration graphs across environments.

Read the full file on GitHub · 384 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 384 lines · 56 tokens per session scan A d4b6cc4b08bd

Subscribe to this mod's changes

alembic-migrations is a skill published in the GitHub repository robhowley/py-pit-skills (5 stars, last pushed 5mo ago), licensed MIT. It adds 56 tokens to every session and 1,755 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories