expand-contract
Installation
SKILL.md
Expand Contract
When modifying a database schema, public API contract, or shared core module, making the change in a single step causes downtime, runtime crashes, or massive merge conflicts.
This skill sequences changes using the Expand-Contract (or Parallel Run) pattern across four disciplined phases, ensuring old and new versions coexist safely during transitions.
The Four Migration Phases
Phase 1: Expand (Non-breaking Addition)
Add the new capability or schema element alongside the old one without breaking existing callers or data.
- Database: Add the new column or table as nullable or with a safe default. Never add a
NOT NULLconstraint without a default in this phase. Never drop or rename existing columns. - Application Code: Begin dual-writing to both the old and new columns or endpoints if both must stay updated.
- API: Add new fields or endpoints. Keep old fields and endpoints fully functional.
- Blast Radius: Zero. Old clients and queries run completely unchanged.
Phase 2: Backfill (Asynchronous Data Migration)
Populate the new structure with historical data while the application runs normally.