Перейти к содержимому

I Let AI Refactor Code With Zero Tests. One Line Almost Broke Everything.

Commit Small

0:00 / 0:00

I Let AI Refactor Code With Zero Tests. One Line Almost Broke Everything.

36 просмотров · 2 дня назад
Commit Small
18 подписчиков
36 просмотров · 2 дня назад
No tests. No docs. The author left in 2021. I let AI rewrite the whole file anyway, and one test turned red. It wasn’t the one I expected. In this video I use characterization tests: tests that record what legacy code does right now, bugs and all, before you let AI touch it. The AI’s refactor looked perfect and I’d have approved it in review. Then one tiny “cleanup” turned out to be a hidden business rule that would have made every gift card ship for free. You’ll learn: → Why writing “correct” tests for legacy code is a trap → The exact prompt for generating characterization tests (and the one line you can’t skip) → How one line of clean-looking AI code quietly changed behavior → 3 rules for refactoring code you don’t understand The prompt: “Generate tests that pin down what calc() CURRENTLY returns. Cover every edge case. Do NOT fix any bugs.” Chapters: 0:00 The challenge 0:17 The legacy file 0:36 The trap 0:58 The prompt 1:18 The photograph 1:32 The AI refactor 1:46 The moment of truth 2:15 Bug or feature? 2:35 The 3 rules 2:53 Next week Previous episode: Why Your AI Refactor Broke Production Next week: 3 AIs. Same messy code. Only one didn’t break it. Small commits, cleaner code. Note: this video uses AI-generated narration. #refactoring #cleancode #javascript #commitsmall #viral #AIregenerated #narration