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.

Table 1. The stack, before and after
LayerLegacy monolithNew H&D app
FrameworkReact 17React 19
Build toolingWebpack 4Vite 7
TestingJest and CypressVitest and Playwright
LanguageLoosely typed JS / TS mixStrict, 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.

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.
Figure 1. From proof of concept to production

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.

Flowchart of nginx routing H&D customers to the new H&D app after cutover, with a dashed instant rollback path to the legacy monolith.after cutoverinstant rollbackown deploy queueshared queueH&D customersnginxrouting configNew H&D appstatic Vite buildLegacy monolithLife · CI · old H&DLife + CI customersH&D repoMonolith repo
Figure 2. Cutover and rollback through nginx. The cutover was a single config change, so the rollback was too. The dashed path back to the monolith stayed available after launch.

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.

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”
MetricMonolithNew appReduction
Dev server cold startWebpack 4 → Vite 766.3 s1.4 s
−97.9%
Hot module reloadBefore value is qualitativeSluggish< 50 ms
~98%
Production build sizeStatic output behind nginx62 MB5.1 MB
−91.8%
Direct dependenciesTrimmed monolith dependencies11829
−75.4%
Async (thunk) code3 monolith files → 13 modular files8,983 LOC2,558 LOC
−71.5%
State reducers / slicesHand-rolled Redux → Redux Toolkit41 reducers12 slices
−70.7%
Source filesH&D only, out of a 3-product monolith653206
−68.5%
node_modules footprint1.8 GB622 MB
−65.4%
Build configuration6 Webpack configs → 1 Vite config601 LOC267 LOC
−55.6%
CI pipeline durationCircleCI main, independent deploy queue23 min13 min
−43.5%
Figure 3. New H&D app vs. legacy monolith. Ten measurements from the migration. The hatched hot-reload bar is an estimate: its “before” value is qualitative, not measured.

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:

Table 2. How the application is built, tested, and served
No SSR serverDay-one test suiteAutomated 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.

Flowchart of the porting loop, from legacy source and golden example through agent porting, tsc and ESLint checks, and engineer review to merge.failpassnew pattern foundAGENTS.mdrepo rulesAgent ports a pageGolden examplehand-ported first pageLegacy sourcein the monolithtsc · ESLintVitest · PlaywrightAgent self-correctsEngineer reviewMerged
Figure 4. The porting loop. Each pattern started with one closely reviewed example. The automated checks let agents fix their own mistakes before a human looked at the code. The dashed edge is the step we sometimes skipped.

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.md as a living artifact. Codifying architectural rules and repository conventions in AGENTS.md kept 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 our AGENTS.md and 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

Come build with us

We're hiring engineers who care about secure, well-built software. See what's open on the PolicyMe engineering team.

See open roles