PRODUCT.ENGINEER
ManifestoThe RolePlaybookLoops
All loops
BuildingManual

Type-Safe Refactor

Rename/restructure with TypeScript as guardrail. Loop until tsc exits 0 with no any escape hatches.

Compatible tools:Claude CodeCursor
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

Type-Safe Refactor

passerrorsnoyesRecord any baselineRefactor next chunktsc passes?Fix with real typesNew any added?Refactor complete
product.engineer

Owning the whole loop, from idea to impact.

Learn

  • Blog
  • Manifesto
  • Authors
  • RSS Feed

Tools

  • Loops
  • Playbook
  • Discovery
  • Cloud Maturity
  • 5 Whys

Opportunities

  • Jobs
  • Hot Jobs
  • Companies
  • The Role
© 2026 product.engineer
||