Claude Code Dynamic Workflows: Orchestrate Hundreds of Agents via JavaScript
Anthropic's Dynamic Workflows for Claude Code let developers write JavaScript orchestration scripts that schedule dozens to hundreds of sub-agents in parallel, keeping intermediate results in script variables instead of context, enabling reproducible, observable, and reusable large-scale coding tasks like Bun's 750k-line Rust migration.
What It Is: Moving Planning from Conversation into Scripts
In standard Claude Code usage, the model keeps its plan in its head, deciding the next step each turn and funneling all sub-agent results back into the conversation context. Large tasks explode the context window and prevent true parallelism.
Dynamic Workflows change this: Claude writes a JavaScript orchestration script from a single prompt, hands it to an independent runtime that executes in the background, and schedules dozens to hundreds of sub-agents. Intermediate results stay in script variables, the parent session stays responsive, and only a single coordinated answer is returned at the end.
The official documentation highlights the key difference: sub-agents, skills, and agent teams are all directed by Claude turn-by-turn, whereas a workflow's baton is held by the script — so the orchestration can be saved and re-run.
Figure 1: Real-time progress view of a React→Solid migration workflow (source: Anthropic official blog)
Getting Started: Three Trigger Methods
ultracode keyword : Include "ultracode" in the prompt (prior to v2.1.160 the keyword was "workflow"), or simply say "use a workflow"; Claude Code will highlight and generate a script for that task.
/effort ultracode : A session-level switch that sets reasoning intensity to xhigh, letting Claude decide which tasks deserve a workflow — a single request may be split into coherent "understand code, implement, verify" workflows.
/deep-research : A built-in workflow that performs multi-angle retrieval, cross-verifies sources, and produces a cited report.
Prerequisite: Claude Code v2.1.154 or later. Pro users must enable manually in /config; Enterprise is admin-controlled; Max, Team, and API have it on by default. The first run shows the plan and raw script for confirmation.
Dissecting an Official Script
The documentation's audit example, saved as a workflow, looks like this:
export const meta = {
name: 'audit-routes',
description: 'Audit every route handler for missing auth checks'
}
const found = await agent('List every .ts file under src/routes/.', { schema: {...} })
const audits = await pipeline(found.files, file =
agent(`Audit ${file} for missing authentication checks.`, { label: file }),
)
return audits.filter(Boolean) metaholds metadata; the body is plain JavaScript with top-level await: agent() spawns one sub-agent, pipeline() maps over a list spawning one per item, parallel() runs a group concurrently. agent() returns null on interruption, so the trailing filter(Boolean) removes empty slots.
Two important constraints:
Date.now() and Math.random() throw errors directly — this ensures re-runs reproduce the exact same call sequence.
Scripts cannot touch the filesystem or shell; all reads, writes, and executions are delegated to sub-agents.
More Reliable Results: Adversarial Verification Baked into Code
The value of workflows isn't just "more agents" — it's codifying quality patterns. In /deep-research, every conclusion must pass cross-voting by multiple independent agents; failures are filtered, unverifiable claims are marked unverified. In Bun's migration, each .rs file got two independent reviewer agents — letting agents rebut each other's findings, which is hard in a single pass but natural when encoded in a script .
Boundaries and Costs: What You Need to Know
Hard limits : max 16 concurrent agents, 1,000 total agents per run, 4,096 items per parallel / pipeline call.
No mid-run intervention : only permission prompts can pause; steps requiring human sign-off must be split into multiple workflows run sequentially.
Resume only within the same session : pausing works and completed agents read from cache; exiting Claude Code forces a full restart.
Token consumption is significantly higher : official guidance suggests a small trial run first; a "Large workflow" warning appears above 25 agents or an estimated 1.5 million tokens. /config lets you set scale tiers (default "medium" ≈ 15 agents), and lightweight phases can swap to a smaller model.
Satisfactory workflows can be saved as slash commands via /workflows and stored in the project's .claude/workflows/ directory for team-wide reuse.
Summary
Dynamic Workflows upgrade Claude Code's unit of work from "one conversation turn" to "one orchestrated run": plans become code, execution is observable, and results are reusable. Deploy them when a task exceeds a single context window or when the orchestration is worth repeating; for small fixes, regular chat and one or two sub-agents remain the most economical choice.
References
Official blog: https://claude.com/blog/introducing-dynamic-workflows-in-claude-code
Official docs: https://code.claude.com/docs/en/workflows
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
AI Step-by-Step
Sharing AI knowledge, practical implementation records, and more.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
