Dynamic workflows 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’s Agent Platform, and Microsoft Foundry. On Pro, turn them on from the Dynamic workflows row in
/config.When to use a workflow
Subagents, skills, agent teams, and workflows can all run a multi-step task. The difference is who holds the plan:
A workflow moves the plan into code. With subagents, skills, and agent teams, Claude is the orchestrator: it decides turn by turn what to spawn or assign next, and every result lands in a context window. A workflow script holds the loop, the branching, and the intermediate results itself, so Claude’s context holds only the final answer.
Moving the plan into code also lets a workflow apply a repeatable quality pattern, not just run more agents: it can have independent agents adversarially review each other’s findings before they’re reported, or draft a plan from several angles and weigh them against each other, so you get a more trustworthy result than a single pass.
Run a bundled workflow
The quickest way to see a workflow in action is to run/deep-research, the built-in workflow Claude Code includes for investigating a question across many sources. You’ll see agents work through a set of phases in the background while your session stays free, and get one report at the end instead of a turn-by-turn transcript.
1
Run the workflow
Run
/deep-research with a question you want investigated. It fans out web searches across several angles, fetches and cross-checks the sources it finds, and synthesizes a cited report.2
Allow workflows
Claude Code asks whether to allow the workflow. Select Yes to continue. The exact prompt depends on your permission mode. See Approve the plan before it runs for the per-mode options.
3
Watch progress
The run starts in the background. Run The view shows each phase with its agent count, token total, and elapsed time. Drill into any phase to see its agents and what each one found. See Watch the run for the full set of controls.You can also watch from the task panel below the input box: a one-line progress summary appears there while the run is going. Press the down arrow to focus it, then Enter to expand.
/workflows, use the arrow keys to select the run, and press Enter to open its progress view:4
Read the report
When the run finishes, the report lands in your session. It cites the sources each claim came from, with claims that didn’t survive cross-checking already filtered out.As of v2.1.196, when the verifier agents can’t check a claim, such as after a rate limit or API error, the report lists that claim as unverified instead of counting it as refuted.
Bundled workflows
Claude Code includes/deep-research as a built-in workflow:
Workflows you save yourself become commands the same way and appear in
/ autocomplete alongside the bundled ones.
Watch the run
Workflows run in the background, so the session stays responsive while agents work. Run/workflows at any time to list running and completed workflows, then select one to open its progress view.
Have Claude write a workflow
You can have Claude write a workflow for your task in two ways:- Ask for a workflow in your prompt, either in your own words or by including the keyword
ultracode, and Claude writes one for the task. - Let Claude decide with ultracode: set
/effort ultracodeand Claude plans a workflow for every substantive task in the session.
/deep-research, or one you’ve saved.
Ask for a workflow in your prompt
To run a single task as a workflow without changing the session’s effort level, include the keywordultracode in your prompt. Asking in your own words, for example “use a workflow” or “run a workflow”, also works: Claude treats a direct request as the same opt-in. Before v2.1.160 the literal trigger keyword was workflow; natural-language requests work in both versions.
Dismiss or turn off the keyword
If you didn’t mean to start a workflow, pressOption+W on macOS or Alt+W on Windows and Linux to dismiss the highlight for this prompt, or press backspace while the cursor is right after the highlighted keyword. To stop the keyword from triggering at all, turn off Ultracode keyword trigger in /config.
Where the keyword works
The keyword is an opt-in only in a prompt you type yourself: at the interactive prompt, in an IDE extension panel, in a Remote Control client, or in an Agent SDK application that stamps your keyboard input’sorigin as { kind: "human" }. It doesn’t start a workflow when it reaches the session another way:
- a prompt passed with
-p - a prompt an Agent SDK application sends without stamping it as human input
- a scheduled task prompt
- a webhook payload or pull request comment relayed into the conversation
Before v2.1.210, the keyword started a workflow from any of these routes too, including a webhook payload or pull request comment relayed into the conversation.
Let Claude decide with ultracode
Ultracode is a Claude Code setting that combinesxhigh reasoning effort with automatic workflow orchestration. With it on, Claude plans a workflow for each substantive task instead of waiting for you to ask.
claude --effort ultracode. Requires Claude Code v2.1.203 or later.
With ultracode on, Claude decides when a task warrants a workflow. 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. This applies to every task in the session, so each request uses more tokens and takes longer than at lower effort levels.
Ultracode lasts for the current session and resets when you start a new one. Drop back with /effort high when you return to routine work. It’s available on models that support xhigh effort; on other models the /effort menu doesn’t offer it.
Approve the plan before it runs
In the CLI, the per-run prompt shows the planned phases and these options:- Yes, run it: start the run
- Yes, and don’t ask again for
<name>in<path>: start, and skip this prompt for this workflow in this project from now on - View raw script: read the script before deciding
- No: cancel
Ctrl+G opens the script in your editor. Tab lets you adjust the prompt before the run starts.
Whether you see this prompt depends on your permission mode:
In the Desktop app, an approval card shows the workflow name, the phase list, and a token-usage caution, with Once, Always, and Deny actions. The progress view appears in the Background tasks side pane.
Your permission mode controls only the launch prompt above. 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 aren’t in your allowlist can still prompt you mid-run. To avoid this on a long run, add the commands the agents need to your allowlist before starting.
In claude -p and the Agent SDK there is no one to prompt, so tool calls follow your configured permission rules without interactive confirmation.
Save the workflow for reuse
When Claude writes a workflow for a task you’ll repeat, you can save that run’s script as a command. A process like a review you run on every branch then runs the same orchestration each time. Run/workflows, select the run you want to keep, and press s. In the save dialog, Tab toggles between the two save locations:
.claude/workflows/in your project: shared with everyone who clones the repo~/.claude/workflows/in your home directory: available in every project, visible only to you. If you setCLAUDE_CONFIG_DIR, this location is theworkflows/directory under that path.
~/.claude/workflows/ even when CLAUDE_CONFIG_DIR was set; the file was still saved under the configured directory.
Press Enter to save. The workflow runs as /<name> in future sessions from either location.
In a monorepo with several .claude/ directories, you can keep workflows alongside the package they apply to. As of v2.1.178, saving to the project location writes to the closest .claude/workflows/ directory that already exists between your working directory and the repository root, or to the repository root if none exists yet. Project workflows also load from every .claude/workflows/ along that path, and when more than one defines the same name Claude Code runs the one closest to the working directory.
If a project workflow and a personal workflow share a name, the project one runs.
Pass input to a saved workflow
A saved workflow can accept input through theargs parameter. The script reads it as a global named args. Use this to supply a research question, a list of target paths, or a configuration object at invocation time instead of editing the script for each run.
The following prompt runs a saved workflow with a list of issue numbers:
args directly without parsing it first. If args is omitted, the global is undefined inside the script.
Example workflow prompts
A workflow fits best when the task is larger than one agent can hold in context, or when the same step needs to run across many items. The prompts below show common shapes. Each one asks Claude to write and run a workflow for that task; you don’t write the script yourself.Audit many files for the same issue
Fan out one agent per file, then collect and verify the findings.Keep fixing until a check passes
Run a checker, fix what failed, and repeat until it passes or stops making progress.Migrate many files in parallel
Discover the files to migrate, transform each one in an isolated copy so edits don’t conflict, and verify each result.Review every changed file and write one summary
Run a reviewer per file, then hand all the findings to one agent that ranks and deduplicates them.Research a topic across many sources
Fan out readers across changelogs, issues, and docs, then synthesize. The bundled/deep-research workflow does this; you can also describe a narrower version.
Find issues until the list stops growing
Keep searching in rounds and stop when new rounds turn up nothing new.What the saved script looks like
When you save a workflow, the file in.claude/workflows/ holds a meta block followed by a script body that orchestrates subagents. You usually don’t need to edit it, but here is the shape of a small one so you can recognize what Claude generated:
await. agent() spawns one subagent and pipeline() runs one per item in a list. If you want to edit a script by hand, ask Claude to walk you through the change, or see the Workflow tool entry in the Agent SDK reference for the full set of options.
How a workflow runs
The workflow runtime executes the script in an isolated environment, separate from your conversation. Intermediate results stay in script variables instead of landing in Claude’s context. Every run writes its script to a file under your session’s directory in~/.claude/projects/. Claude receives the path when the run starts, so you can ask for it. You can open that file to read the orchestration Claude wrote, diff it against a previous run’s script, or edit it and ask Claude to relaunch from the edited version.
The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session.
Behavior and limits
The runtime applies the following constraints:Manage runs
Once a run starts, you manage it from the/workflows view, or by expanding its progress line in the task panel below the input box.
Resume after a pause
If you stop a run, you can resume it: agents that already completed return their cached results, and the rest run live. An agent that was still running when you stopped isn’t saved and starts over on resume, so a workflow that fans work out across many small agents preserves more progress than one long agent. Resume a paused run from/workflows by selecting it and pressing p, or ask Claude to relaunch the workflow with the same script.
Resume works within the same Claude Code session. If you exit Claude Code while a workflow is running, the next session starts the workflow fresh.
Cost
A workflow spawns many agents, so a single run can use meaningfully more tokens than working through the same task in conversation. Runs count toward your plan’s usage and rate limits like any other session. To gauge the spend before committing to a large task, run the workflow on a small slice first: one directory instead of the whole repo, or a narrow question instead of a broad one. The/workflows view shows each agent’s token usage as the run progresses, and you can stop the run there at any time without losing completed work. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep every run smaller by default, set a size guideline in /config.
Claude Code also flags a run that grows unusually large. When a workflow schedules more than 25 agents, or its projected token total passes 1.5 million, its progress line in the task panel below the input box shows a Large workflow warning. The warning points you to /workflows, where you can stop the run. Requires Claude Code v2.1.203 or later.
The warning is advisory: it doesn’t pause or limit the run. Two settings change when you see it:
- If you set a size guideline, the guideline’s agent count replaces the 25-agent threshold.
- Sessions with ultracode on don’t show the warning, because turning ultracode on already opts you in to large runs.
CLAUDE_CODE_SUBAGENT_MODEL environment variable is set, which overrides both. To control the model cost:
- Check
/modelbefore a large run if you usually switch to a smaller model for routine work - Ask Claude to use a smaller model for stages that don’t need the strongest one when you describe the task
Set a size guideline
The Dynamic workflow size setting in/config keeps the workflows Claude writes to a smaller scale by default. Claude Code sends the setting to Claude as advice, so a prompt that calls for a different scale still overrides it. Requires Claude Code v2.1.202 or later.
Each value sets the agent count Claude aims for in the scripts it writes.
Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting.
Turn workflows off
Workflows are available in the CLI, the Desktop app, the IDE extensions, non-interactive mode withclaude -p, and the Agent SDK. The same disable settings apply on every surface.
To turn workflows off for yourself:
- Toggle Dynamic workflows off in
/config. Persists across sessions. - Set
"disableWorkflows": truein~/.claude/settings.json. Persists across sessions. - Set
CLAUDE_CODE_DISABLE_WORKFLOWS=1. Read at startup, so it applies wherever you set it.
"disableWorkflows": true in managed settings, or use the toggle on the Claude Code admin settings page.
When workflows are disabled, the bundled workflow commands are unavailable, the ultracode keyword no longer triggers a run, and ultracode is removed from the /effort menu.
Related resources
- Run agents in parallel: compare subagents, agent view, agent teams, and workflows
- Create custom subagents: the worker primitive workflows orchestrate
- Manage costs: how multi-agent runs count toward usage limits