Claude Code Dynamic Workflows: Orchestrating Hundreds of AI Agents from a Single Session
A single Claude Code agent can fix a bug, add a component, update a config. Dynamic Workflows let Claude write an orchestration script that dispatches hundreds of agents in parallel — coordinating code migrations, security audits, and architecture analysis at a scale that was impossible with single-pass prompting. Jarred Sumner used it to rewrite Bun from Zig to Rust: 750,000 lines of code in eleven days.
12 min read
The Problem: Tasks Too Big for a Single Agent Pass
Claude Code changed how developers interact with AI by putting an autonomous agent in the terminal. But terminal agents have a structural ceiling. A single conversation has a single context window. A single context window can hold only so many files, tool outputs, and reasoning steps before it saturates. For small tasks — fix a bug, add a component, update a config — that ceiling never matters. For large tasks — migrate a codebase from one language to another, audit security across hundreds of endpoints, refactor an entire module hierarchy — a single agent pass is not enough.
On May 28, 2026, Anthropic shipped Dynamic Workflows in Claude Code. [1] The feature lets Claude write a JavaScript orchestration script at runtime, spin up tens to hundreds of parallel subagents, coordinate their work, validate results, and present a final answer — all within a single session. Work that developers would normally plan in quarters now finishes in days. This article explains what Dynamic Workflows are, how they work, where they fit alongside other orchestration tools, and what they cannot do yet.
What Dynamic Workflows Are
A Dynamic Workflow is a JavaScript script that orchestrates subagents at scale. You describe a task in natural language. Claude analyzes the task, decomposes it into subtasks, and writes an orchestration script that defines the execution plan — what agents to launch, in what order, with what inputs, and how to validate their outputs. A separate runtime executes the script in an isolated environment outside your conversation, keeping your session responsive while agents work in the background. [2]
The key architectural insight is that the plan moves to code. In a normal Claude Code session, the model reasons about what to do next inside the conversation — every planning step, every decision, every course correction consumes context window tokens. In a Dynamic Workflow, the orchestration logic lives in a JavaScript script outside the conversation. The script decides what to launch, in what order, with what conditional or loop logic, and keeps intermediate state in variables that live outside any single agent's context. Coordination costs zero model tokens. [3]
How It Differs from Regular Claude Code
Regular Claude Code operates as a single agent in a terminal session. You prompt, it reasons, it acts — file reads, shell commands, git operations — and you approve each step. Sub-agents can be spawned (up to three levels deep), but the orchestration logic lives inside the conversation. For a deeper look at the base features, see our guide to .
Dynamic Workflows change the execution model in three ways:
Scale. Up to 16 agents run concurrently, and up to 1,000 agents total per execution. Regular Claude Code tops out at a handful of nested sub-agents.
Deterministic control flow. The JavaScript orchestration script owns the branching, looping, and error handling. You can inspect it, modify it, and rerun it. The agent does the thinking; you own the control flow.
Background execution. The workflow runs in the background while your session stays interactive. You get notified when it completes or hits an issue.
The mental model shift: regular Claude Code is a single developer at a terminal. Dynamic Workflows is a project manager dispatching a team of specialists, each with their own context window and scoped permissions, all following a plan written in executable code.
The Workflow Paradigm: Scripts, Agents, and Pipelines
Dynamic Workflows use two core primitives: agent() and pipeline(). An agent() call spawns a subagent with a specific prompt, scoped permissions, and an isolated context. A pipeline() call sequences multiple agent calls, passing outputs from one stage to the next. [4] Because the orchestration is JavaScript, you get branching (if/else), loops (for, while), parallel execution (Promise.all), and error handling (try/catch) for free.
A typical workflow follows a pattern: a planning agent decomposes the task, a fan-out phase dispatches specialized agents in parallel, a validation phase checks results, and a fix loop retries failed subtasks until constraints are met. Claude generates this structure automatically from your task description, but you can also save, edit, and rerun workflow scripts manually via the /workflows command.
Branching and Conditional Logic
Because the orchestration script is standard JavaScript, conditional logic is native. A migration workflow can check whether a file uses a deprecated API pattern and dispatch different agents depending on the result — one for simple renames, another for complex structural changes. The branching logic is visible, inspectable, and editable in the script.
Loops and Fix Cycles
Iterative correction is built into the paradigm. A workflow can run a build, check for errors, dispatch fix agents for each failing module, rebuild, and repeat until the build passes or a retry limit is hit. This loop pattern is what makes Dynamic Workflows viable for messy, real-world codebases where a single pass rarely produces clean results.
Parallel Fan-Out
The most common pattern is fan-out: decompose a task into independent subtasks and dispatch agents in parallel. A security audit workflow can fan out across every API endpoint in the codebase simultaneously, with each agent checking a single endpoint for vulnerabilities. The runtime manages concurrency (up to 16 simultaneous agents) and collects results.
Integration with Existing Claude Code Features
Dynamic Workflows do not replace Claude Code's existing capabilities — they orchestrate them at scale.
MCP servers. Every subagent in a workflow can access the same MCP servers configured for your Claude Code session. A workflow that audits documentation can use a Playwright MCP server to verify that every link in your docs resolves, while simultaneously using a GitHub MCP server to check for open issues related to each page.
Tool use. Subagents have full access to Claude Code's tool palette — file reads, file writes, shell commands, git operations. Scoped permissions from the parent workflow can restrict which tools a given subagent may use, enforcing least privilege across the fleet.
Hooks. Claude Code hooks fire for each subagent action. A PostToolUse hook that logs every file write to your observability pipeline will capture writes from all workflow agents, giving you a complete audit trail of what a 200-agent workflow touched.
Context engineering. Each subagent gets its own context window, which means the orchestration script is itself an exercise in context engineering — deciding what each agent needs to see (and what it does not need to see) to do its job well. The most effective workflows scope each agent's context tightly: one file, one function, one specific question.
What You Can Build: Real-World Use Cases
Large-Scale Code Migrations
The headline example: Jarred Sumner used Dynamic Workflows to port Bun from Zig to Rust — roughly 750,000 lines of code in eleven days, with 99.8% of the existing test suite passing. [5] The workflow ran in phases: one workflow mapped Rust lifetimes for every struct field in the Zig codebase, the next wrote every .rs file as a behavior-identical port with two reviewers per file, a fix loop drove the build and test suite until clean, and an overnight workflow addressed unnecessary data copies and opened a PR for each. Peak throughput hit about 1,300 lines of code per minute. The project cost approximately $165,000 at API pricing.
Codebase-Wide Security Audits
A security audit workflow can fan out across every file in a project, with specialized agents checking for SQL injection, XSS, hardcoded secrets, insecure dependencies, and authentication gaps — all in parallel. The orchestration script collects findings, deduplicates, ranks by severity, and produces a structured report. What would take a security team days of manual review compresses into a single workflow session.
CI/CD Pipeline Generation
Claude Code with Dynamic Workflows can generate GitHub Actions or GitLab CI configurations from natural language descriptions, not as generic templates but as project-specific pipelines that match your actual constraints. [6] One agent analyzes your build system, another maps your test structure, a third identifies deployment targets, and the orchestration script synthesizes their outputs into a complete pipeline with proper caching and parallelization.
Multi-Agent Code Review
A workflow can assign multiple reviewer agents to a pull request — one checking logic correctness, another verifying test coverage, a third auditing for style and convention compliance, and a fourth checking for security issues. Each reviewer agent works independently with its own context, and the orchestration script merges their feedback into a single consolidated review.
Architecture Analysis
For complex legacy codebases, a workflow can dispatch agents to map dependency graphs, identify circular imports, measure coupling between modules, and produce architecture diagrams — tasks that require reading far more code than a single context window can hold.
How Dynamic Workflows Compare to Other Orchestration Tools
Dynamic Workflows occupy a specific niche in the orchestration landscape. Understanding where they fit — and where they do not — prevents using the wrong tool for the job. [7]
LangGraph is a runtime application framework for building stateful agent workflows that run in production. It is purpose-built for persistent state, conditional branching with checkpoints, human-in-the-loop approval gates, and cross-session continuity. Dynamic Workflows are a development-time tool — they run during coding sessions, not as deployed production services. If your agent needs durable state across sessions, LangGraph is the right choice. Claude Code can be used to build LangGraph applications.
Temporal wraps every execution in crash-proof durability with exactly-once semantics and auditable execution history. [8] Dynamic Workflows have no cross-session state persistence, no exactly-once guarantees, and no auditable execution history beyond the session log. If your agent touches money, legal records, or any irreversible operation, Temporal belongs in your stack — Dynamic Workflows does not.
n8n is a visual automation platform where you connect trigger nodes to action nodes in a drag-and-drop interface. AI is an add-on, not the core. n8n excels at event-driven business automation — when a form is submitted, send an email, update a spreadsheet, notify a Slack channel. Dynamic Workflows excel when the AI model itself needs to decide what step comes next based on what it reads. [9] Different tools for different jobs.
Microsoft Agent Framework and similar enterprise agent platforms focus on deploying and managing agents as persistent services with monitoring, governance, and integration into corporate identity systems. Dynamic Workflows is scoped to development tasks within Claude Code sessions. It is not a general-purpose agent deployment platform.
The short version: Dynamic Workflows orchestrate AI agents during development. LangGraph, Temporal, n8n, and enterprise agent frameworks orchestrate agents (or automation) in production. They complement each other rather than compete.
Token Economics and Cost Management
Dynamic Workflows can burn through tokens fast. Every agent in a workflow pays its own context overhead. Fan a task across 40 agents and you pay 40 context setups, not one. Input tokens from context accumulation are usually the biggest cost driver, not output tokens. [10] The Bun rewrite consumed approximately $165,000 in API costs over eleven days.
Two strategies help manage costs:
Model tiering. Use Claude Haiku for narrow, well-defined subtasks (file-by-file linting, simple transformations) and reserve Sonnet or Opus for complex reasoning tasks (architecture decisions, novel code generation). Model tiering is the single biggest lever for cost reduction.
Scope bounding. Give each agent the minimum context it needs. An agent checking a single file for a specific pattern does not need your entire project tree in its context. Tight scoping prevents context bloat and keeps per-agent costs low.
Anthropic recommends logging input_tokens and output_tokens per call from day one and setting alerts for per-run token budgets. Workflows will pause when you hit your usage limit and continue automatically when it resets, rather than dropping agents mid-execution.
Availability and Access
Dynamic Workflows are available in the Claude Code CLI, the Desktop app, and the VS Code extension for Pro, Max, Team, and Enterprise plans. They are also accessible through the Claude API, Amazon Bedrock, Google Cloud Vertex AI, and Microsoft Foundry. The feature launched as a research preview on May 28, 2026 and moved toward general availability through the summer, with enterprise reliability improvements shipping through September 2026. [11]
You can trigger a workflow by including the word "workflow" in your prompt, or by using the /workflows slash command. Custom workflow scripts can be saved to your project's .claude/commands/ directory for reuse.
What Dynamic Workflows Cannot Do Yet
For all their power, Dynamic Workflows have clear boundaries:
No cross-session state. A workflow lives and dies within a single session. There is no built-in mechanism to resume a workflow after a session ends. For durable, long-running orchestration, you still need something like Temporal or LangGraph.
No exactly-once semantics. If an agent fails mid-execution, the retry logic is best-effort. There are no transactional guarantees. This is fine for code generation and analysis. It is not fine for operations that must execute exactly once.
No visual builder. Despite the visual workflow trend in the broader automation market, Dynamic Workflows are defined in code (JavaScript scripts), not in a drag-and-drop interface. The trade-off: maximum flexibility for developers, higher barrier for non-technical users.
Token cost opacity. It is difficult to predict the token cost of a workflow before running it. The cost depends on how many agents are spawned, how much context each receives, and how many retry cycles occur. Cost estimation tooling is still maturing.
Concurrency ceiling. The hard limit of 16 concurrent agents and 1,000 total agents per run means truly massive codebases may require multiple workflow runs or batching strategies.
Development-time only. Dynamic Workflows run during coding sessions. They are not designed for production runtime orchestration, scheduled automation, or event-driven triggers. Use CI/CD tools, cron systems, or dedicated agent platforms for those use cases.
Where This Is Heading
Dynamic Workflows represent a shift in what AI coding tools can take on. The ceiling is no longer "what can one agent do in one pass" but "what can a coordinated fleet of agents accomplish across a codebase." The Bun rewrite is the proof point: a project that would have taken a human team months was completed in under two weeks, at a cost that, while significant, is a fraction of the equivalent engineering payroll.
Alongside Dynamic Workflows, Anthropic's Code with Claude event in May 2026 also announced Managed Agents (persistent agents that respond to triggers without constant human input) and Proactive Workflows (agents that identify conditions in your codebase and initiate actions on their own). [12] The three features together point toward a future where Claude Code is less a coding tool and more a software development orchestration platform — one where the developer's primary job is defining intent and constraints, and AI handles the execution.
The developers who learn to think in workflows — decomposing large goals into parallelizable subtasks with clear validation criteria — will have a compounding advantage as these tools mature. Start with small workflows on well-understood tasks. Build intuition for what works as a single agent pass and what needs orchestration. The gap between the two approaches is only going to widen.