db-migrate
DB Migrate
Cross-Platform AI Agent Skill This skill works with any AI agent platform that supports the skills.sh standard.
Create, validate, and run database migrations across any framework. Auto-detects the migration tool from project files.
Anti-Hallucination Guidelines
CRITICAL: Migration operations can be irreversible in production:
- Detect before acting — Always scan for marker files before running any command
- Never invent commands — Only use commands listed in the detection table or discovered in project docs
- Warn on destructive operations — Always flag DROP, TRUNCATE, or irreversible schema changes
- Dry-run first — Use
--dry-runmode when supported by the framework - Read existing migrations — Check naming conventions before creating new ones
Workflow
Phase 1: Detect Framework
Scan for marker files to identify the migration framework:
# Check for common marker files
ls alembic.ini 2>/dev/null
ls prisma/schema.prisma 2>/dev/null
ls knexfile.* 2>/dev/null
ls flyway.conf 2>/dev/null
ls db/migrate/ 2>/dev/null
ls manage.py 2>/dev/null
ls atlas.hcl 2>/dev/null
Also check:
package.jsonforknex,db-migrate,sequelize,typeormdependenciespyproject.toml/requirements.txtforalembic,sqlalchemyGemfileforactiverecord
If multiple frameworks detected, ask user which one to use. If none detected, ask user to specify.
Refer to references/framework-commands.md for the full detection table and per-framework commands.
Phase 2: Parse Arguments
Determine operation mode from $ARGUMENTS:
create(or no argument): Create a new migration filestatus: Show pending and applied migrationsvalidate: Check rollback scripts, naming conventions, index coverage
If --name <name> provided, use it for migration name. Otherwise ask for a descriptive name.
If --dry-run provided, show what would be created/run without executing.
Phase 3: Execute Operation
create — New Migration
- Check naming conventions in existing migrations (Glob
migrations/,db/migrate/) — infer pattern - Generate timestamp prefix:
date +%Y%m%d%H%M%S - Run framework-native CLI to create the migration file
- Verify file was created — read and display it to the user
- If autogenerate is available (Alembic, Prisma): generate from schema diff
After creation, remind user to:
- Review the generated migration for correctness
- Add rollback/down script if not auto-generated
- Add indexes for any new foreign keys
status — Pending Migrations
Run the framework's status command and display:
- Applied migrations (with timestamps)
- Pending migrations (not yet applied)
- Current database schema version
validate — Migration Quality Check
Check the following:
- Rollback exists: Every
upmigration has adownscript (warn if missing) - Naming convention: All files follow the project's timestamp + description pattern
- Foreign key indexes: Grep for
REFERENCESor foreign key declarations without correspondingCREATE INDEX - Destructive operations: Grep for
DROP TABLE,DROP COLUMN,TRUNCATE— flag each one - Data migrations vs schema migrations: Warn if both data and schema changes exist in one file
Phase 4: Safety Checks
Always run these before finalizing a create operation:
Destructive operation detection:
grep -iE "DROP TABLE|DROP COLUMN|TRUNCATE|DELETE FROM" <migration_file>
If found: warn user, require explicit confirmation to proceed.
Missing index check:
grep -iE "REFERENCES|foreign_key|FK_" <migration_file>
If foreign keys present, check for corresponding index creation.
Rollback verification:
- Check if the migration has both up and down sections
- For autogenerated migrations (Prisma, Alembic): verify the shadow database check passes
Phase 5: Report
Display a summary of what was created or checked:
- File path of new migration
- Migration name and timestamp
- Any warnings (destructive ops, missing rollbacks, missing indexes)
- Next steps (apply with
<command>, rollback with<command>)
Argument Parsing
create: Create a new migration (default if no subcommand given)status: Show migration statusvalidate: Validate existing migrations--name <name>: Migration description for the filename--dry-run: Show what would happen without executing
Important Notes
- Always review auto-generated migrations before applying — they may include unintended changes
- Rollback scripts are required for production safety; warn loudly if missing
- Never run migrations directly against production without a backup
- Prisma shadow database: Prisma dev migrations use a shadow DB; ensure
DATABASE_URLis not production - Transaction wrapping: Ensure migrations run in transactions for atomicity
Examples
# Create a new migration
/db-migrate create --name add_users_table
# Check pending migrations
/db-migrate status
# Validate migration quality
/db-migrate validate
# Create without executing (preview)
/db-migrate create --name drop_legacy_column --dry-run
More from mgiovani/cc-arsenal
find-skills
Discover and install third-party agent skills from the skills.sh ecosystem.
35agent-browser
Headless browser automation CLI optimized for AI agents. Uses snapshot + refs system for 93% less context overhead vs Playwright. Purpose-built for web testing, form automation, screenshots, and data extraction.
12jira-cli
Interactive CLI for Atlassian Jira issue, epic, and sprint management.
9refactor
Safe codebase refactoring with characterization tests, incremental changes, and continuous verification. Automatically activates when users want to refactor code, extract methods/classes, simplify logic, reduce duplication, improve naming, restructure modules, or clean up technical debt.
7inject-docs
Inject framework-specific best practices into CLAUDE.md. Supports Next.js
6jira-todo
Generate smart daily work plans with intelligent prioritization from
6