Skip to the content

Refactoring 40,000 lines of inherited code

The only developer had left and no documentation remained. We reconstructed a map of the system and made changes safe to ship.

Client
B2B SaaS, 7-year-old product
Industry
Business software
Year
2026
Duration
3 weeks
The problem

The product made money, but every change broke something elsewhere. The team was afraid to ship and did so once every two months.

Solution

What we did
and why we did it that way.

01

A map of the system

We went through the repository and the commit history and turned it into a dependency diagram and a list of risk areas.

02

A safety net

We wrote characterisation tests against the current behaviour—including two “bugs” that customers had come to rely on.

03

Dependency updates

We closed 23 known vulnerabilities in libraries that had not been updated for four years.

04

CI and releases

We stood up a pipeline with tests. A release stopped being an event and became a 12-minute operation.

Result

What changed
and what we measured it with.

40,000
lines worked through in 3 weeks
0 → 71%test coverage of the critical paths
23
CVEs closed in dependencies
12min
full release cycle instead of two months
Stack
PythonTypeScriptPostgreSQLDockerGitHub ActionsPlaywrightSemgrep
Timeline

How it went
day by day and week by week.

  1. Week 1

    Reconnaissance

    Map of the system, risk areas, migration plan.

  2. Week 2

    Tests

    Characterisation tests for the critical scenarios.

  3. Week 3

    CI and handover

    Pipeline, dependency updates, a walkthrough with the team.

Screens

How it looks
in schematics.

These are screen schematics. We do not publish client interfaces without permission

Next

A similar problem
on your side?

Describe it in the brief. In working hours we come back with an estimate of time and cost within two hours.