← Back to library

Port a huge TypeScript runtime to Rust in small merges

Stephen Toub describes moving GitHub's Copilot agent runtime from TypeScript on Node to over eight hundred thousand lines of Rust in a few months, mostly as one developer directing Copilot. Work landed across 128 pull requests into main while the team kept adding features. Temporary bindings let ported functions call each other until the TypeScript was gone.

  • OutcomeRewrite a core runtime into a faster language with agents doing most of the coding, shipping piece by piece rather than in one risky cutover.
  • SetupAn afternoon+
  • LevelAdvanced
  • CreditStephen Toub
View original
Works with
Microsoft Copilot

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 23, 2026

When should you use it?

  • A runtime's language limits performance or embedding
  • The codebase keeps changing during the port
  • You need to avoid a big-bang cutover

Not for: Small apps where a rewrite is not justified; Teams without strong test coverage

What do you need, and what do you get?

You need

  • A coding agent with repo access
  • A temporary interop layer between old and new languages
  • CI and incremental rollout

You get

  • Ported modules merged continuously
  • A temporary seam that shrinks to zero
  • A native binary with a small public interface

How does it work, step by step?

  1. Pick an incremental strategyPort function by function on main instead of on a separate branch held open for months.
  2. Build a temporary seamExpose ported Rust to the remaining TypeScript and back through Node native bindings.
  3. Keep shippingMerge each piece so users meet regressions one at a time, when they are easy to fix.
  4. Watch the true volumeNew TypeScript kept arriving; track lines in and out, not just what is left.
  5. Collapse the seamFinish when no temporary bindings or old call sites remain.

The prompt

Our own prompt, inspired by Stephen Toub and written to work in Microsoft Copilot. Values in lime are placeholders.

Prompt0 variables
We are porting [module] from TypeScript to Rust incrementally. Port only [function or file] in this pull request. Keep its behavior identical, add a temporary binding so existing TypeScript callers still work, and add tests comparing old and new outputs on [fixtures]. Report the current count of temporary bindings and remaining TypeScript call sites.

Inspired by Stephen Toub: Migrating the GitHub Copilot runtime to Rust, using Copilot. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.

What can go wrong?

  • Initial size estimates were badly misleading because the code grew during the port.
  • Running several versions of a component at once was avoided because of merge churn.

Our take

Most teams will never port eight hundred thousand lines, but Stephen Toub's method transfers. Incremental merges into a always-shippable main, a temporary seam of bindings so ported functions can call the old ones, and honest tracking of how much new TypeScript kept arriving during the migration are the practices that matter. The insight that the old codebase grew while the port was underway is a warning for any migration plan that assumes a frozen target. Have the agent produce a daily count of remaining seam functions so progress is visible and morale does not depend on vibes. Keep a human owner for the interface design across the seam; that is where long-term cost lives if the temporary layer becomes permanent. Prefer many small pull requests over heroic branches. Measure runtime behavior, not only compile success, before collapsing each slice of the seam. Document why Rust was chosen so future maintainers know which constraints still apply.

Where the time goes back: Agents make a rewrite that would have needed a team for a year or more affordable for one person in months.

FAQ

How big did the seam get?
At its peak it had over 2,000 temporary exports and over 3,300 call sites, all removed by the end.
Who did the work?
Mainly one developer directing agents, as teammates continued adding capabilities.

Source and credit

Inspired by Stephen Toub. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.

Inspired by
Migrating the GitHub Copilot runtime to Rust, using Copilot
Creator
Stephen Toub
Published on
github.blog
Original date
Sep 16, 2026
License
Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
Originally for
Microsoft Copilot
AI dry run
Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

Are you the creator? Claim or correct this page.

More in Operations & Admin

All 203 Operations & Admin playbooks →

Related playbooks

Operations & AdminWorkflow✓ AI dry run

Give each business function its own reviewing agent

Cover finance, tax, legal, marketing and ops as a solo founder, with agents that check each other before anything goes out.

Credit: João Pedro Silva Setas

An afternoon+
Operations & AdminSkill✓ AI dry run

Keep your coding agent on current web platform features

Add Google Chrome's modern-web-guidance skill to Claude Code, Codex, Cursor or another coding agent so that before it writes front-end code it looks up a vetted guide for the pattern at hand, uses built-in browser features such as native dialogs instead of old JavaScript workarounds, applies fallbacks only where browser support requires them, and tells you which guides shaped the change.

Credit: GoogleChrome

Minutes
Operations & AdminWorkflow✓ AI dry run

Add a merge check for every way coding agents break code

Keep a running list of the specific ways coding agents have damaged your repository, from hollow tests and invented fake responses to deleted files and silenced type errors, and turn each one into an automated gate that blocks the merge, so the same mistake cannot slip through review twice.

Credit: u/alexmarquardt on r/ClaudeCode

An afternoon+
Operations & AdminWorkflow✓ AI dry run

Keep parallel coding agents on written design files

Keep four to eight coding agents busy without losing track, by having them build only from finished written designs.

Credit: Manuel Schipper

An afternoon+