Refactor Code Without Changing Its Behavior

Clean up structure and readability while holding behavior fixed — with a clear summary of what changed and why.

0 likes 0 dislikes
Sign in to rate this prompt

Prompt

    Refactor the code below for readability and structure. **Do not change its observable behavior** — the same inputs must produce the same outputs and side effects.

Code:
{{code}}

Goals (optional — e.g. reduce nesting, extract functions, clearer names, remove duplication):
{{goals}}

Please:
1. Return the refactored code.
2. Summarize what you changed and why, as a short bulleted list.
3. Flag anything you were tempted to change but left alone because it might alter behavior.

If a "cleanup" would risk changing behavior, don't make it silently — point it out and let me decide. If the code's intended behavior is unclear in places, ask before assuming.

Like this prompt?

Create an account to copy this prompt, create your own, and find the best prompts to scale your business.