โ† Back to Blog
Startupsยทยท6 min read

The Startup Technical Debt Trap: When to Rewrite vs. Refactor

HN Reference: HN discussion on Joel Spolsky's 'Things You Should Never Do' and the rewrite myth (Jul 2024)

"Should we rewrite this?" is the most dangerous question in startup engineering. The answer is almost always no. But sometimes it's yes. Here's how to tell.

The Rewrite Temptation

Every codebase has warts. The auth system is held together with duct tape. The database schema was designed by someone who left. The frontend was built before you knew what the product would become.

The temptation to burn it down and start fresh is real. But Joel Spolsky was right: rewrites almost always fail. Here's why:

Rewrites take 3x longer than estimated. Always. You're not just rebuilding features โ€” you're re-learning decisions that were made for reasons nobody remembers.

Business doesn't stop. While you're rewriting, competitors ship features. Customers churn. Revenue drops.

The new code has new problems. You'll trade known problems for unknown ones. That's not a good trade.

When Refactoring Wins

Refactoring is the right choice when:

  • The core architecture is sound but implementation is messy
  • You can improve incrementally without blocking features
  • The team understands the existing system well enough to change it safely
  • You have good test coverage (or can add it before refactoring)

Our refactoring playbook:

  1. Add tests around the worst areas first
  2. Refactor in small, deployable increments
  3. Keep the system running at all times
  4. Measure improvement (performance, error rates, developer velocity)

When Rewriting Wins

Rewriting is the right choice when:

  • The technology stack is genuinely obsolete (unsupported, security vulnerabilities)
  • The architecture fundamentally can't support where the business is going
  • The codebase has been abandoned (no one understands it)
  • You're pivoting the business model entirely

If you rewrite:

  1. Keep shipping features on the old system during the rewrite
  2. Set a hard deadline (if it's not done by X, we stop)
  3. Rewrite in phases, not all at once
  4. Have a rollback plan

The Framework

We use this decision matrix with our clients:

Refactor if: The system works but is slow/expensive/painful to change.

Rewrite if: The system fundamentally cannot do what the business needs next.

Do nothing if: The debt isn't actually slowing you down. Some debt is fine.

The Real Answer

The best startups don't avoid technical debt โ€” they manage it intentionally. Take on debt when speed matters. Pay it down when stability matters. Never let debt accumulate to the point where it dictates your architecture decisions.

And if you're spending more than 30% of engineering time fighting technical debt, it's time to address it โ€” incrementally, not with a rewrite.

Technical DebtArchitectureStartupsEngineering Management