Library / Refactor

Type-tighten

Firm up weak types and surface hidden bugs.

Refactor types typescript safety Claude Code
The prompt
Replace any/loose types in @<file> with precise types inferred from how the values are actually used. Don't change runtime behavior, and flag anything that reveals a real bug.

Why it works

Tightening types from real usage often exposes latent bugs — the model is told to flag them rather than paper over them. The runtime-behavior guard keeps it a type-only change.

Fill in

  • @<file> — the file with loose types.

Follow-ups

  • “Turn the flagged issue into a failing test, then fix it.”