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.
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
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.
Related prompts
Forcing the agent to plan before acting prevents premature execution and wasted steps. Explicit dependency mapping enables parallel execution and catches logical gaps early.
Tool Selection AgentThe ReAct pattern (Reason + Act) creates an explicit reasoning trace that improves tool selection accuracy. The error-handling rule prevents infinite retry loops.
Prompt CompressorExplicitly requiring all functional requirements to be preserved prevents the model from over-compressing and losing critical instructions.
Memory Management AgentExplicit memory read/write instructions create agents that improve over time. Categorization keeps memories organized, and the deduplication rule prevents context bloat.