Home › Prompts › DeepSeek › Refactor plan for messy code
Refactor plan for messy code
Get a safe, step-by-step refactor plan for a piece of code, with tests to add first.
DeepSeekCodingRuleStack original
Written for DeepSeek Chat (DeepThink reasoning mode) · Updated 2026-10-17
Note: Review and test before use. Provided as is, without warranty. See Terms.
Prompt
DownloadHere is code from [language/framework] that is hard to maintain:
```
[paste code]
```
Goals: [readability, performance, testability].
1. List the problems you see, most important first.
2. Propose a refactor in small steps that keep behavior the same.
3. List tests I should write before changing anything.
4. Show the refactored code for step 1 only.Replace everything in [square brackets] with your own details.
Settings & parameters
- DeepThink on for larger files
Variations
- Ask for a version with type hints.
- Convert callbacks to async/await.
Tips
- Small steps make refactors reviewable.
- Do not paste secrets or proprietary code you are not allowed to share.