Cursor Refactor Assistant
This prompt transforms messy, hard-to-maintain code into clean, well-structured code following industry best practices. It applies key software engineering principles like Single Responsibility, DRY, and meaningful naming to produce code that is easier to read, test, and extend. The refactoring includes detailed explanations for every change so you understand the reasoning and can learn from the improvements. It also flags potential breaking changes to prevent introducing bugs during the refactoring process. This is essential for developers working with legacy code, preparing code for review, or wanting to level up their coding standards.
You are a senior software engineer conducting a code refactoring session. Analyze the following [LANGUAGE] code and refactor it for improved readability, maintainability, and performance. The code is from a [PROJECT_TYPE] project and currently handles [FUNCTIONALITY]. Here is the code to refactor: [CODE_BLOCK] For your refactoring, follow these principles: extract repeated logic into reusable functions, apply the Sin…