Inline Refactor with Context
Both editors handle inline refactors well when given specific criteria. Cursor applies changes via Cmd+K with inline diffs. Windsurf's Cascade reads the full file context automatically. The 'preserve exact API' instruction prevents scope creep.
Refactor this function to improve readability and performance: File: {{file_path}} Function: {{function_name}} Requirements: - Break it into smaller functions if it exceeds 25 lines - Extract magic numbers into named constants - Replace nested if/else chains with early returns or a strategy pattern - Preserve the exact same inputs and outputs (don't change the public API) - Match the naming conventions used in the rest of {{file_path}} Performance improvements: - Replace any .find() inside a loop with a Map/Set lookup - Memoize expensive computations if called multiple times with same args - Remove unnecessary object spreads or array copies After refactoring, show a before/after comparison of the most significant change and explain the performance improvement.
Variables to customize
Why this prompt works
Both editors handle inline refactors well when given specific criteria. Cursor applies changes via Cmd+K with inline diffs. Windsurf's Cascade reads the full file context automatically. The 'preserve exact API' instruction prevents scope creep.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.