Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Alembic

$ alembic Community Med Risk
SQLAlchemy · Database & Data · MIT · macos / linux / windows

alembic is the standard schema migration tool for SQLAlchemy projects. It inspects live database state (alembic current), lists revision graphs (alembic history), autogenerates Python migration scripts (revision --autogenerate), and emits dry-run DDL via --sql offline mode.

FCRS-1.0 Score
80 /100
Good
Medium Confidence
Zero-Friction Install
pip install alembic
CLI vs MCP Decision CLI Only

alembic imports your repository's SQLAlchemy Base.metadata models and env.py directly from Python; MCP cannot substitute for local project code evaluation.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
✓ Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 18 / 25

Runs completely non-interactively with --sql offline SQL generation, current, and history, though outputs are plain text/SQL rather than --json.

  • Non-interactive CLI with --sql offline preview; no --json output
Trust & Safety 21 / 25

--sql offline mode enables pure DDL review without DB writes, and revision --autogenerate produces reviewable Python files before execution.

  • --sql offline mode generates SQL scripts without mutating the database
Setup & Portability 13 / 15

Standard PyPI package installed in the project's Python virtualenv across macOS, Linux, and Windows.

  • Distributed on PyPI (alembic); runs inside project Python env
Utility & Efficiency 13 / 15

Integrates SQLAlchemy model diffing, branching/merge revision histories, and offline DBA SQL export.

  • Supports --autogenerate, branching (branches/merge), and --sql offline output
Maintenance & Lineage 8 / 10

Official SQLAlchemy project (sqlalchemy/alembic) under MIT license.

  • Official sqlalchemy/alembic repository under MIT
Docs & Verifiability 7 / 10

Thorough CLI and cookbook documentation at alembic.sqlalchemy.org.

  • Official docs at alembic.sqlalchemy.org

Security, Auth & Guardrails

Auth Modes
Config File Env API Key
Credential Storage

Configured via alembic.ini (sqlalchemy.url) or Python env.py reading DATABASE_URL / app settings from the environment.

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

100% free and MIT open-source.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# Alembic Agent Rules
- Always inspect generated `--autogenerate` scripts before running `alembic upgrade head`.
- Use `alembic upgrade <from>:<to> --sql` to preview generated DDL offline before applying to shared DBs.
- Never commit plaintext credentials into `alembic.ini`; inject `sqlalchemy.url` in `env.py` from env vars.

Agent-Ready Command Recipes

Safe Read-Only Queries

Check current database revision
alembic current

Queries alembic_version and reports the active revision ID(s) on the target database.

Preview upgrade DDL without executing (--sql)
alembic upgrade head --sql

Generates the raw SQL DDL statements for all pending migrations in offline mode without touching the DB.

Controlled Writes & Previews

Autogenerate a migration from SQLAlchemy models
alembic revision --autogenerate -m "add_user_index"

Diffs target_metadata against the live DB and writes a Python revision file for review.

Strengths for Agents

  • + --sql offline mode outputs exact migration DDL for review before execution.
  • + revision --autogenerate detects model changes against the database schema automatically.

Caveats & Pitfalls

  • ! No --json output mode on current, history, or heads.
  • ! Requires the project's Python virtual environment and database drivers to evaluate env.py.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI