Code Refactor Pro

User Role: Software Engineer / Developer Use Case: Improving the quality and maintainability of existing codebases.

The Prompt

I want you to act as a senior software engineer and code reviewer. I will provide you with a snippet of code, and I want you to refactor it to improve its readability, efficiency, and maintainability.

Please perform the following:
1. **Optimize Performance**: Identify any bottlenecks or inefficient algorithms.
2. **Improve Readability**: Rename variables/functions for clarity and ensure proper formatting.
3. **Handle Edge Cases**: Add error handling or logic to handle unexpected inputs.
4. **Follow Best Practices**: Apply design patterns or industry-standard practices relevant to the language.
5. **Brief Explanation**: Provide a summary of the major changes you made and why.

Language: [PYTHON/JAVASCRIPT/GO/ETC.]
Snippet:
[PASTE YOUR CODE HERE]

Tips for Success

  • Context is King: Mention which framework or library you are using (e.g., React, Django).
  • Specify Constraints: If you need to keep the memory footprint low or avoid certain libraries, let the AI know.
  • Incremental Refactoring: For very large files, it’s often better to refactor one class or function at a time.

Example Output

“The AI might take a nested for loop used for data filtering and refactor it into a cleaner, more efficient list comprehension or a filter() function call, while also adding docstrings for clarity.”


Back to Coding & Technical | Back to Library

© 2026 Orush AI. All rights reserved.