REFACTORCleans up messy code without changing what it does. Tells you what changed and why.
Category: Coding & Technical
Before / After
Make this cleaner: [paste function]
REFACTOR [paste function]
What changes in Claude's response
You get the rewritten code plus a numbered list of every change: 'extracted lines 12-28 into a helper because they're called twice', 'replaced the nested ternary with a switch because branch coverage was unreadable', 'inlined the single-use variable on line 34'. The why matters — without it, you can't tell if the refactor matches your team's style.
When NOT to use REFACTOR
Don't REFACTOR code you don't have tests for. The promise is 'same behavior' but the only way to verify that is tests. No tests = REFACTOR is rolling dice.
Codes that stack with REFACTOR
REFACTOR is one of 120 tested prompt prefixes. The full cheat sheet has before/after examples, warnings, combos, and 10 workflow playbooks.
See the full cheat sheet — from $5More Coding & Technical codes
/debugFinds the bug and tells you exactly where it is, not what bugs look like in general.
/shipitAdds the production-readiness layer Claude usually skips: error handling, edge cases, types, logging.
ARCHITECTDesigns system structure before any code is written. Forces decisions, doesn't just list options.
/convertRewrites code in another language idiomatically — not transliterated.
AUTOMATETurns a manual process you described in English into a runnable script.