♻️

Code Smell Detector and Fixer

Identify code smells in existing code and get refactored versions

prompt template
Review this code for code smells and refactor it:

```
[PASTE_CODE_TO_REVIEW]
```

For each issue found:
1. **Smell name** — e.g., "Long Method", "Feature Envy", "Primitive Obsession"
2. **Location** — which lines/functions
3. **Why it's a problem** — concrete impact (harder to test, likely to cause bugs, etc.)
4. **Refactored code** — the improved version
5. **Technique used** — e.g., "Extract Method", "Replace Conditional with Polymorphism"

Priority order: fix bugs first, then readability issues, then style.

Do NOT:
- Change working behavior (preserve all existing functionality)
- Add features or error handling that didn't exist
- Over-abstract (don't create helpers for one-time code)
- Change public API signatures without flagging it

After refactoring, provide:
- A diff summary of what changed and why
- Confidence level that the refactoring preserves behavior (High/Medium/Low)
- Suggested tests to verify the refactoring didn't break anything

How to Use This Prompt

  1. 1Copy the prompt template above
  2. 2Paste into Claude, ChatGPT, or Cursor
  3. 3Replace [bracketed placeholders] with your specific project details
  4. 4Iterate on the AI output to refine and customize the results