typeorm-migrations

typeorm-migrations is a cursor rule for coding agents from J-Pster/Psters_AI_Workflow. It costs 1,132 tokens per session, scanned A, original, MIT.

A rule set for creating TypeORM database migrations, which are files that change a database schema over time. It requires using the TypeORM command-line tool and following generation, drift checking, local execution, and verification in order.

In plain words
What is it for?
Use it when entity changes require a TypeORM migration: generate it with the CLI, check it for unrelated differences, run it locally, and stop if it fails.
Why use it?
It helps prevent schema drift, where migrations are generated from an outdated database state and later contain incorrect or repeated changes.

Cursor rule

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.

agentmods
npx agentmods add rules/j-pster/psters_ai_workflow/typeorm-migrations
Clone the repo
git clone --depth 1 https://github.com/J-Pster/Psters_AI_Workflow

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 typeorm-migrations

README.md
[![agentmods](https://agentmods.dev/badge/rules/j-pster/psters_ai_workflow/typeorm-migrations.svg)](https://agentmods.dev/rules/j-pster/psters_ai_workflow/typeorm-migrations)
Your own site
<a href="https://agentmods.dev/rules/j-pster/psters_ai_workflow/typeorm-migrations"><img src="https://agentmods.dev/badge/rules/j-pster/psters_ai_workflow/typeorm-migrations.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,132 This file is loaded in full into every session.
When invoked 1,132 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.01132 $0.01132
Opus 5 $0.00566 $0.00566
Sonnet 5 $0.00226 $0.00226
Haiku 4.5 $0.00113 $0.00113

Measured 5d ago against content hash 99259bf6f02d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

typeorm-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 5d 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.

plugins/psters-ai-workflow/rules/typeorm-migrations.mdc · 123 lines

How it starts

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

TypeORM Migrations - CLI Only

CRITICAL: Always Use TypeORM CLI for Migrations

IMPORTANT: You MUST NEVER create migration files manually. Always use the TypeORM CLI to generate migrations automatically based on entity definitions.

CRITICAL: Generate → Drift-Check → Run IMMEDIATELY (Atomic Chain)

THIS IS THE #1 SOURCE OF PRODUCTION BUGS. When a migration is generated but NOT run on the local database immediately, the next typeorm:generate compares against the OLD schema and produces a migration with schema drift — it re-includes changes from the unrun migration plus new changes, creating a broken migration that will fail in production.

THE RULE: Every migration MUST be run on the local DB immediately after generation. Never defer. Never skip. Never "do it later."

The atomic chain (NEVER break this sequence):

1. Generate:     npm run typeorm:generate -- src/database/migrations/MigrationName
2. Drift-check:  Run schema-drift-detector agent on the new file → fix any unrelated changes
3. Run locally:  npm run typeorm:run  (or  npm run dev:migrate  for Docker)
4. Verify:       If typeorm:run fails → STOP. Fix the issue before continuing.

BLOCKING: Do NOT proceed to the next task, the next entity change, or the next migration until step 3 succeeds. If you need to generate a second migration in the same session, the first one MUST be run first.

Production deployment: Use project-specific migration scripts (e.g. npm run migrate:localtoprod) that:

  1. Run typeorm:run on local DB first (fails fast if local is broken)
  2. Run guard scripts to block schema dumps and wrong-baseline migrations
  3. Only then run migrations on the production DB

NEVER edit past migrations. If a migration is wrong, create a new corrective migration.

Why This Rule Exists

  1. Automatic Schema Detection: TypeORM CLI compares the current database schema with entity definitions and generates the exact SQL needed
  2. Consistency: Ensures migrations match entity definitions exactly
  3. Error Prevention: Avoids manual errors in SQL generation
  4. Drift Prevention: Running immediately keeps the local DB in sync so future generations are clean

Read the full file on GitHub · 123 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. 5d ago First seen · 123 lines · 1,132 tokens per session scan A 99259bf6f02d

Subscribe to this mod's changes

typeorm-migrations is a cursor rule published in the GitHub repository J-Pster/Psters_AI_Workflow (290 stars, last pushed 5mo ago), licensed MIT. It adds 1,132 tokens to every session, about $0.0057 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-30.