Developer Tools

>> Refactoring 100k+ Lines Solo: Master Claude Code 4.8's Dynamic Workflows and Parallel Subagents

Introduction

Can one developer refactor a 100,000+ line legacy codebase without a six-month task force? In May 2026, Anthropic shipped Claude Opus 4.8 and a Claude Code feature called Dynamic Workflows—a research-preview pattern where the agent plans work, fans out parallel subagents, and verifies results before reporting back (Claude Opus 4.8 announcement).

Claude Code Dynamic Workflows refactoring a 100k+ line codebase
Disclosure: SlimVps Editorial publishes this guide. SlimVps rents cloud Macs for long-running dev environments; Claude Code and Anthropic models are third-party products with their own plans and terms.

Claude Code Dynamic Workflows target exactly the pain full-stack teams feel during cross-language or cross-framework migrations: too many files for one chat window, too many dependencies for one sequential agent loop. This article decomposes how the execution tree works, when it beats classic single-thread Claude Code, and a seven-step runbook you can run on a repo with a real test suite—not a demo snippet.

If you are still building baseline agent discipline (evals, context limits), read our AI skills for developers in 2026 guide first; Dynamic Workflows amplify good habits—they do not replace them.

What changed with Opus 4.8 and Dynamic Workflows

Anthropic describes three mechanics that matter for migration work:

MechanicWhat it doesWhy migrations care
Planning phaseClaude decomposes the repo into work unitsAvoids "edit one file until context dies"
Parallel subagentsHundreds of subagents in one sessionFile-level or package-level parallelism
Verification gateAgent checks outputs before final reportReduces silent breakage across 100k lines

Opus 4.8 also emphasizes honesty under uncertainty—early testers report fewer unremarked flaws in generated code versus Opus 4.7. For migrations, that means fewer false "done" states when tests were never run.

Availability (check current docs): Dynamic Workflows launched in research preview on Claude Code for Enterprise, Team, and Max plans. API model id: claude-opus-4-8. Effort control includes xhigh for difficult, long-running jobs.

Architecture: the multi-agent execution tree

Think of Dynamic Workflows as a shallow orchestration tree, not a free-for-all swarm.

Components

NodeResponsibilityTypical artifact
Lead sessionScope, plan, merge strategyMIGRATION.md checklist
PlannerPartition repo (by package, layer, or feature slice)Work-unit manifest JSON
Worker subagentsApply transform + local fixes per sliceBranch commits or patch series
VerifierRun tests/linters, diff review, conflict scanCI log summary
Human mergeApprove PRs, resolve policy conflictsSigned merge commit

Data flow

  1. You define the migration contract: target framework, forbidden APIs, definition of done = green CI.
  2. Lead agent inventories the repo and emits N parallelizable units (often 50–200+ on 100k LOC monoliths).
  3. Subagents execute units with read-only access to shared policy docs and write access only inside their slice.
  4. Verifier aggregates failures; lead either respawns failed units or escalates to you with file paths.
  5. You merge when test-suite bar is met—not when the model says “complete.”

This matches Anthropic’s stated example: codebase-scale migrations across hundreds of thousands of lines from kickoff to merge, with the existing test suite as the bar.

Decision matrix: when Dynamic Workflows win

SituationUse Dynamic Workflows?Recommended alternative
100k+ LOC, mechanical transforms (import paths, API renames)Yes
<5k LOC spikeNoSingle-session Claude Code
Migration with no automated testsNo until tests existAdd characterization tests first
Security-sensitive auth/crypto rewritePartial — plan only; human review each sliceManual lane + agent assist
Need legally auditable diffsYes, with frozen planner manifestStore manifest in git

If your repo has fewer than 30% test coverage on touched modules, do not start Dynamic Workflows. Invest two weeks in golden-path tests; otherwise parallel agents optimize for plausible diffs, not correct behavior.

Prerequisites before you start

  1. CI that runs in <45 minutes on a clean checkout—or per-slice CI with merge queue.
  2. Formatter + linter enforced in CI (agents converge faster with auto-fix loops).
  3. Migration playbook in docs/migration/ (forbidden patterns, target idioms).
  4. Branch strategy: one integration branch; workers target topic branches or stacked PRs.
  5. Token budget: Opus 4.8 at xhigh effort for long jobs; expect higher usage than Opus 4.7 defaults.

For IDE/agent hygiene (allowlists, secrets), cross-check Cursor and alternative stacks—principles apply to Claude Code shells too.

Seven-step migration runbook

Step 1 — Baseline and freeze scope

git checkout -b migration/opus-48-baseline git rev-parse HEAD > .migration/baseline.sha CI=1 npm test 2>&1 | tee .migration/baseline-test.log

Pass: baseline tests green or failures documented in KNOWN_FAILURES.md.

Step 2 — Write the migration contract

Create MIGRATION.md with:

  • Target stack version (e.g. React 19, Spring Boot 3.4)
  • In scope directories
  • Out of scope (generated code, vendored libs)
  • Done = npm test && npm run lint green

Step 3 — Kick off Dynamic Workflow in Claude Code

  1. Select Opus 4.8 (claude-opus-4-8).
  2. Set effort to xhigh for multi-hour migrations.
  3. Use the prompt pattern below and attach MIGRATION.md plus baseline SHA.

Dynamic Workflows are in research preview on eligible Claude Code plans.

Plan a codebase migration per MIGRATION.md.\nPartition into parallel work units ≤ 2k LOC each.\nRun subagents to apply transforms.\nVerify with the existing test suite before reporting done.

Step 4 — Review the planner manifest

CheckFail action
Any unit > 5k LOC?Ask to split
Shared global state touched by >10 units?Serialize that module
Missing test mapping per unit?Add test targets

Save manifest to .migration/units.json in git.

Step 5 — Let workers run; monitor fan-out

  • Cap concurrent edits per directory if VCS conflicts spike.
  • Re-run formatter after each batch merge.
  • Do not accept drive-by refactors outside migration scope.

Expect dozens to hundreds of subagents on large repos.

Step 6 — Verifier gate and CI

git fetch --all npm test 2>&1 | tee .migration/final-test.log diff .migration/baseline-test.log .migration/final-test.log > .migration/test-delta.txt

Pass: no new failures beyond documented known list.

Step 7 — Human merge and postmortem

  • Units spawned / failed / retried
  • Wall-clock hours vs estimate
  • Token spend (from Anthropic usage dashboard)
  • Defects found in staging within 7 days

Merge to main behind feature flag if needed.

Parallel subagent tactics that survive 100k LOC

TacticDetail
Slice by dependency layerUtils → domain → UI reduces cyclic merge pain
Mechanical firstRegex-safe renames before semantic refactors
One concern per unit"Migrate HTTP client" separate from "Migrate state management"
Idempotent scriptsWorkers run codemod CLI; LLM fixes fallout only
Verifier owns flake detectionRetry failed tests once; escalate second failure

Anthropic notes subagents can run longer on Opus 4.8—still set explicit wall-clock ceilings (e.g. 20 minutes per unit) so one hung worker does not block the tree.

Troubleshooting

Error A — "Migration complete" but CI red

Pattern: Lead agent summary claims success; npm test fails on your machine.

Fix:

  1. Re-open session with .migration/final-test.log attached.
  2. Prompt: Enumerate failing tests by work unit from units.json. Respawn only failed units.
  3. Block merge until verifier references passing CI run URL or log hash.

Error B — Merge conflict storm

Pattern: >30% of units touch the same 5 files (e.g. central index.ts).

Fix: Re-plan with a serialization lane for shared files—one subagent owns barrel exports; others produce patches applied sequentially.

git diff --name-only migration/opus-48-baseline...HEAD | sort | uniq -c | sort -nr | head

Files with count > 3 are merge hotspots.

Error C — Rate limits / token exhaustion

Pattern: Subagents stall mid-tree; partial commits litter branches.

Fix: Pause fan-out; merge completed units; resume with smaller batch size (e.g. 25 units). Use xhigh only on remaining hard slices—not entire repo restarts.

If you are…Do this
Solo full-stack100k migration in 3 waves (utils → services → UI); never one Big Bang merge
2–5 person startupOne human owns manifest + merge; agents own slices
Platform teamProvide codemods + CI; Dynamic Workflows only for semantic gaps

If you only have one weekend: scope to 20k LOC with full tests; prove the workflow before betting the monolith.

FAQ

What are Claude Code Dynamic Workflows?
A research-preview orchestration mode where Claude Code plans a large task, runs many parallel subagents in one session, and verifies output before finishing—aimed at repo-scale work like migrations (source).

Do I need Claude Opus 4.8 specifically?
Anthropic tied Dynamic Workflows to the Opus 4.8 generation for longer, more reliable agent runs. Use model id claude-opus-4-8 and check your plan includes Claude Code research features.

Can one person really refactor 100k+ lines?
One person can orchestrate it if CI is strong and transforms are largely mechanical. Semantic rewrites still need human review lanes—Dynamic Workflows compress calendar time, not accountability.

How many parallel subagents run?
Anthropic cites hundreds in a single session on large migrations. Your effective count should be limited by merge conflict data, not the theoretical maximum.

What is the bar for "done"?
The existing automated test suite—not model self-report. Treat verifier output as a pre-merge checklist, not a substitute for your CI.

Does this replace OpenClaw/Dify-style agents?
No. Claude Code Dynamic Workflows are IDE-centric repo refactors. Orchestration platforms (OpenClaw + Dify) solve different problems—ops automation and multi-system workflows—not replacing a disciplined migration runbook.

// SYS.CTA

Run the migration runbook on your stack

This article is vendor-neutral on hosting. When you need macOS capacity for long CI or agent sessions, compare options on our pricing page.