/mattpocock-skills:expand-contractfrom mattpocock-skills
Plan and execute zero-downtime database schema migrations, breaking API changes, or wide refactors using the Expand-Contract pattern. Use when modifying database schemas, altering API contracts, or refactoring high-blast-radius code.
Ships in mattpocock-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
Add the new capability or schema element alongside the old one without breaking existing callers or data.
NOT NULL constraint without a default in this phase. Never drop or rename existing columns.Populate the new structure with historical data while the application runs normally.
Redirect reads and business logic to use the new structure, guarded by runtime controls.
Once all readers and writers have successfully operated on the new structure for a soak period with zero traffic hitting the old path:
NOT NULL, foreign keys, indexes) if required.Evaluate every phase against the door test:
/to-ticketsWhen called during ticket breakdown, decompose the work into sequential tickets with explicit blocking edges:
### Migration Plan: <Change Name>
1. **Ticket 1 [Expand]**: Add `<new_field_or_table>` to schema with default/nullability. Deploy dual-write logic in repository layer.
- Blocked by: None (can start immediately)
- Risk: Two-way door
2. **Ticket 2 [Backfill]**: Run batch backfill script to populate historical records. Verify parity across all environments.
- Blocked by: Ticket 1 [Expand]
- Risk: Two-way door
3. **Ticket 3 [Switch]**: Flip reads and downstream consumers to `<new_field_or_table>`, guarded by feature flag `ff_<feature_name>`.
- Blocked by: Ticket 2 [Backfill]
- Risk: Two-way door
4. **Ticket 4 [Contract]**: Remove old column/endpoints, remove feature flag branches, apply final schema constraints.
- Blocked by: Ticket 3 [Switch]
- Risk: One-way door (requires database backup confirmation)
/prWhen a PR touches a schema or API contract, summarize:
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub op3616windows/skills --plugin mattpocock-skills48 skills in this plugin
/ask-mattAsk which skill or flow fits your situation. A router over the skills in this repo./chief-of-staffPursue a long-running goal in a single session by co-ordinating subagents./claude-handoffHand the current conversation off to a fresh background agent that picks up the work immediately./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./code-reviewReview the changes since a fixed point (commit, branch, tag, or merge-base) along three axes: Standards (does the code follow this repo's documented coding standards?), Spec (does the code match what the originating issue/spec asked for?), and Security (does the code introduce AppSec or privacy vulnerabilities?). Runs all three reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X"./diagnosing-bugsDiagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.