Rename/restructure with TypeScript as guardrail. Loop until tsc exits 0 with no any escape hatches.
Start the "Type-Safe Refactor" loop. - Goal: Refactoring is complete with zero TypeScript errors and no new `any` types introduced. - Max iterations: 8 - Between iterations run: `npx tsc --noEmit && grep -r "as any\|: any" src/ --include="*.ts" --include="*.tsx" | grep -v node_modules | wc -l` - Exit when: tsc exits 0 AND the any-count has not increased from the pre-refactor baseline. Steps: 1. Before starting, record the current `any` count as baseline 2. Perform the next chunk of the refactoring (rename, move, restructure) 3. Run `npx tsc --noEmit` to check for type errors 4. If there are errors, fix them using proper types — never add `as any` or `: any` to suppress 5. If the any-count increased, replace the new `any` with proper types 6. Move to the next chunk of the refactoring 7. Repeat until the full refactoring is done and tsc is clean Self-pacing instructions: After each iteration, run the check command, read the output, and only continue if the exit condition is not met. Stop when exit condition passes or max iterations reached. Give a short status update each pass.
How it works