Over the past year, we’ve seen a wave of engineering teams use coding agents to tackle large-scale migrations and rewrites that used to be prohibitively expensive, from Bun porting its codebase from Zig to Rust, to GitHub migrating the Copilot runtime to Rust, to Shopify rebuilding the Shop app from React Native to Swift and Kotlin. These projects highlight a clear shift: migrations that once required large teams and multi-quarter roadmaps are now achievable in a fraction of the time.
Earlier this year at PolicyMe, our team took a similar approach to modernize our Health & Dental (H&D) frontend. We extracted the application from a shared legacy repository and upgraded the stack across the board.
| Layer | Legacy monolith | New H&D app |
|---|---|---|
| Framework | React 17 | React 19 |
| Build tooling | Webpack 4 | Vite 7 |
| Testing | Jest and Cypress | Vitest and Playwright |
| Language | Loosely typed JS / TS mix | Strict, type-safe TypeScript |
Historically, scoping a migration like this for a team of four engineers would have meant setting aside a full quarter. With coding agents in our workflow, we gave ourselves two sprints.
Outgrowing the shared monolith
Our legacy frontend monolith served three distinct insurance product lines: Life, Critical Illness, and Health & Dental. While sharing a single repository helped us launch new products quickly early on, the codebase had accumulated significant technical debt. It had grown into a mix of JavaScript and loosely typed TypeScript, backed by a complex Webpack 4 configuration and slow feedback loops.
Advances in coding agents changed the tradeoffs of addressing this debt. Rather than incrementally refactoring inside the monolith, agents made it practical to extract the Health & Dental app into its own repository, modernize the entire toolchain, and pay down years of TypeScript and state management debt in one concentrated push.
Validating the workflow before committing
Modernizing the legacy frontend had come up many times before, which meant we weren’t starting from zero. Prior to kicking off the project, several engineers had independently experimented with coding agents to spin up a lightweight proof of concept, porting a single page over to React 19, Vite, and Playwright.
Those early experiments were compelling. While not production-ready, the proof of concept proved that a fast, feature-for-feature migration was realistic. More importantly, it helped us identify the foundational work required before the whole team jumped in: defining our initial AGENTS.md repository rules, settling on the new directory structure, and scoping the infrastructure changes needed to deploy a standalone app.
AGENTS.md rules, directory layout, standalone infra scope.Four stages in order. Pre-kickoff: Proof of concept. One page ported to React 19, Vite, and Playwright by agents. Pre-kickoff: Groundwork. AGENTS.md rules, directory layout, standalone infra scope. Q2 · Sprints 1–2: Foundations, then porting. State and test harness first, then four engineers porting in parallel. End of sprint 2: Production cutover. nginx points H&D traffic at the new static build.
Measuring the impact
A core team of four engineers kicked off the migration at the start of Q2. Our top priority was preserving both existing user behavior and the analytics events that our data and growth teams depend on, without introducing regressions.
For customers, the transition needed to be invisible. To de-risk the release, we built the new application in a separate repository and used nginx as our routing and rollback mechanism. When we were ready to cut over, we updated our nginx configuration to point traffic to the new static build; if any issues surfaced in production, we could revert traffic back to the monolith immediately.
H&D customers go to the nginx routing config. After cutover, nginx sends them to the New H&D app, a static Vite build. A dashed instant rollback path leads from nginx to the Legacy monolith (Life · CI · old H&D). Life + CI customers go to the Legacy monolith directly. The H&D repo deploys to the new app through its own deploy queue. The Monolith repo deploys to the legacy monolith through the shared queue.
The chart below compares the new Health & Dental application against the legacy monolith across local development speed, codebase footprint, and CI performance, reflecting both the shift to modern tooling and a much leaner application architecture.
| Metric | Monolith | New app | Reduction |
|---|---|---|---|
| Dev server cold startWebpack 4 → Vite 7 | 66.3 s | 1.4 s | |
| Hot module reloadBefore value is qualitative | Sluggish | < 50 ms | |
| Production build sizeStatic output behind nginx | 62 MB | 5.1 MB | |
| Direct dependenciesTrimmed monolith dependencies | 118 | 29 | |
| Async (thunk) code3 monolith files → 13 modular files | 8,983 LOC | 2,558 LOC | |
| State reducers / slicesHand-rolled Redux → Redux Toolkit | 41 reducers | 12 slices | |
| Source filesH&D only, out of a 3-product monolith | 653 | 206 | |
| node_modules footprint | 1.8 GB | 622 MB | |
| Build configuration6 Webpack configs → 1 Vite config | 601 LOC | 267 LOC | |
| CI pipeline durationCircleCI main, independent deploy queue | 23 min | 13 min |
Four headline results. 47× Faster dev server start, 66.3 s → 1.4 s. 92% Smaller build, 62 MB → 5.1 MB. −10m CI pipeline, 23 → 13 min. <50ms Hot reload, was “sluggish”. Below them, a horizontal bar for each of the ten metrics in Table 2 shows its reduction on a scale from 0% to 100%, in three groups. Dev experience & CI: dev server cold start, hot module reload, build configuration, CI pipeline duration. Codebase & bundle: production build size, async (thunk) code, node_modules footprint. Architecture & counts: direct dependencies, state reducers / slices, source files. The hot module reload bar is hatched and labelled “~98% (estimate)” because it is an estimate.
Beyond the raw metrics, we used the migration to simplify how the application is built, tested, and served:
| No SSR server | Day-one test suite | Automated quality gates |
|---|---|---|
| The new app is served as static files behind nginx. | We launched with existing legacy tests ported and expanded test coverage across the pyramid. | We cleared all ESLint, Prettier, and TypeScript strictness debt during the port, and enforce it going forward with lint-staged pre-commit hooks and CI checks. |
What we’ve learned
Agentic workflows look very different from traditional software development. Rather than manually rewriting files line by line, our focus shifted to sequencing foundational tasks, designing repeatable prompts, and verifying agent output against automated checks.
Three inputs feed Agent ports a page: AGENTS.md repo rules, Golden example (hand-ported first page), and Legacy source in the monolith. The ported page goes to the checks: tsc · ESLint, Vitest · Playwright. On fail, the Agent self-corrects and the checks run again. On pass, the page goes to Engineer review, then Merged. A dashed edge labelled new pattern found leads from Engineer review back to AGENTS.md repo rules.
- Sequencing matters: unblock the foundations first. Not everything can be parallelized across agents. Core architectural pieces, like establishing our Redux Toolkit state foundation and configuring the Playwright test harness, had to happen first. Prioritizing those on day one ensured the four of us weren’t stepping on each other’s toes once feature porting began.
- Clear tasks and golden examples are king. Agents performed best when given a concrete reference implementation within the new repo. Whenever we tackled a new pattern, we ported the first page or component closely with the agent, iterating until the architecture and types were exactly where we wanted them. That completed file then became the canonical example we pointed agents to for the remaining pages, turning one manual review into a repeatable workflow.
- Existing tests and linters are force multipliers for agents. Having an existing codebase to reference, paired with strict TypeScript, ESLint rules, and unit tests in the target repo, gave the agents a tight feedback loop. They could port a feature, run the checks, and self-correct type or logic errors before an engineer stepped in for code review.
- Treat
AGENTS.mdas a living artifact. Codifying architectural rules and repository conventions inAGENTS.mdkept generated code aligned with our standards. Where we slipped was forgetting to document a few new patterns we discovered mid-sprint. When another team at PolicyMe kicked off a similar migration right after us, passing along both ourAGENTS.mdand the unwritten lessons we missed along the way gave them an immediate head start.
Where we go from here
Splitting Health & Dental out of the legacy monolith into an independent frontend has raised the ceiling on how fast our team can ship. No longer tied to a shared release queue or a 23-minute CI build, we can deploy updates on our own schedule.
We view this migration as our new baseline. With a strictly typed codebase and fast Vitest and Playwright feedback loops in place, our immediate focus is expanding our end-to-end test coverage. More broadly, we’re continuing to evolve our engineering workflows around coding agents, shifting from using AI for a one-off migration to building a development process where a small team can ship continuously.
Credits
- Joseph Bosire
- Engineering Manager
