Cursor prompt
Refactor with Zero Regressions
Structured refactoring prompt that ensures existing behavior is preserved while improving code quality.
Refactor the following code. Your goal is to improve {{refactor_goal}} while maintaining identical external behavior. RULES: - Do NOT change any public API signatures - Do NOT change any return values or side effects - Every existing test must still pass without modification - If you introduce new helper functions, they must be private/internal APPROACH: 1. First, list every public contract (function signatures, return types, side effects) 2. Perform the refactoring 3. After refactoring, verify each contract is preserved 4. Note any edge cases that the original code handled (even if poorly) Code to refactor: ```{{language}} {{code}} ``` Refactoring goal: {{refactor_goal}}
Fill in: {{refactor_goal}}, {{language}}, {{code}}. In Loopy you fill these in a form and copy the finished prompt in one click.
More refactoring prompts
- CursorAdd TypeScript to Legacy JavaScriptIncrementally migrate a JavaScript codebase to TypeScript without breaking changes, starting with the most critical files.
- CursorOptimize Database QueriesIdentify N+1 queries, add missing indexes, rewrite slow queries, and add performance monitoring to an existing application.
- CopilotTranslate Code Between LanguagesConvert code from one programming language to another while preserving logic, idioms, and error handling.

