.claude/skills/database-migration-safety/SKILL.md
# Skill: Database Migration Safety ## When to Load Auto-load when: working with Alembic, raw SQL migrations, schema changes, `migrations/` directory, or `*.sql` files. Triggers on `alembic`, `migration`, `upgrade`, `downgrade`, `schema`, `ALTER TABLE` (≥2 keywords). ## Core Rules Every migration must satisfy these requirements before `alembic upgrade head` runs: 1. **Reversible** — `downgrade()` must be implemented and tested. `pass` is not acceptable. 2. **Staged** — run against a staging/
npx skillsauth add pyramidheadshark/ml-claude-infra .claude/skills/database-migration-safetyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Auto-load when: working with Alembic, raw SQL migrations, schema changes, migrations/ directory, or *.sql files. Triggers on alembic, migration, upgrade, downgrade, schema, ALTER TABLE (≥2 keywords).
Every migration must satisfy these requirements before alembic upgrade head runs:
downgrade() must be implemented and tested. pass is not acceptable.Before proposing or executing any migration:
[ ] downgrade() is implemented (not pass)
[ ] Migration tested on staging DB
[ ] For tables > 100k rows: migration is non-locking (CONCURRENT index, batched updates)
[ ] No data loss without explicit acknowledgment: DROP COLUMN, TRUNCATE, type narrowing
[ ] --autogenerate output reviewed manually (it misses: renames, indexes, check constraints)
[ ] Rollback plan documented: "If this fails in prod, run: alembic downgrade -1"
| Anti-Pattern | Risk | Required Action |
|---|---|---|
| downgrade() is pass | Irreversible migration | Implement downgrade or get explicit sign-off |
| DROP COLUMN without nullable grace period | Data loss on rollback | Add nullable=True first, drop in next release |
| --autogenerate applied without review | Silent schema drift | Always diff before apply |
| alembic upgrade head in prod without staging | Broken prod schema | Require staging run first |
| Locking ALTER TABLE on large table | Table lock, downtime | Use CREATE INDEX CONCURRENTLY, batched UPDATE |
| Migration touches multiple unrelated models | Hard to rollback atomically | Split into separate migrations |
--autogenerate misses the following — always check manually:
server_default changesCheckConstraint)Safe pattern for removing a column:
nullable=True, remove from ORM modelDROP COLUMNWhen this skill is active, append to analysis:
[MigSafety]: BLOCK|WARN|CLEAR — [specific risk identified] -> [required action]
Examples:
[MigSafety]: BLOCK — downgrade() is pass on 2M-row table -> implement downgrade or get explicit sign-off[MigSafety]: WARN — no staging run documented -> confirm staging test before prod apply[MigSafety]: CLEAR — evaluated: downgrade implemented, staging confirmed, no locking opsADD COLUMN NOT NULL DEFAULT on small tables (< 10k rows) — low riskCONCURRENTLY — already non-lockingtesting
# Design Doc Creator ## When to Load This Skill Load when: design documents, requirements, new project start. Short fixture skill for testing (optional/meta skill).
development
# Windows Developer Guide ## When to Load Automatically loaded on Windows (`platform_trigger: "win32"`). Applies to: `.py`, `.ps1`, `.bat`, `.cmd` files and any Windows-specific workflow. ## Python on Windows ### Encoding (CRITICAL) Windows defaults to `cp1251` / `cp1252` for file I/O. Always specify UTF-8 explicitly: ```python with open("file.txt", "r", encoding="utf-8") as f: content = f.read() Path("file.txt").read_text(encoding="utf-8") Path("file.txt").write_text(content, encodin
development
# Test-First Patterns ## When to Load This Skill Load when writing tests, creating `.feature` files, setting up conftest, discussing test strategy, or reviewing coverage. ## Philosophy Tests are written BEFORE code. Always. No exceptions. The order is: Design Doc → BDD Scenarios → Unit Tests → Implementation. BDD scenarios come from the design document's use cases section — they are a direct translation of business requirements into executable specifications. This makes tests the living do
testing
# Skill: Supply Chain Auditor ## When to Load Auto-load when: adding dependencies, reviewing packages, updating versions, or discussing `requirements.txt`, `pyproject.toml`, `package.json`. Triggers on `dependency`, `install`, `package`, `CVE`, `audit`, `vulnerable` (≥2 keywords). ## Core Rules Every new dependency addition must pass this checklist before merging: 1. **Pinned** — exact version in production (`==1.2.3` for pip, `"1.2.3"` for npm, not `^` or `~`). 2. **Maintained** — last com