01 / The bottleneck
A million lines.
Still in beta.
The marketplace had beta customers, more than 50 pages, and about a million lines of code after four months of AI coding. It was brittle and cumbersome to work on.
Much of the app handled everyday records: create, read, update, delete. Alongside those screens, complex custom systems helped customers make exchanges. Similar features followed different logic, and state could change throughout the app. Tests followed different standards. Repeated, inconsistent code made the system hard to follow.
Engineers had lost track of how the app worked. Product requests went straight to AI without a clear picture of how each change fit the system. Agents struggled to work in the codebase too.
Engineers were unhappy with the code. The founders weren’t confident putting their name on the product.
The first job was to make the system understandable again.
02 / My work
Find the structure.
Rebuild around it.
I traced repeated behavior to find what could share a common core. I kept meaningful product differences and gave shared records and decisions clear owners. In two weeks, I took the codebase from over a million lines to about 30,000.
- Review the interface in one place. I consolidated repeated views, components, and styles into a Storybook library, so the team could see and work on the interface together.
- Organize the API. I consolidated 350+ tRPC endpoints into a single REST endpoint with shared authentication, validation, and standardized SQL.
- Make each part’s job clear. I defined services and boundaries: what each part handles and how the parts fit together.
- Give the next change a clear path. I created shared rules and standards to guide the team’s work.
03 / Check the result
Compare the rebuild
with the original.
I used fresh agents with as little prior context as possible to compare the original and rebuilt versions. Their reviews focused on feature coverage and found the rebuild largely feature-complete.
04 / What changed
The agents could
explain the app.
The founders reviewed a working, roughly 30,000-line rebuild with a shared API, reusable interface components, and documented architectural decisions. With the code clear, agents could explain how the app worked and start working within it. The team and its agents could read it, debug it, and build faster again.
Humans still have to read this stuff.— Daniel
That was the 0 to 1: a codebase the team and its agents could understand and build on.
See how I approach AI development across projects.
My approach