// When it breaks, triage before you rebuild · lesson 06
When rebuilding actually is the right call
This whole track pushes hard against the rewrite reflex, so let me be fair to the rewrite: sometimes it is exactly right. Diagnosis first does not mean repair always wins. It means the decision to rebuild has to be earned by understanding, not reached for out of frustration. The line is simple. Rebuild on a diagnosis, never on a mood.
Rebuilding on a mood sounds like "this is a mess, I hate it, let me just start over." Rebuilding on a diagnosis sounds like "I have traced this, and the core structure assumes a thing that is no longer true, so patching around it will keep producing bugs of this class, therefore a rebuild on a corrected assumption is cheaper than continuing to patch." Notice the second one names the actual problem and explains why repair will not work. That is the entry fee for a legitimate rewrite.
What makes a rebuild the correct move?
A few real signals. The design is wrong at the foundation, not just buggy on the surface, so every fix fights the architecture. The invariants you need cannot be added to the current structure without effectively rewriting it anyway. The system has accumulated so many surface fixes that no one, including you, can say what it does anymore, and a rescue-spec reveals the current code cannot satisfy it. In those cases the existing code is not an asset you are preserving, it is debt you are paying interest on, and a clean rebuild against a real spec is the cheaper path.
The key is that you can only know any of that after diagnosis. You cannot tell a foundational design flaw from a one-line bug by feel, because they present identically: something is broken and you are annoyed. Diagnosis is what distinguishes them. So even when the answer turns out to be rebuild, the diagnosis was not wasted, it is what told you rebuild was right and, just as important, what the rebuild needs to do differently. A rewrite without a diagnosis just recreates the same problem with fresh code.
So hold both truths. The reflex to rebuild is usually avoidance, and you should distrust it. And sometimes, after you have actually looked, rebuild is the correct, evidence-backed call. The diagnosis is what earns you the right to make it.
The takeaway: Rebuilding is sometimes correct, but only on a diagnosis, never on a mood. If you can name the foundational flaw and why patching won't fix it, rebuild; if you can't, you haven't earned the rewrite yet.