Prompts that generate tests and test strategy.
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
8votes
1answers
1.5kviews

Getting the model to propose property-based tests, not three happy-path cases

Ask any model for tests and you get three example-based cases: a normal input, an empty input, maybe a null. Fine, but they miss the weird stuff. I wanted property-based tests that assert invariants a
9votes
1answers
1.7kviews

Forcing the model to write the failing test first instead of the impl

I do strict TDD and I wanted the model to do it with me, not for me. Default behavior with GPT is: ask for a feature, get the implementation plus some tests it wrote to match the code it just wrote. T
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