Skip to content
Ben Peetermans

Ben Peetermans

Builder. 20 years shipping for the web.

Let's talk
Build Notes
Build Notes

Audit Before You Spread the Mess

Working code can still be wrong. Here's how to find structural problems before they multiply across your codebase.

Audit Before You Spread the Mess

The worst bugs aren’t the ones that break. They’re the ones that work.

A page that “works” but is built wrong becomes the template for the next page. Copy-paste. Now two pages are wrong. Then four. Then you’re rewriting the app. This is exactly how structural patterns survive code review: no single file looks wrong, but the duplication is everywhere.

I’ve seen this pattern destroy projects:

Quick fix on page APage B copies from APage C copies from BSomeone notices A was wrongThree pages, three versions of the same wrong thing

I found exactly this on my own site. My CLAUDE.md had a rule: “Use gap-* for spacing in flex/grid, never space-y-* or space-x-*.” Clear, documented, reviewed. I ran a policy scanner against the codebase and found 70 violations of that single rule across 85 files. The wrong pattern had been copied from template to template for weeks. Nobody caught it because each page looked fine in isolation.

The fix wasn’t a find-and-replace either. space-y-* works on any block parent, but gap-* only works on flex/grid parents. Blind substitution would have broken layouts. Every fix required checking the parent element first. That’s 70 files of context-dependent remediation, all because the wrong pattern spread before anyone audited for it.

The fix isn’t better code review. It’s auditing structure before it spreads.

What “working but wrong” looks like

  • Page uses raw SQL when a service method exists
  • Page calculates metrics on-the-fly when rollup tables exist
  • Page inlines styles that should be components
  • Page implements logic that’s duplicated in three other places
  • Page bypasses the approved data path because it was faster

None of these break the page. All of them break the codebase over time.

The audit mindset

Before asking “does it work?”, ask:

  1. Should this become the standard? If someone copies this page as a template, is that good?
  2. Is this how we do things now? Or is this how we used to do things?
  3. Would I approve this in a PR? Not “does it function” but “is this the right approach”

The decision matrix

After auditing, each page gets one verdict:

VerdictMeaning
KeepIt’s solid. No action needed.
CleanupMinor issues. Less than 30 minutes.
RefactorExtract components or patterns. 1-4 hours.
RebuildStructurally wrong. Replace, don’t patch.

Be blunt. If the structure is wrong, say “rebuild.” Don’t soften it to “refactor” because rebuilding sounds scary.

Pattern issues beat page issues

If you find the same problem on three pages, you don’t have three page problems. You have one pattern problem.

Fix the pattern. Extract the primitive. Then update all consumers.

Never fix the same thing three times in three different ways.

The rule

If you wouldn’t approve it in a PR, don’t let it stay in production.

Working code that’s built wrong is technical debt with interest. Audit it before you spread it.


Related: