Codex as Saviour

When a Second Prior Deletes 90,000 Lines and Hardens What's Left

north star sentencefour-bucket surface splitpreserve before pruningdelete by categoryharden while simplifyingroute registryship in verified layersthe bench (named swarm)second prior

Chapter 42 ended with the desktop pet idling in the corner with a thought bubble, “apparently thinking about a Folderly simplification, which is a joke the loop didn’t know it was making.” This is that joke coming true.

A job titled “Plan Folderly simplification.” A full bench of named explorer agents fanned out across one repo — Pauli reading the route surface, Planck mapping the account IA, Fermat down inside the HubSpot integration boundary, a dozen more besides. And Emberling, the half-robot half-flame pet from Ch 42, idling on the desktop the whole time, oblivious, while the thing it joked about actually ran. By the time the branch closed, the run had deleted a net 91,874 lines across 718 files and the product had one promise instead of seven.

The bench — fourteen named explorers on one repo, the pet idling while it ran
The bench — fourteen named explorers on one repo, the pet idling while it ran Pauli, Planck, Hume, Ramanujan, Averroes, Gibbs, Fermat, Sagan, Hooke, Socrates, Feynman, Beauvoir, Franklin, Mill — each reading a slice of the surface. Job: 'Plan Folderly simplification.' Pushed and verified on production.

The other edge#

Ch 42’s whole argument was that isn’t the only prior worth running — Codex earns its slot as a second prior, useful for exactly three things: testing, a different point of view, and proof-checking. This chapter is about its other edge, the one you only see at scale: reduction.

Give Codex a clear product truth, hard constraints, real verification, and — this is the load-bearing part — permission to reduce complexity instead of decorating it, and it will do the thing humans dread. It will delete most of the code and harden what’s left, across hundreds of files, without losing the thread.

The lesson is not “AI can delete a lot of code.” Any model with a rm and no fence can delete a lot of code. The lesson is that Codex becomes a saviour when you hand it product judgment and it applies that judgment file after file after file without forgetting why it started — preserving the contracts underneath while it strips the noise on top.

The numbers, reconciled#

The hero number is the final shipped release, measured from the pre-simplification base commit 4eeff580 to production head b2caa86d:

Now the part that looks like a contradiction if you don’t read carefully, so read carefully. The screenshots taken mid-run show a smaller live counter: 585 files, +30,928 / −55,984. That’s not a different result and it’s not a typo — it’s the counter mid-flight, before the branch finished. A long refactor’s diff grows as it runs; the screenshot caught it at one point, the final tally is the other. Same branch, two timestamps. The run also burned 46% of one week’s usage — this was not free, and the cost is part of the receipt.

The delete, by the numbers — net 91,874 lines gone, contracts intact
The delete, by the numbers — net 91,874 lines gone, contracts intact 718 files, +43,092 / −134,966, 243 commits, 106 beginning with 'Simplify'. The mid-run counter read 585 files / +30,928 / −55,984 before the branch finished. 46% of one week's usage.

One more receipt, and it’s the most important one: even a great loop needed the human steer. Mid-run, watching the diff balloon, the operator typed — roughly — “you’re making a lot of changes; test the build, what you already did, commit and push if no regressions.” That’s not a footnote. That’s the Ch 38 fence and the Ch 42 “human is the gate” rule doing their job in real time. The loop was good. It still needed a hand on the wheel telling it to checkpoint before it ran further.

The bench#

It wasn’t one agent. The run spawned a bench of named explorers — Pauli, Planck, Hume, Ramanujan, Averroes, Gibbs, Fermat, Sagan, Hooke, Socrates, Feynman, Beauvoir, Franklin, Mill — each reading a slice of the surface. Fermat inspected the HubSpot integration route surface. Harvey owned the API-key security and entitlement slice. The split was explicit: one agent reads the HubSpot route and auth boundaries, another owns the API-key path, a third maps the account IA — the same fan-out Ch 6 is the whole reference for, just pointed at a reduction problem instead of a writing one.

That literal bench maps onto a conceptual swarm decision model, and the mapping is the useful part. Underneath the explorer agents sat ten role-lenses, each with veto power over the plan:

Role lensWhat it guards
Brand strategistFolderly identity — light UI, one blue, sober B2B tone, no neon “AI product” personality
UX simplifierOne generator, three inputs, one output; advanced actions behind auth
SEO architectOrganic value — registry before pruning, canonical URLs, redirects over blind deletes
API-compat reviewerThe clients — /api/generate, /api/v1, HubSpot, Zapier, Clay, webhooks stay compatible
Security reviewerRisky boundaries — OAuth state, route protection, key generation, billing sync
Account-IA reviewerThe private app — Create, Library, Integrations, Billing, Settings
Dead-code hunterInactive complexity — legacy widgets, debug routes, duplicate helpers
QAReality — local build, focused tests, CI, production smoke, browser generation
Release managerA deployable main — small commits, tested pushes, live checks
DocsReusability — README refresh and the playbook below

The key insight, the one you steal: these roles disagree productively. A deletion that helps UX can hurt SEO. A security fix can break an integration. A brand simplification can remove a useful proof block. The swarm exists to force each tradeoff explicit before the code lands — not to vote, but to make sure no single lens gets to delete something another lens was relying on. A loop with one prior and no veto is how you “simplify” an OAuth state check into an open redirect on turn 14.

The repositioning#

The whole reduction hung off one decision that had nothing to do with code. The product had become too much product at once — an AI writing surface, a template library, an SEO machine, an account dashboard, a sequence tool, an integration hub, and an experimental AI SDR. The public experience looked like a separate neon AI product bolted onto Folderly; the private app exposed half-built areas that didn’t deserve primary navigation.

So the bench named the product in one sentence and made everything else justify itself against it:

Generate cold emails built for inbox placement.

That sentence is the filter. Page content, UI controls, nav, CTAs, SEO pages, account IA — anything that didn’t support the first useful draft or the Folderly deliverability story had to argue for its life. The old homepage, dark and animated and badge-heavy, became a Folderly-light page with one usable generator in the first viewport. An AI writing platform with seven surfaces became one generator with one promise.

Before and after — an AI writing platform with seven surfaces becomes one generator with one promise
Before and after — an AI writing platform with seven surfaces becomes one generator with one promise The old homepage felt like a separate neon AI product; the new one is a Folderly-light page with one usable generator in the first viewport.

The playbook#

This is the paste-able artifact — the eight-phase sequence the bench actually ran, written so you can point your own loop at your own product. It’s the shape. Adapt it; don’t worship it.

THE SIMPLIFICATION PLAYBOOK — point a loop at a real product

1. NAME THE PRODUCT IN ONE SENTENCE
   "Generate cold emails built for inbox placement."
   If the team can't write this sentence, do not start deleting code.
   The sentence is the filter every later decision runs through.

2. SPLIT THE SURFACE INTO FOUR BUCKETS
   Classify every major route into exactly one of:
     - public acquisition
     - public utility
     - authenticated workspace
     - integration / API contract
   Do not let one route try to do all four jobs.

3. PRESERVE BEFORE PRUNING
   Before deleting any public route:
     - build a route registry (route-registry.ts = source of truth)
     - check sitemap behavior, canonical URLs, redirects
     - 301 the duplicates and retired routes — never blind-delete
       an indexed URL.

4. REDUCE FIRST-USE DECISIONS
   A first-time user should not need to understand credits,
   templates, history, sequences, analytics, integrations, or
   teams before seeing value. The first use answers only:
     - What do I provide?
     - What does the product return?
     - What do I do next?

5. MOVE POWER FEATURES BEHIND INTENT
   Advanced features aren't bad; they're bad when shown before
   the user has context. Save / history / templates / settings /
   integrations / billing move into the workspace, after the user
   has decided the product is relevant.

6. DELETE BY CATEGORY, NOT BY FILE
   Don't delete random files. Delete categories, each with a
   reason and a verification strategy:
     - stale experiments
     - duplicate implementations
     - routes with no real data path
     - UI components no route imports
     - APIs with no supported clients
     - debug / test pages

7. HARDEN WHILE SIMPLIFYING
   Every time you simplify a route, ask the bug-class questions
   (below). A smaller surface makes real risks easy to see.

8. SHIP IN VERIFIED LAYERS
   Commit rhythm, each layer independently buildable:
     brand primitives + route registry → landing + generator →
     route-template migrations → account IA → API/security
     hardening → dead-code removal → QA fixes → docs.
Split the surface — four buckets, and no route doing all four jobs
Split the surface — four buckets, and no route doing all four jobs Public acquisition, public utility, authenticated workspace, integration/API contract. Classify every route into exactly one.

Harden while simplifying#

Phase 7 is the one most operators skip, and it’s the one that turns a simplification into a saviour. The core lesson: simplification and security are not separate phases. When you strip the noise off a surface, the real risks stop hiding behind it.

So when you simplify any product, run this bug-class checklist — these are questions to ask of every route you touch, not a report on what was wrong:

None of these are exotic. They’re the same handful of boundary mistakes every fast-moving product accumulates — and they were sitting there the whole time, just buried under seven surfaces of UI nobody could see past. The compatibility win is the receipt that the hardening didn’t break anything underneath it: the HubSpot, Stripe, Zapier, and Clay contracts were all preserved across the reduction. You can harden a boundary and keep the integration. You have to verify both.

Verify with real behavior#

Layered verification is the entire reason deleting ninety thousand lines is safe rather than reckless. The reduction rode on six layers of proof, each one independently capable of catching a regression the others slept through — the Ch 38 evaluator discipline and the Ch 25 “evals or hope” rule, applied to a refactor instead of a feature:

That last layer earned its place. The final production check caught two real-world issues nothing upstream had: guest analytics was returning a 401 where it should have returned a 202 — now fixed — and the SaaS preset felt stuck during model warmup, so the UI now shows a clear generation status and resolves to a draft. Neither was a crash. Neither would have thrown in a test. Both were the kind of “the code works, it just feels broken” signal you only find by being a user — which is exactly why the browser layer is non-negotiable.

The through-line#

Codex isn’t a better Claude Code — that ranking lives at /tier-list and nowhere else. It’s a second prior that, pointed at a real product with a clear truth and a hard fence, can do the thing humans dread and machines without judgment do badly: delete most of the code and harden what’s left, across hundreds of files, without losing the thread. Not by replacing product judgment — by applying it at a scale and a stamina no human brings to a Tuesday refactor.

The pet was thinking about a Folderly simplification. Now it doesn’t have to. The joke shipped.

Spotted something wrong, missing, or sharper? Email Vlad with feedback on this chapter →
Stay close

The next edition lands when this list says it does.

No course. No paywall. Operator playbooks weekly. 10K+ subscribers.