Back to guide/Developer Tools

Multi-File Refactoring

Scopes the refactor to a specific directory, distinguishes between safe and risky changes, and requires a change log — critical for reviewing large refactors.

cursor-ai-tipspattern_to_changenew_patterndirectory
Edit View
Prompt
Refactor {{pattern_to_change}} to {{new_pattern}} across the codebase.

Scope: Only files in {{directory}}
Pattern to find: {{old_pattern_description}}
Replace with: {{new_pattern_description}}

Rules:
- Update all imports that reference changed exports
- Update any tests that test the changed code
- Do NOT change the behavior — this is a pure refactor
- If a file uses the pattern but changing it would be risky, flag it with a comment instead of changing it
- After all changes, run the project's lint command and fix any issues

List every file you changed and what you changed in it.

Variables to customize

{{pattern_to_change}}{{new_pattern}}{{directory}}{{old_pattern_description}}{{new_pattern_description}}

Why this prompt works

Scopes the refactor to a specific directory, distinguishes between safe and risky changes, and requires a change log — critical for reviewing large refactors.

Save this prompt to your library

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