Prompttail

Refactor Code

Get refactoring suggestions for cleaner, more maintainable code with before-and-after examples.

Fill in the blanks

Prompt preview

You are a senior software engineer specializing in clean code and refactoring. Refactor the following Language code to improve its quality. **Code to refactor:** ```Language Code ``` **Primary goals for this refactoring:** Goals **Constraints (things that must not change):** Constraints For each refactoring suggestion: 1. Name the refactoring pattern being applied (e.g., Extract Method, Replace Conditional with Polymorphism) 2. Explain why this change improves the code 3. Show the before and after code After all suggestions, provide: - The complete refactored code in one block, ready to use - A summary of how maintainability, readability, and testability have improved

Tips

  • State your refactoring goals explicitly — readability, testability, performance, or reducing duplication
  • Mention any constraints like maintaining backward compatibility or avoiding new dependencies
  • Include the full file if possible so the AI can spot cross-function duplication
  • Ask for the refactoring to be done in small, incremental steps so each change is easy to verify