DEV Community

Lumafy
Lumafy

Posted on

The Sumner Method: What Bun's AI-Assisted Zig Rust Rewrite Teaches About Large Migrations

Jarred Sumner's write-up on rewriting Bun from Zig to Rust is one of the most concrete public examples of AI-assisted large-scale engineering.

The striking part is not just the numbers. It is the workflow design.

According to the official Bun post, the rewrite involved about 50 Claude Code dynamic workflows, 64 Claude agents at peak, 6,778 commits, roughly 16,000 compiler errors worked down, and a +1M-line diff.

Official source: https://bun.com/blog/bun-in-rust

I studied the workflow and extracted the reusable parts into an open-source playbook:

https://github.com/Lumafy/sumner-method

This article summarizes the pattern.

The Core Loop

The reusable workflow is not "ask AI to rewrite the codebase."

It is closer to this:

while (task = nextTask()) {
  const result = implement(task);
  const feedback = adversarialReview(result);
  const fixed = applyFeedback(result, feedback);
  runGates(fixed);
}
Enter fullscreen mode Exit fullscreen mode

The key design choice is separation:

  • one agent implements
  • separate agents review
  • reviewers see the diff, not the implementer's reasoning
  • fixes go through gates instead of being trusted automatically

Why Rust Makes This Pattern More Practical

Rust gives AI agents a lot of machine-checkable feedback:

  • compiler errors
  • borrow checker failures
  • clippy warnings
  • Miri checks
  • unsafe audits
  • tests
  • compile-time assertions

For one person, thousands of compiler errors are overwhelming. For a decomposed workflow, they can become a queue.

That does not make the migration easy. It makes the work observable.

The 8 Phases

The playbook breaks the process into these phases:

Phase Goal
A Extract facts and write a porting guide
B Mechanically translate files
C Fix compile errors
D Bring up runtime behavior
E Make tests pass
F Remove performance regressions
G Improve code quality
H Harden security

Each phase should have:

  • a bounded task queue
  • a clear definition of done
  • review prompts
  • machine-checkable gates
  • a way to record blocked items

Adversarial Review

The most reusable idea is adversarial review.

Instead of asking a reviewer agent to "check this code", the reviewer is instructed to assume the code is wrong and prove every claim from source files, target files, tests, or docs.

This changes the review task from approval to falsification.

That matters because AI-generated code often looks plausible even when it is subtly wrong.

What I Put in the Repo

The repository includes:

  • phase templates
  • role prompts for implementer, reviewer, fixer, and orchestrator
  • workflow notes for Claude Code
  • examples of bug classes adversarial review should catch
  • a Bun case study summary

Repo:

https://github.com/Lumafy/sumner-method

What This Is Not

This is not a claim that AI can replace engineering judgment.

The lesson I took from Bun's rewrite is almost the opposite: AI agents become useful when surrounded by more engineering structure, not less.

The work has to be decomposed, reviewed, measured, and gated.

Without that structure, "AI rewrite" is just a high-risk batch of plausible diffs.

Top comments (0)