Skip to main content
claude-code15 min read

What the Bun Rewrite Proved About Claude Code Dynamic Workflows

Bun's Zig-to-Rust rewrite shows what Claude Code dynamic workflows can do: parallel subagents, real costs, and copyable engineering playbooks.

claude-codedynamic-workflowsbunagentic-engineeringworkflow2026
What the Bun Rewrite Proved About Claude Code Dynamic Workflows
Read time
15 min
Sections
12
Focus
claude-code

Bun’s rewrite from Zig to Rust is the first large public proof point that Claude Code dynamic workflows are no longer a demo pattern. Anthropic says dynamic workflows can run hundreds of parallel subagents, and the Bun migration shows what that means in practice: roughly 50 dynamic workflows, spread across 11 days, producing a Rust port that has powered Claude Code since June 17, 2026. The estimated API bill at list pricing was about $165,000.

That number is the wrong headline and the right warning. The important change is not that a company spent six figures on coding agents. It is that a small engineering group could point large numbers of AI subagents at a complex systems rewrite, split the work into verifiable shards, and keep enough human control to ship production infrastructure. For founders and engineering leaders, this turns “AI coding assistant” into something closer to an elastic migration team.

This guide breaks down what the Bun rewrite proved, which dynamic workflows you can copy now, which model stack to use, where cheaper models are enough, and where the economics still fail. The goal is not to encourage every team to burn six figures on parallel agents. The goal is to show when agent swarms beat conventional engineering, when they should be routed through cheaper models, and how to design workflows that produce reviewable code instead of expensive noise.

[stat] ~$165,000 Estimated list-price API spend for Bun’s 11-day, ~50-workflow Zig-to-Rust rewrite effort


What changed: dynamic workflows are coding-agent orchestration, not chat

Traditional coding assistants work like pair programmers. A developer asks for a function, a fix, a test, or an explanation. The assistant responds. The developer edits, runs tests, and repeats. That model is useful, but it is fundamentally serial.

Claude Code dynamic workflows change the unit of work. Instead of one assistant following one thread, a workflow can spawn many specialized subagents: one reads the source module, another maps dependencies, another drafts a Rust equivalent, another writes tests, another checks unsafe assumptions, another compares behavior against the original, and another summarizes review risks. Anthropic’s claim that these workflows can run hundreds of parallel subagents matters because large migrations are mostly decomposition problems.

The Bun rewrite is a clean proof point because Zig-to-Rust is not a cosmetic refactor. It crosses language semantics, memory models, build tooling, error handling, standard library conventions, and performance assumptions. A successful port has to preserve behavior while changing almost every surface area of the implementation. That is exactly the kind of work where a single chat thread collapses under context size, but a swarm of narrow agents can make progress.

The workflow that matters looks like this:

  1. Select a bounded subsystem.
  2. Generate a dependency and behavior map.
  3. Spawn subagents against files, tests, call graphs, and edge cases.
  4. Produce candidate Rust implementations.
  5. Run automated checks.
  6. Compare behavior against the source version.
  7. Send only the highest-confidence patches to human reviewers.

The shift is from “AI writes code” to “AI runs an engineering campaign.”

💡 Key Takeaway: Dynamic workflows are valuable when the work can be split into independent, testable units. They are weakest when success depends on taste, ambiguous product judgment, or untestable architecture preferences.


Why the Bun rewrite matters for engineering leaders

Bun’s migration proved four practical things.

First, AI coding agents can work across a real production codebase for more than a single sprint task. An 11-day rewrite campaign is long enough to surface the painful parts: stale context, inconsistent assumptions, duplicate work, tool failures, hidden regressions, and review fatigue.

Second, the economic unit is now the workflow, not the prompt. A single dynamic workflow might consume millions of tokens across planning, code search, subagent calls, patch generation, test output, retries, and final review. The cost only makes sense when the target work is valuable enough to justify that spend.

Third, premium models are not needed for every step. A high-end model should design the plan, arbitrate conflicts, and review risky patches. Cheaper models can classify files, summarize tests, generate boilerplate, write fixture scaffolds, and run first-pass translations. If you use a premium model for every subtask, you are buying convenience at enterprise burn rates.

Fourth, the output still needs engineering discipline. Dynamic workflows do not eliminate test suites, CI, code owners, benchmark gates, or staged rollout. They increase the volume of plausible code. Your process determines whether that code becomes leverage or cleanup debt.

$0.006
DeepSeek V3.2 for a small classification/summarization task
vs
$0.200+
Claude Fable 5 for a heavyweight agent step

For context, Claude Fable 5 is priced at $10 per 1M input tokens and $50 per 1M output tokens with a 1,000,000-token context window. Claude Sonnet 5 is cheaper at $3 input and $15 output per 1M tokens, also with a 1,000,000-token context window. DeepSeek V3.2 is dramatically cheaper at $0.28 input and $0.42 output per 1M tokens, but with a smaller 128,000-token context window. Use AI Cost Check to model your own workflow volume before running a large campaign.


The 7 dynamic coding workflows teams can copy now

The Bun rewrite is the extreme version. Most teams should start with narrower workflows that have clear acceptance criteria. Here are seven practical playbooks.

Workflow Best for Recommended lead model Cheaper fallback Typical cost per run Human review required
Language migration shard Porting modules across languages Claude Fable 5 Claude Sonnet 5 $500-$5,000 Yes, mandatory
Dependency map and risk scan Understanding a subsystem before refactor Claude Sonnet 5 Gemini 3 Flash $10-$150 Yes
Test-generation swarm Increasing coverage before migration Claude Sonnet 5 GPT-5 mini $20-$300 Yes
Bug reproduction factory Turning reports into failing tests GPT-5.3 Codex Codex Mini $5-$80 Yes
API compatibility audit Checking behavioral drift Claude Sonnet 5 DeepSeek V3.2 $25-$250 Yes
Performance regression triage Benchmark diff analysis Claude Fable 5 o4-mini $50-$800 Yes
Documentation and migration guide generation Explaining code changes to teams GPT-5.6 Luna Gemini 2.5 Flash $2-$50 Light review

These estimates assume multi-step agent runs, not single API calls. For example, a test-generation swarm might read 200,000 input tokens, produce 40,000 output tokens, run tools, ingest failures, and retry. On Claude Sonnet 5, that token portion is roughly:

  • Input: 0.2M × $3 = $0.60
  • Output: 0.04M × $15 = $0.60
  • Base model cost: $1.20
  • With retries, tool logs, multi-agent overhead, and review summaries: often 10x-100x, or $12-$120

The gap between raw token math and real workflow spend is where most budgets break. Agent loops multiply context.

⚠️ Warning: Never budget dynamic workflows from a single prompt estimate. Use a multiplier for planning, retries, tool output, test logs, failed branches, and final review. For coding agents, 10x-50x overhead is normal.


Playbook 1: Run a language migration shard like the Bun rewrite

A full Zig-to-Rust rewrite is too large for most teams to copy directly. The useful version is a migration shard: one subsystem, one dependency boundary, one test harness, and one rollback plan.

Step 1: Choose a shard with measurable behavior

Pick a module that has existing tests, stable interfaces, and limited external side effects. Good candidates include parsers, formatters, protocol clients, serialization layers, CLI command handlers, and internal utility packages. Bad candidates include authentication flows, payment logic, production database migrations, and code with weak tests.

Define the migration target in a short spec:

  • Source files and target files
  • Public APIs that must remain compatible
  • Known edge cases
  • Performance baseline
  • Test command
  • Benchmark command
  • Code owner for final review

Step 2: Spawn mapping subagents before generation

Do not ask an agent to port code immediately. First run subagents that produce maps:

  • File dependency map
  • Function behavior summary
  • Error-handling inventory
  • Type and memory ownership assumptions
  • Test coverage gaps
  • Unsafe or low-level operations
  • Performance-sensitive paths

Use Claude Sonnet 5 for this stage if the shard is large. Its 1,000,000-token context makes it suitable for broad subsystem analysis at $3/$15 per 1M tokens. For smaller modules, Gemini 3 Flash at $0.5 input and $3 output per 1M tokens is a strong fallback.

Step 3: Generate tests before the port

The highest-leverage agent output is often not the port itself. It is the failing test that proves the port is incomplete.

Ask subagents to generate:

  • Golden-input/golden-output tests
  • Fuzz-style property tests
  • Boundary tests for empty, huge, malformed, and unicode inputs
  • Compatibility fixtures from production logs
  • Performance benchmark harnesses

Use GPT-5.3 Codex for code-heavy test generation at $1.75 input and $14 output per 1M tokens. Use Codex Mini at $1.5/$6 when the test patterns are repetitive.

Step 4: Run multiple translation agents independently

Spawn several agents with different instructions:

  • One prioritizes literal translation.
  • One prioritizes idiomatic target-language code.
  • One prioritizes performance.
  • One prioritizes safety and correctness.
  • One only writes TODOs and risk notes.

This diversity matters. If all agents share the same prompt, they often make the same wrong assumptions.

Step 5: Merge only after automated comparison

Before human review, run:

  • Source-language tests
  • Target-language tests
  • Fixture comparison
  • API compatibility checks
  • Benchmarks
  • Static analysis
  • Linting
  • Security checks

Then ask a premium model to summarize only the diff, failing tests, changed assumptions, and unresolved risk. This is where Claude Fable 5 earns its price: broad context, higher reasoning quality, and better synthesis across conflicting subagent reports.

Estimated cost

A moderate migration shard might use 8M input tokens and 1.5M output tokens across mapping, tests, generation, logs, and review.

On Claude Sonnet 5:
Input: 8 × $3 = $24
Output: 1.5 × $15 = $22.50
Raw token cost: $46.50
With 20 parallel agents, retries, tool logs, and review loops: $900-$2,500

On Claude Fable 5 for every step:
Input: 8 × $10 = $80
Output: 1.5 × $50 = $75
Raw token cost: $155
With agent overhead: $3,000-$8,000

Recommendation: use Sonnet or Codex for most implementation agents, then use Fable only for architecture review and final arbitration.

📊 Quick Math: If 50 workflows cost about $165,000, the average was roughly $3,300 per workflow. That is reasonable for high-value infrastructure migration, but too expensive for routine CRUD refactors.


Playbook 2: Build a bug reproduction factory

The most broadly useful dynamic workflow is not a rewrite. It is converting ambiguous bug reports into failing tests and candidate fixes.

Step 1: Normalize the bug report

Feed the workflow:

  • User report
  • Logs
  • Stack traces
  • Recent commits
  • Relevant source files
  • Existing tests
  • Environment details
  • Expected behavior

A cheap model can classify severity and route the issue. GPT-5 mini costs $0.25 input and $2 output per 1M tokens with a 500,000-token context, making it a strong triage model. DeepSeek V3.2 is even cheaper at $0.28/$0.42, especially for summarization and clustering.

Step 2: Spawn hypothesis agents

Create subagents for different failure causes:

  • Regression from recent commit
  • Input validation edge case
  • Race condition
  • Dependency version mismatch
  • Platform-specific behavior
  • Cache or state corruption
  • Documentation mismatch rather than code bug

Each agent must produce a minimal reproduction plan, not a fix.

Step 3: Generate failing tests

Ask the best hypothesis agents to write failing tests. The acceptance rule is simple: a test that fails on current main and passes after the candidate fix. No failing test, no patch.

Step 4: Generate candidate fixes

Use code-specialized models for patches. GPT-5.3 Codex at $1.75/$14 is a strong default. Grok Code Fast 1 at $0.2 input and $1.5 output per 1M tokens is a cheaper fallback for small patches.

Step 5: Review with a separate model

Do not let the same agent that wrote the patch approve it. A reviewer agent should check:

  • Does the test actually prove the bug?
  • Is the fix minimal?
  • Does it add hidden behavior changes?
  • Does it affect performance?
  • Does it require docs or migration notes?

For critical bugs, use Claude Sonnet 5 as reviewer. For low-risk issues, use GPT-5 mini or Gemini 3 Flash.

Estimated cost

A typical bug reproduction workflow can fit into 500,000 input tokens and 100,000 output tokens, multiplied by agent loops.

Using GPT-5.3 Codex:

  • Input: 0.5 × $1.75 = $0.88
  • Output: 0.1 × $14 = $1.40
  • Raw cost: $2.28
  • Practical dynamic workflow cost: $10-$80

This is the easiest workflow to justify economically. If it saves one engineer an hour, it pays for itself.


Model stack recommendations for dynamic coding workflows

The best stack is routed, not monolithic. Use premium context and reasoning only where they change the outcome.

Role Best model Why Cheaper option
Workflow planner Claude Fable 5 Best for high-stakes multi-agent planning and synthesis Claude Sonnet 5
Subsystem mapper Claude Sonnet 5 Large context at lower price than Fable Gemini 3 Flash
Code patch generator GPT-5.3 Codex Strong code-focused pricing and context Codex Mini
Bulk summarizer Gemini 3 Flash Good long-context economics Gemini 2.5 Flash
Cheap classifier DeepSeek V3.2 Very low output price GPT-5 nano
Final reviewer Claude Fable 5 Best used sparingly on high-risk diffs o3 or Claude Sonnet 5
Documentation writer GPT-5.6 Luna Good price-performance for prose and technical synthesis Gemini 2.5 Flash

GPT-5.6 Luna is priced at $1 input and $6 output per 1M tokens with a 1,050,000-token context window, making it useful for release notes, migration guides, and implementation summaries. GPT-5 nano at $0.05/$0.4 is appropriate for labels, routing decisions, and small transformations. Gemini 2.5 Flash at $0.3/$2.5 is a strong fallback for large-volume summarization.

If you are comparing premium general models for engineering work, start with GPT-5 vs Claude Opus 4.6 and GPT-5 vs Gemini 3 Pro. For budget routing, GPT-5 vs DeepSeek V3.2 is the more relevant comparison.


Cost model: how a six-figure agent campaign happens

The Bun estimate makes sense when you model dynamic workflows as many nested calls.

A single heavyweight workflow might include:

  • 1 planning pass
  • 20 mapping agents
  • 40 code-generation agents
  • 20 test-generation agents
  • 10 benchmark and compatibility agents
  • 10 reviewer agents
  • 3 retry rounds
  • CI logs and tool output added back into context
  • Final synthesis and patch selection

Even if each subagent averages only 100,000 input tokens and 20,000 output tokens, 100 subagent calls becomes 10M input tokens and 2M output tokens before retries. On Claude Fable 5, that raw token cost is:

  • Input: 10 × $10 = $100
  • Output: 2 × $50 = $100
  • Total raw: $200

That sounds cheap until you add long context, repeated tool traces, failed branches, multiple rounds, duplicated file reads, and final review. A true workflow can expand by 10x-40x, producing $2,000-$8,000 per serious run. Multiply by roughly 50 workflows, and the reported $165,000 estimate is plausible.

Scale Example Runs Estimated spend
Small team experiment One bug factory + one test swarm 5-10 $100-$1,000
Department pilot Several refactor shards 20-40 $5,000-$40,000
Major migration campaign Language or platform rewrite 50-150 $100,000-$500,000+
Continuous agent engineering Always-on bug, test, review agents Monthly $10,000-$250,000/month

The right question is not “is $165,000 expensive?” The right question is whether the workflow replaced or accelerated more than $165,000 of engineering time, opportunity cost, and calendar delay. For a strategic infrastructure rewrite, the answer can be yes. For ordinary feature work, the answer is usually no.


Governance: how to keep dynamic workflows from becoming expensive chaos

Dynamic workflows need hard constraints. Without them, agents will explore, retry, summarize, and rewrite until the budget is gone.

Use these controls:

  1. Budget per workflow. Set a hard dollar limit before launch.
  2. Token caps per subagent. Prevent one branch from swallowing the run.
  3. Depth limits. Cap retry loops and recursive task spawning.
  4. Patch-size limits. Reject diffs that are too large to review.
  5. Test-first gates. Require failing tests before fixes.
  6. Model routing. Use cheap models for low-risk tasks.
  7. Human approval checkpoints. Never auto-merge generated migration code.
  8. Replayable logs. Store prompts, tool calls, diffs, and decisions.
  9. Evaluation harnesses. Score output against tests, benchmarks, and static checks.
  10. Kill switches. Stop workflows when failure rates spike.

A useful pattern is “cheap fan-out, expensive fan-in.” Use low-cost models to explore many possibilities, then use a premium model to synthesize the best options. This mirrors how human engineering teams work: many engineers investigate, then senior reviewers decide.

✅ TL;DR: Use dynamic workflows for bounded, testable engineering campaigns. Route cheap models for mapping and boilerplate, reserve premium models for planning and final review, and enforce hard budget gates before agents start spawning more agents.


When dynamic workflows make sense

Use Claude Code dynamic workflows when the work has three traits: high value, high parallelism, and objective verification.

Strong fits:

  • Language migrations
  • Framework upgrades
  • Test suite expansion
  • Bug reproduction at scale
  • API compatibility audits
  • Security remediation campaigns
  • Documentation regeneration after large changes
  • Performance regression triage
  • Monorepo dependency modernization

Weak fits:

  • Greenfield product design
  • UI taste decisions
  • Ambiguous architecture debates
  • Untested legacy systems
  • One-off small features
  • Highly regulated changes without human signoff
  • Code with unclear ownership
  • Systems where incorrect behavior is hard to detect

For startups, the best first project is usually a bug reproduction factory or test-generation swarm. These produce reviewable artifacts and improve the codebase even when patches are rejected. For larger companies, migration shards and dependency modernization can justify bigger budgets because calendar compression is valuable.

The Bun rewrite shows what is possible at the frontier: agent swarms can help move a production-grade system across languages. But the reusable lesson is smaller: decompose work, verify behavior, route models by difficulty, and treat agents as an elastic engineering system with costs attached.


Practical architecture for your first dynamic workflow

A minimal production-grade setup needs five layers.

1. Task planner

The planner converts a human objective into a DAG of tasks. Use Claude Sonnet 5 for normal workflows and Claude Fable 5 for high-risk migrations. The output should be structured JSON with task names, inputs, acceptance criteria, model choice, and budget.

2. Context packer

The context packer selects files, docs, tests, logs, and dependency information. This layer prevents waste. Sending an entire repository into every subagent is the fastest way to burn money.

3. Subagent runner

The runner executes tasks in parallel with token caps. Each subagent should produce one artifact: a map, a test, a patch, a risk note, or a benchmark summary.

4. Evaluator

The evaluator runs tests, linters, static analysis, benchmarks, and compatibility checks. It should score artifacts before any human sees them.

5. Reviewer and merger

The reviewer summarizes accepted artifacts, rejected artifacts, risks, and open questions. Humans approve final diffs. Use a premium model only after automated filtering.

A good first budget is $500-$2,000 for a serious pilot. That is enough to run multiple workflows, compare model routes, and produce a real cost curve without risking a Bun-sized surprise. Use AI Cost Check to calculate the model mix before the run.


Frequently asked questions

What are Claude Code dynamic workflows?

Claude Code dynamic workflows are multi-agent coding workflows that decompose an engineering task into many parallel subagents. Instead of one chat thread, the system can map code, generate tests, create patches, run checks, and summarize review risks across many coordinated tasks.

How much did the Bun rewrite cost?

The estimated API bill was roughly $165,000 at list pricing for about 50 dynamic workflows over 11 days. That averages around $3,300 per workflow, though actual cost depends on model routing, token volume, retries, and tool output.

Which model should I use for large coding-agent workflows?

Use Claude Sonnet 5 as the default planner and mapper, GPT-5.3 Codex for code generation, and Claude Fable 5 only for high-risk planning or final review. Use cheaper models like DeepSeek V3.2, Gemini 3 Flash, or GPT-5 mini for classification, summaries, and boilerplate.

When are dynamic workflows not worth the money?

They are not worth it for small features, weakly tested legacy code, ambiguous product work, or changes where correctness cannot be automatically checked. Use them when the task is parallel, valuable, and verifiable.

How do I estimate my own dynamic workflow cost?

Estimate total input and output tokens across all subagents, then multiply by model pricing and add a 10x-50x agent overhead factor for retries, tool logs, planning, and review loops. Run scenarios in AI Cost Check before launching a large workflow.


Build your first agent workflow with a budget attached

The Bun rewrite proved that dynamic coding workflows can now tackle work that used to require a dedicated migration team. The next step is not copying the $165,000 spend. It is copying the operating model: bounded shards, parallel subagents, test-first verification, routed models, and human-controlled merges.

Start with one workflow that improves your codebase even if the patch is rejected: a bug reproduction factory, a test-generation swarm, or a dependency risk scan. Price the run with AI Cost Check, compare premium and budget routes with pages like GPT-5 vs DeepSeek V3.2, and reserve expensive models for the decisions that actually need them.