Library / Refactor

Refactor

Restructure and simplify code safely while preserving behavior.

5 prompts
Extract & dedupe Remove duplication without altering behavior. Refactor dry extraction
@<file> has repeated logic in <functions>. Extract a shared helper without changing behavior. Keep the public API identical, and run the tests to confirm nothing broke.
Open ↗
Rename safely Rename a symbol everywhere without collateral edits. Refactor rename refactor
Rename <old> to <new> across the codebase. Update all references and imports, and don't touch any unrelated code. Show me the list of files changed.
Open ↗
Simplify function Make a gnarly function readable without changing what it does. Refactor readability cleanup
Refactor <function> in @<file> for readability — early returns, clearer names, fewer nested branches. Behavior must stay identical; show me a before/after of the tricky parts.
Open ↗
Split a large file Break up a sprawling file into focused modules. Refactor modularity architecture
@<file> is too large. Propose a split into cohesive modules with concrete names and responsibilities. Wait for my OK, then move the code and fix all imports.
Open ↗
Type-tighten Firm up weak types and surface hidden bugs. Refactor types typescript
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.
Open ↗