analyze-migrations
Analyze database migration files for safety issues before applying them to production. Use when the user says "check my migrations for safety issues", "review my database migrations", "are these migrations safe to run in production", "analyze my schema changes for locks or data loss", "scan my migration files for dangerous patterns", or "will this migration cause downtime".
What this skill does
# Migration Safety Analyzer Statically analyze database migration files to detect patterns that cause table locks, data loss, or production outages before they reach production. ## Step 1: Detect migration framework and locate files Scan the repository for migration file patterns: | Framework | Path pattern | File pattern | | ------------------ | -------------------------------------------------------- | -------------------------- | | Prisma | `prisma/migrations/` | `migration.sql` | | Rails/ActiveRecord | `db/migrate/` | `*.rb` | | Django | `*/migrations/` | `[0-9]*.py` | | Flyway | `src/main/resources/db/migration/`, `migrations/`, `db/` | `V*.sql`, `R*.sql` | | Alembic | `alembic/versions/`, `migrations/versions/` | `*.py` | | Drizzle | `drizzle/`, `src/db/migrations/` | `*.sql` | | TypeORM | `src/migrations/`, `migrations/` | `*.ts`, `*.js` | | Liquibase | `src/main/resources/db/changelog/` | `*.xml`, `*.yaml`, `*.sql` | If the user specifies a path or framework, use that. Otherwise auto-detect by searching for these patterns with Glob and Grep. Report which framework was detected and how many migration files were found. If no migrations are found, report that clearly and stop. Scope: analyze the 20 most-recent migrations by filename sort order (timestamp prefix is standard for all frameworks). If the user requests a specific migration or range, use that instead. ## Step 2: Build migration inventory For each migration file in scope: - Record the filename, detected framework, and direction (up/forward/apply vs. down/rollback/revert) - Note whether a corresponding rollback migration exists (critical gap if missing for destructive operations) - Extract the raw SQL or ORM operation list For ORM-based migrations (Rails, Django, Alembic, TypeORM), translate operations to their SQL equivalents before analysis: - `add_column` → `ALTER TABLE ... ADD COLUMN` - `remove_column` → `ALTER TABLE ... DROP COLUMN` - `change_column` / `alter_column` → `ALTER TABLE ... ALTER COLUMN` - `add_index` → `CREATE INDEX` - `create_table` → `CREATE TABLE` ## Step 3: Static safety analysis Analyze each migration for the following patterns. Evaluate against both PostgreSQL and MySQL semantics unless the stack is known. ### CRITICAL — causes table locks or data loss | Pattern | Risk | Detection | | ------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | | `ADD COLUMN ... NOT NULL` without `DEFAULT` | Full table rewrite lock (PostgreSQL < 11, MySQL < 8.0) | SQL: `ADD COLUMN` + `NOT NULL` + no `DEFAULT`; Rails: `add_column` with `null: false` and no `default:` | | `DROP COLUMN` | Irreversible data loss | SQL: `DROP COLUMN`; Rails: `remove_column`; Django: `RemoveField` | | `DROP TABLE` | Irreversible data loss | Any framework | | `TRUNCATE` | Irreversible data loss | SQL keyword scan | | `ALTER COLUMN` type change | Data corruption or lock | Type mismatch (e.g., `varchar` → `int`, `text` → `varchar(255)` shrink) | | `RENAME TABLE` without deploy coordination | App breakage during deploy | SQL: `RENAME TABLE`, `ALTER TABLE ... RENAME TO` | ### WARNING — potential downtime or deployment risk | Pattern | Risk | Detection | | -------------------------------------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | Missing rollback migration | Cannot undo if deploy fails | No corresponding down/revert file for migration with destructive ops | | FK column without index | Slow queries and lock escalation | `REFERENCES` keyword or `ForeignKeyConstraint` without subsequent `CREATE INDEX` on the referencing column | | `RENAME COLUMN` without multi-phase deploy | App reads old name during deploy window | SQL: `ALTER TABLE ... RENAME COLUMN`; Rails: `rename_column` | | Enum type changes | Breaks existing values or requires lock | `ALTER TYPE ... ADD VALUE`, `ENUM(...)` redefinition, `choices=` changes in Django without migration | | `ALTER TABLE` adding index without `CONCURRENTLY` (PostgreSQL) | Table lock during index build | `CREATE INDEX` without `CONCURRENTLY`; `add_index` without `algorithm: :concurrently` | | `ALTER TABLE` without `ALGORITHM=INPLACE, LOCK=NONE` (MySQL) | May fall back to full copy | MySQL-targeted migrations using `ALTER TABLE` on large tables | | Bulk `UPDATE` / `DELETE` without batch limit | Lock escalation and long transaction | SQL: `UPDATE ... WHERE` or `DELETE ... WHERE` without `LIMIT`; row estimate > 10k | | `NOT NULL` constraint added to existing column | Requires full table scan | Changing existing nullable column to NOT NULL without prior data cleanup | ### INFO — worth reviewing | Pattern | Risk | Detection | | ---------------------------------------------------- | -------------------------- | ------------------------------------------------------------ | | New unique constraint | Lock during validation | `ADD CONSTRAINT ... UNIQUE`, `add_index unique: true` | | `ADD COLUMN` with `DEFAULT` expression (non-literal) | May evaluate per-row | `DEFAULT now()`, `DEFAULT gen_random_uuid()` on large tables | | Migration with no rollback and no destructive ops | Low risk but note | Standard informational | | Multiple DDL statements in one migration | Harder to retry on failure | Count `ALTER TABLE`, `CREATE`, `DROP` statements | ## Step 4: Generate safety report Structure the output as a migration safety report grouped by severity. **Header**: framework detected, files analyzed, analysis date. **CRITICAL findings** (if any): formatted as: ``` [CRITICAL] <migration-filename>:<line> Pattern: <what was found> Risk: <what can go wrong in production> Safe alternative: <concrete rewrite or multi-step approach> ``` **WARNING
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.