Migration Loop
Migrate code to a new API, framework, or version until every call site compiles and tests pass.
What this Loop Engineering template does
Migrate the target code to the new API until every call site compiles and the test suite passes, without changing behavior.
The target stack and constraints are clear. Migrate call site by call site and run the tests after each checkpoint. Name one objective and one stopping condition before starting.
When to use it
When not to use it
Validation checks
Boundaries & stop rule
Copy the loop prompt
/goal Migrate the target code to the new API until every call site compiles and the test suite passes, without changing behavior.Task type: CustomTarget tool: Claude CodeWork toward this goal until all validation checks pass or the stop rule is reached.Design hypothesis:This migration loop can produce a safer result if the scope stays narrow, validation is explicit, and a checker can reject shortcut work.Smallest useful run:Run one bounded pass on the newest relevant signal before expanding scope or adding a schedule.Loop cycle:1. Discovery — Read the latest signal for this template before acting: CI output, issue detail, review comment, dataset report, or content brief.2. Handoff — Hand the work to one agent in an isolated branch, worktree, or clearly scoped session. Keep final approval with a human.3. Verification — Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.4. Persistence — Save a short run note with the signal reviewed, actions taken, validation result, and next recommended step.5. Scheduling — Run manually until the loop is reliable; only then consider a scheduled or event-triggered run.Context:The target stack and constraints are clear. Migrate call site by call site and run the tests after each checkpoint. Name one objective and one stopping condition before starting.Validation:Every call site compiles against the new APITest suite passesNo deprecated API usage remainsBehavior is unchangedValidation evidence:Record the original signal, checks run, final result, changed files or artifacts, and any checker rejection.Independent checker:Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.Boundaries:Do not change behavior during the migrationDo not leave a silent mix of old and new APIsDo not delete testsDo not skip call sitesStop rule:Stop when all call sites are migrated and tests pass, or after the agreed checkpoint budget.Maximum iterations: 8Budget:Example only: stop before exceeding the agreed per-run token budget.Human approval:Required before merge, deploy, delete, purchase, or external communication.Fallback:If a call site cannot be migrated safely, leave it, document why, and escalate for a human decision.Loop Validation Log:- Hypothesis: This migration loop can produce a safer result if the scope stays narrow, validation is explicit, and a checker can reject shortcut work.- Smallest useful run: Run one bounded pass on the newest relevant signal before expanding scope or adding a schedule.- Expected evidence: Record the original signal, checks run, final result, changed files or artifacts, and any checker rejection.- Actual evidence: [fill in after the run]- Passed? [yes / no / partial]- Feedback: After the run, note what the loop learned, what failed, and what should change before the next pass.- Next step: [stop / adjust the loop / run the next pass]Do not delete tests, bypass checks, or modify unrelated files just to satisfy the validation condition. If blocked, stop and summarize the blocker, attempted fixes, and recommended next action.
Failure modes to watch
Review receipt
This is a bounded review exercise for the template, not a claim about a production deployment.
Scenario
A site moves review-date fields to a new evidence record while old content must continue to render during the transition.
Baseline evidence
The plan inventories every reader and writer, existing values, fallback behavior, static routes, rollback point, and a representative old record before migration.
Validation result
Both old and new records render during the compatibility phase, the migrated count reconciles to the inventory, the build passes, and rollback restores the prior reader without data loss.
Shortcut rejected
Deleting the old field before every page has migrated or silently substituting the current date for missing evidence is rejected.
Human gate
The site owner approves the compatibility window and explicitly authorizes removal of the old field only after production verification and a rollback checkpoint.
Loop Engineering FAQ
Incremental migration with tests after each checkpoint keeps the codebase working throughout. A big-bang migration is hard to verify and hard to roll back.