# Migration Writer

> Migration Writer is an Agent Skill for development published in the Archive228/loopkit repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Write safe, reversible database migrations for this repo's conventions. Use for any schema change.

- Skill name: `migration-writer`
- Category: [Development](https://www.openparable.com/skill/development/1)
- Source: https://github.com/Archive228/loopkit/blob/HEAD/skills/migration-writer/SKILL.md
- Repository: Archive228/loopkit (638 GitHub stars when collected)

## SKILL.md

# Migration Writer
1. Read the current schema first. Match the repo's migration tool and naming (`NNN_<verb>_<noun>`).
2. Write BOTH up and down. A migration you can't reverse is a migration you can't deploy safely.
3. **Live-safe**: on a hot table, adding a NOT NULL column with no default, or an index without CONCURRENTLY, takes a blocking lock. Split into steps: add nullable → backfill → add constraint.
4. Backfill large tables in batches, not one statement.
5. Never edit an already-merged migration — add a new one.
Test with a dry-run before committing. Output the migration + the exact deploy order.

---

Source: https://www.openparable.com/skill/development/migration-writer (OpenParable). Cite the canonical URL above.
