# Alembic migrations

> Alembic migrations is an open-source agent skill for databases. Guides an agent through Alembic migrations for async SQLAlchemy and PostgreSQL projects. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ajyadav013/claude-kit/tree/main/providers/codex/claude-kit/skills/alembic-migrations
- **Repository:** https://github.com/ajyadav013/claude-kit
- **GitHub stars:** 13
- **License:** MIT
- **Skill name:** alembic-migrations
- **Collection:** https://github.com/ajyadav013/claude-kit
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-12-03

## About

This skill gives an agent a set of conventions for setting up and running Alembic with async SQLAlchemy on asyncpg. It covers wiring an async engine into env.py through run_sync, configuring autogenerate with type comparison and filtering of internal tables, and writing upgrade and downgrade functions for schema changes and data migrations.

The guidance also includes a pattern for enabling Row-Level Security and tenant isolation policies in migrations, with matching downgrade steps. It lists common migration errors such as missing revisions and multiple heads, along with a command reference for init, revision, upgrade, downgrade, history and stamp.

The skill expects a Python project using SQLAlchemy and PostgreSQL through asyncpg. It ships no scripts; the agent works directly with the project's alembic.ini, env.py and version files.

## When your agent uses it

> Alembic migration setup and patterns for async SQLAlchemy — async engine + run_sync in env.py, autogenerate, RLS/multi-tenant migrations. Use for alembic init, writing migrations, or debugging migration errors.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ajyadav013/claude-kit/tree/HEAD/providers/codex/claude-kit/skills/alembic-migrations)
- [License: MIT](https://github.com/ajyadav013/claude-kit/tree/HEAD/providers/codex/claude-kit/skills/alembic-migrations)

## Features

- **Async env.py setup:** Shows how to wire an async engine into Alembic's env.py using run_sync and a NullPool.
- **Autogenerate configuration:** Covers autogenerate workflow, type comparison and excluding internal tables with an include_object callback.
- **Row-level security migrations:** Provides a pattern for enabling tenant-scoped RLS policies and reversing them on downgrade.
- **Revision naming and structure:** Describes sequential, timestamp-hash and generated revision naming and the standard migration file layout.
- **Migration troubleshooting:** Lists frequent errors such as multiple heads and revisions that cannot be located, with fix guidance.
- **Command reference:** Summarizes the Alembic CLI commands for initializing, revising, upgrading, downgrading and inspecting history.

## Good for

- Set up Alembic for a new async FastAPI and SQLAlchemy project
- Generate an autogenerated migration after changing SQLAlchemy models
- Add tenant isolation with row-level security policies to existing tables
- Debug a 'multiple heads' or 'can't locate revision' Alembic error
- Write a data backfill migration with a working downgrade

## Install

### Claude Code

This skill ships in the `claude-kit` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ajyadav013/claude-kit
/plugin install claude-kit@claude-kit
```

Or copy only this skill to `~/.claude/skills/alembic-migrations`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/alembic-migrations &&
cp -R "$tmp/providers/codex/claude-kit/skills/alembic-migrations" ~/.claude/skills/alembic-migrations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/alembic-migrations` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/alembic-migrations` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/alembic-migrations &&
cp -R "$tmp/providers/codex/claude-kit/skills/alembic-migrations" ~/.agents/skills/alembic-migrations &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/alembic-migrations` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/alembic-migrations` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/alembic-migrations &&
cp -R "$tmp/providers/codex/claude-kit/skills/alembic-migrations" ~/.cursor/skills/alembic-migrations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/alembic-migrations` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ajyadav013/claude-kit.git --path providers/codex/claude-kit/skills/alembic-migrations
```

Or copy the folder to `~/.gemini/skills/alembic-migrations` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/alembic-migrations`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/alembic-migrations &&
cp -R "$tmp/providers/codex/claude-kit/skills/alembic-migrations" ~/.copilot/skills/alembic-migrations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/alembic-migrations` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git
```

Then copy `claude-kit/providers/codex/claude-kit/skills/alembic-migrations` into your agent's skills folder as `alembic-migrations`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does Alembic migrations need to run?

It targets Python projects using async SQLAlchemy with asyncpg on PostgreSQL. It includes no scripts, so the agent works with the project's own Alembic files.

### Does Alembic migrations work with non-async SQLAlchemy projects?

The patterns are built around async engines and run_sync. Sync projects are not the focus, and the skill warns against using a sync engine in async projects.

### When does the skill trigger?

It is meant for tasks such as running alembic init, writing migrations, or debugging migration errors in an async SQLAlchemy codebase.

### How do I install Alembic migrations in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/alembic-migrations to use it in all your projects, or to .claude/skills/alembic-migrations in one project. Or install the claude-kit plugin, which includes it: /plugin marketplace add ajyadav013/claude-kit, then /plugin install claude-kit@claude-kit.

### Does Alembic migrations run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Alembic migrations?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Alembic migrations?

The closest alternatives to Alembic migrations are Alembic knowledge patch, Database migrations, Database migrations, Postgres database migration and Postgres.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Alembic knowledge patch](https://ai-powered.com/skills/alembic-knowledge-patch): Alembic knowledge patch is an open-source agent skill for databases.
- [Database migrations](https://ai-powered.com/skills/database-migrations-nabwinsaud): Database migrations is an open-source agent skill for databases.
- [Database migrations](https://ai-powered.com/skills/database-migrations): Database migrations is an open-source agent skill for databases.
- [Postgres database migration](https://ai-powered.com/skills/postgres-database-migration): Postgres database migration is an open-source agent skill for databases.
- [Postgres](https://ai-powered.com/skills/postgres-timescale): Postgres is an open-source agent skill for databases.
- [Data layer patterns edho ferdian](https://ai-powered.com/skills/data-layer-patterns-edho-ferdian): Data layer patterns edho ferdian is an open-source agent skill for databases.
- [Db migration agent](https://ai-powered.com/skills/db-migration-agent): Db migration agent is an open-source agent skill for databases.
- [Design postgres tables](https://ai-powered.com/skills/design-postgres-tables): Design postgres tables is an open-source agent skill for databases.

---
Source: https://ai-powered.com/skills/alembic-migrations
