Convert codebase to TypeScript
Refactor all files to TypeScript and run tests until the full suite passes.
Use this when
You are migrating an existing JavaScript codebase to TypeScript and the job is too large for one sitting — many files, an existing test suite that must stay green, and no appetite to babysit each batch.
Done when
✓ Done means every file is converted and the full test suite passes — the loop declaring COMPLETE is not the signal, the passing suite is. High cost-risk: 100 iterations on a big repo burns real tokens. Run it in a worktree, commit before starting, and spot-check the types (not just the tests) afterward.
Why it works
The Ralph pattern restarts with fresh context each iteration, so a large migration does not decay as the context window fills. The completion promise (COMPLETE) plus --max-iterations 100 gives the loop both a goal state and a hard stop.
Source: MaouStan ↗graded B · 85/100 — how grades work →
More refactoring loops
Refactor auth module, pass tests
Refactor the authentication module iteratively until all tests pass, stopping after ten attempts.
Migrate an API import by import
Sweep a codebase from a legacy API to its v2 replacement with tests and typecheck as the safety net, capped at 30 turns.
Repair React issues in small batches
Baseline the scan, fix a small batch of real errors or warnings, and verify each change improves it without regressions.