Rewrites are a trap,
refactor anyway

Most codebases don't need a rewrite — they need a measured refactor, a performance pass and a test harness. We reshape the system while the business keeps running, and we bring numbers out the other side.

Before-and-after performance curves with code complexity blobs code.perf.delta p95 · p99 · cost before · after · how Before After Latency p95 · last 60 days refactor applied @day 24 refactor 1,420 ms p95 before 280 ms p95 after · −80%

CAPABILITIES

Six surfaces where refactoring lands

Code review, targeted refactor, performance repair, DB optimisation, debt triage and framework upgrades — run under one audit discipline.

01

Legacy codebase review

Architectural scan, hotspot detection, test-coverage map, risk ranking. Reviewable output the stakeholders can act on, not a 200-page audit nobody reads.

02

Targeted refactoring

Strangler-fig migrations, module extraction, test harness retrofit. We never rewrite from scratch — we change the shape while the business keeps running.

03

Performance repair

Profile, measure, fix. P95 latency halved, tail P99.9 stabilised, infrastructure cost dropped to match.

04

Database optimisation

Query plans, index design, read / write split, partitioning, caching. Migrations online, no downtime windows.

05

Technical debt triage

Prioritise by blast radius and revenue impact. Pay down what blocks the next quarter; park what does not.

06

Upgrade & modernisation

Framework upgrades (React 18→19, Node LTS, Rails, Django, Spring), dependency rollups, security patching cadence.

BEFORE · AFTER

Six measured deltas from real engagements

Not lab numbers. Real before-and-after measurements from codebases we've refactored, with the mechanism that moved the needle named in the right-most column.

p95 latency 1,420 ms p95 latency 280 ms

N+1 queries eliminated · edge cache tier · async boundary

Build time 14 min Build time 2 min 30 s

Remote cache · workspace split · incremental transpile

Test coverage 12% Test coverage 58%

Contract tests · fixture generators · regression harness

Cloud spend $38k/mo Cloud spend $12k/mo

Right-size · spot · autoscale · read-replica tier

Deploy freq. weekly Deploy freq. 12× daily

Pipeline parallelism · trunk-based · review gates

3 incidents / week 0.4 incidents / week

SLO-driven refactor · circuit breakers · rollback drill

Refactor, don't rewrite

The "let's start over" impulse almost always costs more than the refactor. Strangler-fig migrations keep the business running while the codebase changes shape.

Open QA & release governance ↗

STACK

Profile · refactor · test · observe

The four lanes we run every refactor engagement on. Stack choice is driven by the existing codebase, never by fashion.

Profile

  • pprof · perf · dtrace
  • Chrome DevTools · Lighthouse
  • Datadog APM · Sentry perf
  • pg_stat_statements · explain

Refactor

  • Strangler-fig · branch-by-abstraction
  • AST codemods (jscodeshift)
  • Modular monolith → services
  • Anti-corruption layer

Test

  • Playwright · Cypress
  • Vitest · Jest · pytest
  • Contract (pact)
  • Property-based (fast-check, hypothesis)

Observe

  • OpenTelemetry · Tempo · Jaeger
  • Grafana · Honeycomb
  • Sentry · Rollbar
  • Log-based golden signals

Adjacent disciplines

Audit · refactor · measure

Change the shape without changing the business

Share the repo (under NDA), the pain and the budget envelope. We come back with an audit report, target metrics and a strangler-fig plan inside ten working days.