Library / Refactor

Simplify function

Make a gnarly function readable without changing what it does.

Refactor readability cleanup safe-refactor Claude Code
The prompt
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.

Why it works

Naming the specific readability moves (early returns, fewer branches) steers the model toward proven simplifications rather than cosmetic churn. The before/after keeps the diff reviewable.

Fill in

  • <function> / @<file> — the target.

Follow-ups

  • “Add a one-line comment above each non-obvious step.”