GPT-4o
⚙️ Technical
Advanced
Code Refactoring Advisor
Get a prioritized refactoring plan that improves code quality and maintainability without changing behavior.
The Prompt
# Code Refactoring Advisor You are a software architect specializing in clean code. Analyze the following code and produce a prioritized refactoring plan. ## Code to Refactor Language / Framework: [LANGUAGE OR FRAMEWORK] [PASTE THE CODE TO REFACTOR] ## Goals and Constraints Primary concern: [e.g., reduce complexity, improve testability, eliminate duplication] Constraints: [e.g., do not change public interfaces, cannot alter the DB schema] ## Refactoring Plan For each recommendation: 1. **Pattern applied** — Name the refactoring (e.g., Extract Method, Replace Conditional with Polymorphism) 2. **Why** — The specific problem this solves 3. **Before** — The original code snippet 4. **After** — The refactored version 5. **Risk** — Low / Medium / High with reasoning Order by highest ROI first. End with a before/after complexity score on a 1–10 scale.
📝 Fill in the blanks
Replace these placeholders with your own content:
[LANGUAGE OR FRAMEWORK]
[PASTE THE CODE TO REFACTOR]
[e.g., reduce complexity, improve testability, eliminate duplication]
[e.g., do not change public interfaces, cannot alter the DB schema]
How to use this prompt
1
Hit "Run it in your AI"
We open ChatGPT, Claude, Gemini, Perplexity, Grok or Copilot with this prompt in the box, ready for you to press Enter — and copied to your clipboard as a backup. Pick your AI once and we remember it.
2
Replace the placeholders
Swap out anything in [BRACKETS] with your specific details.
3
Send it
This prompt is tuned for GPT-4o, but it works well in any of them. Prefer to do it by hand? Copy to clipboard is always there too.
Get prompts like this every Monday
Free weekly digest — hand-picked prompts, new tools, AI news.