Back to guide/General Productivity

Multi-File Refactoring

Defines both the current and desired state, scopes the file changes, and includes a verification step. This prevents Cascade from partially refactoring and leaving the codebase in an inconsistent state.

windsurf-promptswhat_to_refactorcurrent_patterndesired_pattern
Edit View
Prompt
Refactor {{what_to_refactor}} across the codebase:\n\nCurrent state: {{current_pattern}}\nDesired state: {{desired_pattern}}\n\nScope:\n- Files to modify: {{file_pattern}} (e.g., src/components/**/*.tsx)\n- Files to NOT touch: {{excluded_files}}\n\nSteps:\n1. First, search for all usages of the current pattern and list them\n2. Create the new {{abstraction_type}} (interface/function/component) in {{target_file}}\n3. Update each file to use the new pattern\n4. Verify no broken imports or type errors remain\n\nConstraints:\n- Preserve all existing functionality — this is a pure refactor\n- Keep the same exports (no breaking changes for consumers)\n- Match existing code style (indentation, naming conventions)\n- Run the TypeScript compiler after changes to verify

Variables to customize

{{what_to_refactor}}{{current_pattern}}{{desired_pattern}}{{file_pattern}}{{excluded_files}}{{abstraction_type}}{{target_file}}

Why this prompt works

Defines both the current and desired state, scopes the file changes, and includes a verification step. This prevents Cascade from partially refactoring and leaving the codebase in an inconsistent state.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.