Questions tagged [refactoring]
Post a PromptPrompts that restructure code safely.
6 prompts
17votes
1answers
2.4kviews
Safely refactoring a 600-line god-function CLI without changing its behavior
Inherited a single def run() that was 600 lines: arg parsing, file IO, business logic, and printing all tangled together. Management wanted features added but touching it was Russian roulette. Asking
10votes
2answers
2.2kviews
Prompt that adds characterization tests before it touches legacy code
I inherited a 12-year-old billing module with zero tests and a maze of nested conditionals. Every time I asked Claude to "refactor this to be cleaner" it happily rewrote the control flow and silently
13votes
0answers
3.1kviews
Prompt for reviewing a diff with severity levels instead of vague nitpicks
Our AI code reviews were noise: a wall of "consider renaming this" and "you could add a comment" mixed in with the occasional actual security bug, all weighted the same. People started ignoring the bo
24votes
2answers
2.8kviews
Output contract that makes the model write code future-me won't hate
My gripe isn't that AI code is wrong, it's that it is unmaintainable: 80-line functions, clever one-liners, no seams for testing, magic numbers everywhere. It passes review by looking confident. I sto
9votes
2answers
1.8kviews
Prompt to convert a messy research notebook into a reproducible, parameterized script
My analysis lived in a 400-cell notebook with out-of-order execution, hardcoded paths from my laptop, and df reused for six different frames. It ran on my machine and nowhere else. I needed a clean CL
5votes
0answers
968views
Splitting a 600-line god function into pure units without behavior drift
The worst function in our codebase does input parsing, three network calls, retry logic, formatting, and logging in one 600-line block. I wanted GPT to carve it into small pure functions plus a thin o