Code migration is the task where agents either show their best or fail publicly: it is too easy to “deliver” non-working code that looks convincing. The browser-use architectural rewrite case and the meetup experience of the community give you a working five-step method — and an honest map of the limits of applicability. We cover both: the rewrite figures, the steps of the method, typical failure modes, and how to turn a migration into an occasion to simplify the architecture. Data and practices are current as of fall 2026.
The browser-use Case: Rewrite Figures
The community case is an architectural rewrite of the browser-use library carried out by agents. The result in figures: the library’s codebase shrank by 90% — the new stack was built on Python with Chrome DevTools; quality grew by 50%; individual tasks became 2–5 times cheaper; the cost came to about 71% of the original variant; input tokens were halved. For a detailed breakdown of this case, see the material on code migration by agents.
The key point: this is not a “translation from one language to another” but precisely an architectural rewrite — a reduction in codebase size plus a rethinking of the stack for the task. A routine port from language to language usually preserves the size and drags the old problems along with it. The difference between migration types is in the table:
| Migration type | Difficulty | Lesson |
|---|---|---|
| Architectural rewrite (browser-use: a new stack on Python with Chrome DevTools) | High: the core is rewritten against a PRD, 2–5 iterations | A migration is an occasion to simplify the architecture: size down 90%, cost about 71% of the original variant, input tokens halved |
| Port from language to language | Looks easier, but the size is preserved | The old problems move together with the code; without a PRD and reference tests it is a garbage transfer |
| A move between builders (Make → n8n) | High for an agent: it requires knowledge of the nodes of the specific tool | Lev’s case: the agent failed and the finishing had to be done by hand — a limit of the method’s applicability |
| Migration with hidden dependencies | The agent will not check them on its own | Binary dependencies and licenses go into the PRD’s constraint map, drawn up by a human before the first iteration |
The Five-Step Method
The method from community meetups consists of five steps, and in it the order matters no less than the content:
- Reference tests. Before the first edit — a set of tests on the current code: what must work after the migration, no arguments. Tests capture the system’s actual behavior, not the developers’ intentions, which makes them the only defense against “confidently non-working code.”
- A PRD. A formal description of the migration’s goal, the requirements, and the constraint map: binary dependencies, licenses, unbreakable interfaces. For how to prepare such a document for an agent, see the PRD method.
- The core. The agent rewrites the central outline against the PRD, leaning on the reference tests. Not everything at once: first the outline that defines the architecture, everything else after that outline has stabilized.
- Architecture review. A human checks the decisions the tests do not cover: structure, dependencies, module boundaries. Tests capture behavior, but they will not tell you that the modular structure is a bad one.
- Diff audit. A final pass over the changes: anything redundant or suspicious is cut before the merge. The diff is the most honest document of a migration: it shows everything the agent did beyond the task.
Practice on the workload: the core takes 2–5 iterations — the first version almost never passes the reference tests in full, and that is normal as long as the tests exist. Each iteration is a test run and fixes based on the difference; in this cycle the pairing of an agent with a plan and review works well: how to get started in Claude Code. The order of the steps matters too: tests without a PRD give a chaotic rewrite, and a PRD without reference tests give confidently non-working code.
Where Agents Fail
A live case from a meetup: Lev set up n8n MCP, exported a scenario from Make, and sent it to the neural network with the instruction “assemble this scenario” — in n8n it failed, and the finishing had to be done by hand. The reason is not the model’s “weakness” but knowledge of the tool: a scenario lives in a specific builder with its own nodes, and the agent lacks the internal rules needed to assemble it without errors. On connecting external systems to an agent, see connectors and MCP.
The general principle: a neural network “will always give an answer, even when none exists” — for migration this is doubly dangerous, because the generated code looks convincing and it is easy to merge it into the main branch. A telling example from a meetup: ask it to edit a video programmatically and the model will start building contraptions on FFmpeg, even though services like Submagic run on Remotion under the hood; you have to know the solution yourself and say “plan it with Remotion.” Migration is the same: without a constraint map, the agent will confidently “find” a solution that does not exist. For what the vibe-coding market shows about generation without a specification, see the separate breakdown.
The agent will not check binary dependencies and licenses on its own: their place is the constraint map in the PRD, drawn up by a human before the first iteration. The same map takes unbreakable interfaces and environment requirements: everything that cannot be derived from the code must be fixed in words before the start.
Migration as a Moment to Simplify the Architecture
The main takeaway of the case: a migration is a moment to simplify the architecture, not only to change the language. The 90% cut in the library’s size came not from “translation” but from deleting the excess: reducing the stack to Python and Chrome DevTools at the same time brought the cost down to about 71% and halved the input tokens. If your migration reproduces the old structure one to one, you are paying to move garbage; if you let the agent rethink the core against a PRD and tests, you get cheaper and cleaner at the same time.
Plan approval and control stay with a human, as in ordinary agent development. An agent carries out a reduction confidently when it knows what counts as excess, but deciding what is excess belongs to whoever answers for the product. Hence the review requirement: cutting 90% of the codebase means thousands of deleted lines, and only a human can confirm that none of them were needed.
Checklist Before the First Iteration
- Reference tests on the current code — before any edit.
- A constraint map in the PRD: dependencies, licenses, unbreakable interfaces.
- A definition of done: which tests must pass and what counts as completion.
- An architecture review plan: who checks what, beyond the tests.
- A diff audit before the merge: the redundant is cut, the suspicious is explained.
The checklist adds no new steps — it locks in the order: skip the first item and the last one loses its value.
Frequently Asked Questions
How many iterations should you plan for? For the core — 2–5 runs; each iteration is a pass of the reference tests plus fixes based on the difference. If the tests still fail after the fifth run, the cause is usually the PRD, not the number of attempts.
Can you migrate without tests? No: reference tests are the first step of the method; without them the diff audit has nothing to lean on, and the code’s persuasiveness will stand in for its working state.
Why did Make → n8n fail? A scenario lives in a specific builder with its own nodes; the agent lacks knowledge of the tool — cases like this stay manual, and that is a limit of applicability, not a failure of the whole method.
What goes into the PRD? The goal, the requirements, the definition of done, and the constraint map: dependencies, licenses, and interfaces that must not break.
Migration by agents is a manageable process: five steps, 2–5 iterations on the core, a diff audit at the end; it works when reference tests and a human architecture review are in place, and the winner is whoever uses it as an occasion to simplify the architecture. Your action: for your next migration, draw up the constraint map in the PRD before the agent’s first iteration — it is exactly what separates a rewrite from a garbage transfer.
