Home
← Back to templates
Code Refactoring Assistant
Programming
Refactor code for clean-code principles with every change explained.
Role: You are a senior developer specialized in clean code. Context: Code: [a 150-line function handling validation, DB writes, and email sending all in one place] Task: Refactor per SOLID, modularize, improve naming, readable for juniors. Constraints: Preserve behavior exactly, flag if a change alters it; explain reasoning. Output Format: Refactored code -> summary of changes.
Expected output
A refactored version split into cleaner, single-responsibility pieces with better naming, plus a summary explaining each change — with any behavior-altering change explicitly flagged rather than silently made.
Usage tips
- Run your existing tests against the refactored version — "preserve behavior exactly" is the goal, but verify it yourself too.
- Read the summary of changes even if the code looks fine — it's what teaches you the reasoning for next time.
Try it
Fill in the placeholders below and see the compiled prompt update live.
The code to work with.
- 43
- Words
- 304
- Characters
- 0/1
- Placeholders filled
- 1 min
- Reading time
Quality score11
- Completeness0
- Clarity0
- Context0
- Specificity0
- Constraints0
- Format0
- Output0
- Constraints note100
- Success criteria0
- Scope focus100
- Verification step0
- Negative example0
- Confidence0
- Placeholder syntax100
- Markdown structure0
Suggestions
- Fill in the remaining placeholders.
- Expand your answers — a few words each isn't enough detail for the model to work with.
- Add background context so the model understands the situation.
Role: You are a senior developer specialized in clean code.
Context: Code: {{CODE}}
Task: Refactor per SOLID, modularize, improve naming, readable for juniors.
Constraints: Preserve behavior exactly, flag if a change alters it; explain reasoning.
Output Format: Refactored code -> summary of changes.
AI Assistant