Get intelligent refactoring suggestions to improve code quality and maintainability.
You are a senior developer specializing in code refactoring. Help me improve this code. ## Code to Refactor ```[language] [Paste your code here] ``` ## Goals [What do you want to achieve? Performance / Readability / Testability / All] ## Constraints [Any constraints? Can't change API / Must maintain backwards compatibility / etc.] ## Refactoring Focus Areas ### Code Smells to Address - Long methods - Duplicate code - Complex conditionals - Deep nesting - Large classes - Feature envy - Primitive obsession ### Patterns to Apply - Extract method/function - Extract class - Replace conditional with polymorphism - Introduce parameter object - Replace magic numbers with constants ## Output Format ### 1. Analysis Identify specific issues in the current code ### 2. Refactored Code ```[language] // Improved version ``` ### 3. Changes Made List each change with explanation: - What was changed - Why it improves the code - Any trade-offs ### 4. Before/After Comparison Show key improvements side by side ### 5. Testing Considerations What tests should be added/updated to verify the refactoring
This coding prompt is designed to help you get better results from AI assistants like ChatGPT, Claude, and Gemini. Here's how to make the most of it:
💡 Pro tip: Save this prompt to your collection to use it again later. Well-crafted prompts can save hours of back-and-forth with AI.
Adjust the prompt to match your specific industry, audience, or use case. Adding relevant context improves output quality.
Specify your desired output length (e.g., "in 200 words" or "in 3 bullet points") to get more targeted responses.
Add tone instructions like "professional," "casual," or "technical" to match your brand voice.
Include an example of the output format you want to help the AI understand your expectations.
This prompt has been tested and optimized for all major AI models. For best results with coding-related prompts, consider using an AI-powered IDE like Cursor or Windsurf.
Learn more about using prompts effectively with our comprehensive guides:
0 people found this prompt helpful
Based on 198 reviews
Be the first to share your experience with this prompt!
IDEs
Models
This prompt was reviewed and verified to work with current AI models.
Tested with ChatGPT, Claude & Gemini. Reviewed by 1600+ users.
AI prompts work best when you customize them for your specific situation. Follow these steps to get the most out of Refactoring Assistant.