>> 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 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:
| Mechanic | What it does | Why migrations care |
|---|---|---|
| Planning phase | Claude decomposes the repo into work units | Avoids "edit one file until context dies" |
| Parallel subagents | Hundreds of subagents in one session | File-level or package-level parallelism |
| Verification gate | Agent checks outputs before final report | Reduces 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
| Node | Responsibility | Typical artifact |
|---|---|---|
| Lead session | Scope, plan, merge strategy | MIGRATION.md checklist |
| Planner | Partition repo (by package, layer, or feature slice) | Work-unit manifest JSON |
| Worker subagents | Apply transform + local fixes per slice | Branch commits or patch series |
| Verifier | Run tests/linters, diff review, conflict scan | CI log summary |
| Human merge | Approve PRs, resolve policy conflicts | Signed merge commit |
Data flow
- You define the migration contract: target framework, forbidden APIs, definition of done = green CI.
- Lead agent inventories the repo and emits N parallelizable units (often 50–200+ on 100k LOC monoliths).
- Subagents execute units with read-only access to shared policy docs and write access only inside their slice.
- Verifier aggregates failures; lead either respawns failed units or escalates to you with file paths.
- 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
| Situation | Use Dynamic Workflows? | Recommended alternative |
|---|---|---|
| 100k+ LOC, mechanical transforms (import paths, API renames) | Yes | — |
| <5k LOC spike | No | Single-session Claude Code |
| Migration with no automated tests | No until tests exist | Add characterization tests first |
| Security-sensitive auth/crypto rewrite | Partial — plan only; human review each slice | Manual lane + agent assist |
| Need legally auditable diffs | Yes, with frozen planner manifest | Store 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
- CI that runs in <45 minutes on a clean checkout—or per-slice CI with merge queue.
- Formatter + linter enforced in CI (agents converge faster with auto-fix loops).
- Migration playbook in
docs/migration/(forbidden patterns, target idioms). - Branch strategy: one integration branch; workers target topic branches or stacked PRs.
- Token budget: Opus 4.8 at
xhigheffort 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 lintgreen
Step 3 — Kick off Dynamic Workflow in Claude Code
- Select Opus 4.8 (
claude-opus-4-8). - Set effort to
xhighfor multi-hour migrations. - Use the prompt pattern below and attach
MIGRATION.mdplus 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
| Check | Fail 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
| Tactic | Detail |
|---|---|
| Slice by dependency layer | Utils → domain → UI reduces cyclic merge pain |
| Mechanical first | Regex-safe renames before semantic refactors |
| One concern per unit | "Migrate HTTP client" separate from "Migrate state management" |
| Idempotent scripts | Workers run codemod CLI; LLM fixes fallout only |
| Verifier owns flake detection | Retry 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:
- Re-open session with
.migration/final-test.logattached. - Prompt:
Enumerate failing tests by work unit from units.json. Respawn only failed units. - 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.
Recommended path by team size
| If you are… | Do this |
|---|---|
| Solo full-stack | 100k migration in 3 waves (utils → services → UI); never one Big Bang merge |
| 2–5 person startup | One human owns manifest + merge; agents own slices |
| Platform team | Provide 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.
Related reading
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.