Convert codebase to TypeScript

Refactor all files to TypeScript and run tests until the full suite passes.

prompt
→ Claude Code
/ralph-loop "Refactor codebase to use TypeScript. Output COMPLETE when all files converted and tests pass." --completion-promise "COMPLETE" --max-iterations 100
claude-code

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

Loop/goalGitHubB

Refactor the authentication module iteratively until all tests pass, stopping after ten attempts.

prompt
→ Claude Code
/goal "Refactor auth module until all tests pass" --max-iterations 10
refactoringlow risk

Migrate an API import by import

Loop/goalXB

Sweep a codebase from a legacy API to its v2 replacement with tests and typecheck as the safety net, capped at 30 turns.

prompt
→ Claude Code
/goal every file importing from `./legacy-api` now imports from `./v2-api`, all tests pass, and `npm run typecheck` is clean — stop after 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.

prompt
→ Claude Code
Run `pnpm exec react-doctor . --verbose --yes --offline --fail-on none` to record the baseline, then rerun with `--fail-on error`. Fix at most five genuine findings, run the same scan and relevant project checks, and keep only verified improvements. Clear errors before high-confidence warnings. Stop when clean, blocked, approval is required, a finding is false-positive, or another pass makes no measurable progress. Finish with baseline and final results, retained fixes, reverted attempts, checks, and remaining findings.