alembic

alembic is a cursor rule for Cursor from bernierllc/agents-environment-config. It costs 0 tokens per session (585 once invoked), scanned A, original, MIT.

Rules for Alembic, a tool that records changes to a database's structure for Python projects using SQLAlchemy. These recorded changes are called migrations.

In plain words
What is it for?
It is for writing and managing Alembic migrations in Python applications that use SQLAlchemy.
Why use it?
They help database structure changes follow consistent patterns and conventions instead of being handled differently across the project.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It is for writing and managing Alembic migrations in Python applications that use SQLAlchemy.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/bernierllc/agents-environment-config/alembic
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.

Clone the repo
git clone --depth 1 https://github.com/bernierllc/agents-environment-config

Made for: Cursor.

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

README.md
[![agentmods](https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/alembic/github.svg)](https://agentmods.dev/rules/bernierllc/agents-environment-config/alembic)
Your own site
<a href="https://agentmods.dev/rules/bernierllc/agents-environment-config/alembic"><img src="https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/alembic/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

Your own site · 80×15
<a href="https://agentmods.dev/rules/bernierllc/agents-environment-config/alembic"><img src="https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/alembic.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 585 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.00000 $0.00585
Opus 5.5 $0.00000 $0.00234
Sonnet 5.5 $0.00000 $0.00117
Haiku 4.5 $0.00000 $0.00059

Measured 1mo ago against content hash b5909d0eef17, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

alembic 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 1mo 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.

.cursor/rules/frameworks/database/alembic.mdc · 101 lines

How it starts

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

Alembic Migration Rules

Command Usage

Standard Commands

Use python manage.py or make for all database tasks:

# Create migration
make makemigration m="add foo"
# or
python manage.py makemigration -m "add foo"

# Apply migrations
make migrate
# or
python manage.py migrate

# Reset DB (dev only!)
make reset
# or
python manage.py reset

# Seed DB
make seed
# or
python manage.py seed

Migration Best Practices

Autogenerate Migrations

  • Autogenerate always works (all models imported in env.py)
  • Review autogenerated migrations before applying
  • Never auto-generate without review
  • Manual migration review ensures correctness

Database Configuration

  • DB URL is always read from app config, not alembic.ini
  • Use environment variables for database URLs
  • Different URLs for different environments

Migration Management

  • Alembic revision every PR - Create migrations for each pull request
  • Never auto-generate without review - Always review generated migrations
  • Manual migration review ensures correctness

Migration Workflow

  1. Make schema changes in SQLAlchemy models
  2. Generate migration: python manage.py makemigration -m "description"
  3. Review migration file - Check generated SQL
  4. Test migration: Apply to development database
  5. Commit migration with code changes

Common Patterns

Adding a Column

# Migration file
def upgrade():
    op.add_column('users', sa.Column('email', sa.String(), nullable=True))

def downgrade():
    op.drop_column('users', 'email')

Creating a Table

def upgrade():
    op.create_table(
        'users',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id')
    )

def downgrade():
    op.drop_table('users')

Best Practices

  1. Review all migrations before applying
  2. Test migrations on development database first
  3. Keep migrations small and focused
  4. Never edit existing migrations (create new ones)
  5. Document migrations with clear descriptions

Read the full file on GitHub · 101 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. 1mo ago First seen · 101 lines · 0 tokens per session scan A b5909d0eef17

Subscribe to this mod's changes

alembic is a cursor rule published in the GitHub repository bernierllc/agents-environment-config (11 stars, last pushed 10d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 585 tokens. 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.