the agent's codemod converted 200 files then crashed mid-run - the repo is half old API and half new API and the...
Fixes resuming a codemod that crashed after converting 200 files, leaving the repo half on the old API. Use when tests fail both ways and the transform needs a safe resume point. Key trigger: git shows ~200 modified files and the rest still use the old API.
TL;DR: Stabilize first, then resume. Commit the 200 converted files to a branch so the work is safe, define "remaining" as files still importing the old API, make the transform skip already-converted files, and re-run only on the remainder. Fix the test suite after the conversion is complete - a half-migrated repo can't have a green suite, so don't chase one mid-run.
The problem as reported:
the agent's codemod converted 200 files then crashed mid-run - the repo is half old API and half new API and the tests fail both ways- Survey and stabilize:
git diff --statto confirm roughly 200 modified files, thengit checkout -b codemod-resumeand commit them. Expected: the converted work is safe on a branch; the working tree is clean. - Build the remaining list from the old API's footprint:
grep -rl "from 'old-api'" src(using the old import string). Expected: the unconverted files, and only those. - Make the transform idempotent: add a guard so it skips files or nodes that already use the new API. Expected: running it over the whole tree changes nothing that was already converted.
- Re-run the codemod on the remaining files only. Expected: the grep from step 2 now returns nothing.
- Now fix the tests in one pass: run the suite, fix failures caused by the API change, and get to green. Expected: the full suite passes against the fully converted tree.
- Next time, keep the suite green throughout: migrate behind a compatibility shim, or split the work into stacked PRs that each leave tests passing.
Use this when
- A codemod died mid-run leaving the repo split across two APIs.
- Tests fail in both the old and new state.
- You need a safe resume point for a large transform.
Not for this skill when
- The crash corrupted files - restore from git before anything else.
- The converted output is behaviorally wrong - that's a correctness bug in the transform, not a resume problem.
Variant phrasings
- codemod crashed halfway how to resume
- repo half migrated tests fail both ways
- codemod converted 200 files then died
- resume large transform after crash
Why it happens
Long transforms exceed timeouts, memory limits, or sandbox lifetimes. Without incremental commits and an idempotent transform, there's no safe resume point - so the crash leaves the repo in the worst possible state: half converted.
Edge cases
- The transform is nondeterministic: fix that first, or the resume run produces different output than the first run.
- Main moved on while the codemod branch sat: rebase the resume branch and re-run the idempotency check.
- Test files converted before source files (or vice versa): convert in dependency order, or accept a red suite until the pass is complete.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_jxP1ReW38guemEcVwphU7A
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.