Refactor the following code to improve quality, readability, and maintainability:
[PASTE CODE HERE]
Language: [LANGUAGE]
Context: [WHAT THIS CODE DOES]
Please:
1. Identify all code smells (long methods, god classes, feature envy, etc.)
2. Apply relevant design patterns where appropriate
3. Break down large functions into smaller, testable units
4. Improve naming (variables, functions, classes)
5. Remove duplication (DRY)
6. Add proper error handling
7. Add TypeScript types / type hints if applicable
8. Show the refactored code with comments explaining each change
9. Provide a before/after complexity comparison
10. List any behavioral changes to watch for during testing
Refactor the following code to improve quality, readability, and maintainability:
[PASTE CODE HERE]
Language: [LANGUAGE]
Context: [WHAT THIS CODE DOES]
Please:
1. Identify all code smells (long methods, god classes, feature envy, etc.)
2. Apply relevant design patterns where appropriate
3. Break down large functions into smaller, testable units
4. Improve naming (variables, functions, classes)
5. Remove duplication (DRY)
6. Add proper error handling
7. Add TypeScript types / type hints if applicable
8. Show the refactored code with comments explaining each change
9. Provide a before/after complexity comparison
10. List any behavioral changes to watch for during testing
How to use this prompt
Copy the prompt above and paste it into ChatGPT, Claude, Gemini, or any AI assistant. Replace the bracketed placeholders with your specific details.
Leave a Review
Tried this prompt? Let us know how it worked — your reviews help other users find the best prompts.