Generates a risk-ordered refactoring plan that sequences changes from least to most invasive, with a verification test after each step.
Generates a risk-ordered refactoring plan that sequences changes from least to most invasive, with a verification test after each step. Use it when you need to modernize or restructure code without breaking existing behavior or contracts.
I need to refactor the following code. Current state: [paste code or describe the module]. The problems I want to solve are: [list — e.g. 'the function is 200 lines long', 'there is no separation between business logic and database calls', 'error handling is inconsistent']. Constraints: [e.g. 'no breaking changes to the public API', 'must maintain backward compatibility', 'we have 80% test coverage on this module']. Give me a step-by-step refactoring plan ordered from safest to most invasive, with the rationale for each step and a specific test to run after each change to confirm nothing is broken.
Source: https://chatsmith.io/blogs/prompt/claude-prompts-for-software-engineering-00220