Navigation
  • Home
  • Work
  • About
  • Writing
  • Contact
Socials
LinkedInGitHubEmailResume
Writing
Code by AsjadAsjad Anwar
  • Work
  • About
  • Writing
  • Contact
12 November 2026 · 5 min read

Migrating 86,000 lines from Vue to React with an AI agent

The app I had to move was a customer-facing e-commerce support app written in Vue with Bootstrap: order lookup, returns, subscription changes, checkout, a chat widget, all driven by server-defined steps. The target was React, TypeScript, Tailwind, Zustand and TanStack Query. Today the React codebase is about 86,000 lines of TypeScript with roughly 1,500 tests.

I did most of the conversion with an AI coding agent. The agent typed fast and remembered nothing. Almost all of the useful engineering went into what I put around it.

Pack the old codebase and keep it in the repo

The first thing I did was pack the entire Vue app into a single reference file with a repo-packing tool and commit it at the root of the React project. It is about 45,000 lines.

That file became the specification. The rule file tells the agent to look there before it invents anything. Need a constant? Check whether the Vue app already defines it, and reuse the name and the values. About to add a postMessage type for the host page? Check which name the Vue app used, because the script on the other side of the frame already listens for that one.

A rewrite fails quietly when the new code is plausible but different. An agent that can search the original produces the same behaviour in a different syntax, which is what a migration is.

Write the conversion rules down

I started with a short conversion rule file and let it grow each time I corrected the same thing twice. The early version was mostly mechanical:

  • A Bootstrap to Tailwind class table (d-flex becomes flex, w-100 becomes w-full, and so on), plus "never introduce a new Bootstrap class".
  • Keep any class name the backend's per-brand CSS might target, even if it looks legacy.
  • Port font sizes exactly. Designers tuned them, and "close enough" shows.
  • No inline alert boxes. Every error goes through one toast system.

Later it became a project guide of about 1,300 lines covering forms, data fetching, stores, modals, embedding and routing.

The rules that held up best were the ones that state the reason. "Always use braces" gets ignored. "Braceless bodies break when a later edit adds a line" gets followed, by the agent and by people.

One ticket at a time

I kept a file of numbered conversion tickets, each small enough to review in one sitting: port the chat widget and its stylesheet, replace every direct HTTP import with the shared API client, audit one group of components for hardcoded colours.

Each session took one ticket, finished it, and recorded what was done in a notes file the agent reads at the start of the next session. That file is the only memory there is. It holds the ticket status and the facts that kept being rediscovered, such as which auth header scheme the API expects and that responses are not wrapped in an extra data envelope.

Small tickets also made the output reviewable. A diff covering one screen can be compared against the Vue original line by line. A diff covering twelve cannot.

What went wrong

These are real examples from the notes and the cleanup that followed.

Wrong assumptions about the API. Converted services read response.data.data when the backend returns the payload directly, and sent a Bearer token to an API that expects a different scheme. Both look right. Both fail only at runtime.

Casts instead of types. When a field was missing from a model, the converted code cast to any to reach it. The chat settings on the brand config were read that way until the cast was banned.

Faithfully ported dead code. The Vue app had an event chain for a feature that no template ever triggered. The React port reproduced the scaffolding, including a component. It was deleted once someone traced it back.

Stubs that looked finished. A loading flag hardcoded to false. A modal component that rendered nothing. A hook exported from the barrel with zero consumers.

Hardcoded navigation. Shared components called navigate('/session') directly. A second top-level experience with its own routes also flowed through those components, and a stale link could leave a session on a screen of inert buttons. The fix was a single registry that decides where a session lives, plus a route guard.

When I first turned lint on properly, the codebase had about 175 errors and 1,400 warnings.

Ban the cast and make lint enforce it

Asking the agent not to use any did nothing. Making it fail the build did.

// eslint.config.js (excerpt)
'no-restricted-syntax': [
  'error',
  {
    selector: 'TSAsExpression > TSAnyKeyword, TSTypeAssertion > TSAnyKeyword',
    message: 'Never cast to any. Add the missing field to the model.',
  },
],

The rule the agent now follows is to add the field to the model:

// Before: compiles, hides a missing field
const isPreview = (session as any)?.is_preview

// After: the model says what the API sends
interface SessionData {
  is_preview?: boolean
}
const isPreview = session?.is_preview

Lint also runs with zero warnings allowed, every eslint-disable must name one rule and give a reason, and no-restricted-imports stops shared code importing from a feature area.

Honest status: casts to any are gone and blocked. any written as an annotation is not. About 900 remain, most of them function parameters over lists the models still type loosely, so the blanket no-explicit-any rule is still off. The plan is to type the lists at the model and let the parameters fall away, then turn the rule on as a ratchet.

Tests found what review missed

I added tests at the edit boundary instead of backfilling: any change to utilities or stores ships a test. No snapshots, because the UI was still being redesigned and snapshots get approved blind.

The first real batch found five bugs, including:

  • The shared input component was not a forwardRef, so the form library could not attach its ref and validation never ran.
  • A field the API sends and the app reads was missing from the session type.

Coverage thresholds are set per directory at the level that exists today, so a drop fails CI.

Staying shippable

Type-check, lint and the test run all gate the build in CI, and a pre-commit hook runs lint and formatting on staged files. The React app was already serving customers while conversion and cleanup tickets were still landing, so every ticket had to leave the main branch deployable.

Takeaways

  • Commit the old codebase as one searchable file. It turns "write this screen" into "port this screen".
  • Put conventions in a rule file with reasons, and extend it every time you repeat a correction.
  • Slice the work into tickets a person can review against the original in one sitting.
  • Anything you only ask for will drift. Anything the build enforces will hold.
  • Expect plausible errors: wrong response shapes, casts, stubs, ported dead code. Review for those specifically.
  • Be honest about what is unfinished. Mine is roughly 900 any annotations still to type.
All writing

Let’s work
together

Get in touch
theasjadanwar@gmail.com+92 321 4010734Resume (PDF)LinkedInGitHub
Version2026 edition
Based inLahore, Pakistan (UTC+5)
SocialsLinkedInGitHub