A Dynamic Workflow is a JavaScript script Claude writes and a runtime runs in the background while your session stays responsive. The first one I built does something I used to do by hand on every branch: run the reviewers, fix what they flag, verify the fixes, and get the branch ready to merge. This article was written by a different one, a ten-stage pipeline that mines what actually happened in a build and drafts the post before it ever reaches me. Everything below binds to the Claude workflows documentation, because that is the mechanism the whole piece rests on.
A workflow is a script, not a conversation
If you have handed a model a big multi-step task and watched the context fill up halfway through, you already understand the problem. Every intermediate result lands back in the conversation, and by the time the loop finishes you are spending a meaningful fraction of each turn just replaying what already happened. A Dynamic Workflow moves the loop out of the conversation entirely. You describe the job, the runtime writes a JavaScript script and runs it in the background, and you can keep working while it turns the crank.
The shift worth noticing is where the work lives. The runtime executes the script in an isolated environment, separate from the conversation. Intermediate results stay in script variables instead of landing in Claude's context. The loop, the branching, and the partial results live in the script. The conversation holds only the final answer. That is what keeps the session responsive even when the run spawns dozens of agents.
Why a script and not just more subagents
We already run plenty of work through subagents and skills, so the obvious question was why move the plan into code at all. With subagents and skills, Claude is the orchestrator: it decides turn by turn what to spawn next, and every result lands in Claude's context. A workflow script holds the loop, the branching, and the intermediate results itself, so Claude's context holds only the final answer. The boundary between the two approaches is where the state lives: with subagents it sits in Claude's context, and with a workflow it sits in the script.
That is what buys repeatability. A workflow moves the plan into code, and code is something you can read, rerun, and hand to the next clone of the repo without re-explaining it. It also coordinates more agents than one conversation can hold, because the runtime is tracking results instead of the context window. The guidance on when to reach for it is honest about scope: reach for a workflow when a task needs more agents than one conversation can coordinate, or when you want the orchestration codified as a script you can read and rerun. Not for a handful of delegated tasks a few subagents already cover. We treat that as the gate. If three or four subagents already do the job in conversation, we leave it in conversation.
The ground-truth loop
One job we point a workflow at is gathering source material and then refusing to trust it on the first pass. A workflow can fan out agents to collect findings, then have independent agents adversarially review each other's findings before they are reported. Moving the plan into code also lets a workflow apply a repeatable quality pattern, not just run more agents: it can draft from several angles and weigh them against each other, so you get a more trustworthy result than a single pass. The claims that do not survive the cross-check get filtered out before anything reaches the report.
The bundled /deep-research workflow does exactly this over the web. It fans out web searches on a question across several angles, fetches and cross-checks the sources it finds, votes on each claim, and returns a cited report with claims that did not survive cross-checking filtered out. That is the documented shape, and it is the shape our article research borrows. The intended use here is the same loop pointed at our own session logs instead of the open web: gather what actually happened in a build, then cross-check it before a single sentence claims it.
This article is the proof, and the proof is not tidy. When the workflow first drafted this piece, a bug kept the session path from reaching the script, so the ground-truth stage ran empty. The draft did the right thing with nothing: it refused to state a single number it could not cite, and flagged the hole instead of filling it with a plausible guess. That refusal exposed the missing hard gate, and the workflow now blocks publish-readiness when a ground-truthed article has no verified session facts. We then mined the build session by hand, line by line, and every number in the next section is one we watched in the raw transcript. Verify everything. If it is not verified, it does not count.
Here is what the hand-mining turned up, and it was not a clean highlight reel. The build run opened with a throwaway smoke test, two small agents answering a toy question just to prove the primitive ran at all, and even that burned 171,000 tokens in eight seconds. That one number reset how we thought about the cost of a fan-out before we wrote a line of the real workflow. The first real pass then came back with red CI, because the review agents had quietly grown a memory file past a 200-line cap while they worked, and the branch stayed red until we tracked it down and trimmed it. None of that messiness is in the tidy summary. It is in the transcript, line by line, which is the whole reason we point the loop at our own logs instead of our memory. The log remembers what a clean story would rather forget.
Draft, illustrate, review: the stages in one run
Inside a single run, the runtime does the spawning. It holds two ceilings: up to 16 agents running at once, fewer on machines with limited CPU cores, and 1,000 agents total per run. Read those as guardrails more than limits you will feel day to day. They bound how much of your machine a run can claim, and they stop a loop that misbehaves from spawning forever. For an article, the stages map onto that budget directly: agents that pull and verify source material, agents that draft sections, agents that build the diagrams, and agents that adversarially review the result against the brief.
Two mechanics shape every stage, and they work together. Every agent inherits the session's model unless the script explicitly routes a stage to a different model, so a cheaper model can carry the mechanical stages while the session model handles synthesis. And the run is resumable: if you stop it, agents that already completed return their cached results, and the rest run live. Resume works within the same Claude Code session. Exit Claude Code while a workflow is running and the next session starts the workflow fresh.
The model-routing mechanic is the one we lean on hardest. Left alone, every agent in the run inherits the session model, which for our work is usually the flagship. Spread across the spawning the workflow does, that is a lot of expensive reasoning aimed at mechanical work. So the script routes deliberately. The gather-and-verify agents and the draft agents do not need the session model to do their job, and the script can name a cheaper one for those stages while reserving the flagship for the synthesis that actually needs the depth. The resume behavior is the other lever. A run that already finished the gather stage does not pay for it twice; stop the run, fix the brief, resume, and the completed agents hand back their cached results instead of re-spending. Together, these two mechanics are how you keep a fan-out from quietly becoming a bill you did not plan for.
Now the cost, named plainly: a workflow run is token-heavy. It spawns many agents, so a single run can use far more tokens than working the same task in conversation, and every run counts against the plan's usage and rate limits. That is the trade you make for coordination you could not hold in one context. We manage it two ways. First, the routing above keeps the expensive model off the mechanical stages. Second, and this is the bigger lever, a stage does not have to run on Claude at all: our workflows hand stages to Codex, Cursor, and Gemini agents that run on their own subscriptions, so a heavy run is split across providers instead of billed entirely to our Claude usage. Our review workflow does this on every pass, fanning out a Claude reviewer and a Codex reviewer side by side. We do not pretend the run is free. We reach for it when the fan-out earns the bill, route the work across models and providers to keep that bill sane, and stay in conversation when a workflow is not worth it.
The first workflow I built: review-fix-merge
The first Dynamic Workflow I built was not for these articles. It automated something I was already doing by hand on every branch: run the reviewers, read what they flag, fix the P0 and P1 findings, verify each fix, and get the branch ready to merge. That loop was repeatable, I was running it constantly, and it was exactly the kind of plan that belongs in code. So the week the primitive shipped, I moved it into a workflow: review-fix-merge.
It is worth telling what happened the first time I ran it, because it ran on itself. I pointed it at its own pull request. It fanned out six reviewers, synthesized eight P0 and P1 findings, and handed each one to a fix agent that patched it and re-verified the patch. One of the eight was a real P0: a path where a failed push would still have returned ready_to_merge: true with the pull request number, the URL, and the commit hash all null. The workflow found that bug in its own code, on its own pull request. The whole run was 27 agents, about 2.5 million tokens, about 46 minutes. Then it pushed the branch, opened the PR, and checked back with me.
Running unattended like that is only safe because of a boundary worth naming. Your permission mode controls only the launch prompt. The subagents the workflow spawns always run in acceptEdits mode and inherit your tool allowlist, regardless of your session's mode. File edits are auto-approved; shell commands, web fetches, and MCP tools that are not in the allowlist can still prompt mid-run. So a workflow can edit files freely, but it cannot quietly reach past the tools you already trusted.
The boundary, exactly: a workflow's subagents run in acceptEdits mode and inherit your tool allowlist no matter what mode your session is in. File edits auto-approve; anything outside the allowlist still prompts.
Once a workflow earns its keep, it is easy to keep around. After a run, the script can be saved as a slash command, either to the project directory under .claude/workflows/ to share with every clone of the repo, or to your home directory for personal use across projects. Saved workflows show up in autocomplete next to the bundled ones. review-fix-merge lives in our project directory now, so it is one command away on any branch.
That last step is the whole design. It did not merge. It checked with me. Every workflow I run stops one step short of the irreversible action. review-fix-merge fans out the review and the fixes, then hands back a merge-readiness verdict and leaves the actual merge to me. The article workflow that drafted this post, article-generator, runs ten stages, mining the session, researching, drafting, building the diagrams, judging, and polishing, then hands back a publish-readiness verdict and leaves the publish to me. You are reading that handoff right now: the workflow wrote the draft and built the diagrams, and the final wording is mine. The workflow does the fan-out. I own the call you cannot take back. I only merge on green when it is really green, and I only publish when the words are actually mine.
When the harness writes the workflow for you
The operator-facing controls are simpler than the machinery underneath. Including the word workflow anywhere in a prompt causes Claude Code to highlight it and write a workflow script for that task instead of working through it turn by turn. You can suppress the trigger per-prompt with alt+w, or turn it off globally in /config. The word itself is the switch. Type it when you want the codified plan, drop it when you want the conversation.
There is a higher gear. Ultracode is a Claude Code setting that pairs xhigh reasoning effort with automatic workflow orchestration. With it on, the harness itself flags when a task warrants a workflow, and a single request can turn into several workflows in a row: one to understand the code, one to make the change, and one to verify it. Useful, and worth being deliberate about. Each of those workflows carries the same token bill we just named, so leaving Ultracode on can turn a quick question into the kind of run you would normally choose on purpose. We reach for it when the depth is worth the spend, and leave it off when it is not.
One instruction worth keeping: Claude tends to build a bigger workflow than the task needs. When we ask for one, we add a line like "keep it simple, do not overcomplicate this, the smallest workflow that does the job." Left unprompted, the default reaches for more stages and more fan-out than the work earns, which is exactly what runs up the token bill. Telling it to stay minimal is most of what keeps a run cheap.
Dynamic workflows are in research preview. They require Claude Code v2.1.154 or later and are available on all paid plans, with Anthropic API access, and on Amazon Bedrock, Google Cloud Vertex AI, and Microsoft Foundry. Research preview means the surface can move. We adopted it the week it shipped, built review-fix-merge first, then kept going: a workflow that drafts these articles, one that turns an issue into a verified merge-ready draft PR, a morning news brief, a cold-start repo orientation. They have started to chain, where one workflow builds the branch and another reviews it. That is the ThinkFox posture: Day Zero on adoption, careful on what we actually write. The primitive does one boring, durable thing well, which is to move the orchestration plan out of the conversation and into a script we can read, rerun, and trust.