Rebuild vs refactor: how to decide
Not every messy codebase needs a rewrite. Not every rewrite should be delayed until the whole business is on fire.
Rebuild versus refactor is one of the most emotional decisions in software. Developers dream of green fields. Leaders fear downtime, cost and the ghost of projects that took twice as long as promised.
Refactor when the core architecture still works, the team understands the domain and the pain is localised. Slow pages, tangled modules, missing tests, outdated dependencies — these can often be improved incrementally while the product keeps shipping.
Rebuild when the stack blocks the roadmap repeatedly, security risk is rising, hiring is impossible because the tech is too niche or every small change creates unpredictable breakage. If you are spending more time negotiating with the codebase than serving customers, listen to that signal.
The dangerous middle path is a stealth rewrite: calling it a refactor while replacing everything under the hood with no migration plan. That is how teams lose a year and surprise stakeholders with a half-working v2.
Use business milestones to frame the choice. A rebrand, major product pivot or platform migration can be the right moment to rebuild with clear scope. Otherwise, prefer steady improvement with measurable risk reduction each sprint.