A dynamic workflow is a JavaScript script that orchestrates many Claude Code subagents. Claude can write the script for the task you describe, and Claude Code runs it in the background while your main session remains responsive.
Workflows are especially useful for large audits, migrations, cross-checked research, and other tasks that are too large for one conversation to coordinate comfortably.
The official documentation positions workflows for tasks where the orchestration itself benefits from being represented as code and rerun.
| Feature | Who decides what runs next? | Best mental model | Scale |
|---|---|---|---|
| Subagents | Claude, turn by turn | Delegated worker | A few tasks per turn |
| Skills | Claude following instructions | Reusable instructions | Similar to subagents |
| Agent Teams | Lead agent | Peer sessions + shared tasks | Handful of long-running peers |
| Workflows | The script | Executable orchestration | Dozens to hundreds of agents |
Dynamic workflows are available on paid plans with Anthropic API access, and on Amazon Bedrock, Google Cloud's Agent Platform, and Microsoft Foundry. On Pro, the feature is enabled from the Dynamic workflows row in /config.
claude --version when a feature behaves differently.Claude Code includes /deep-research as a bundled workflow for investigating questions across many sources.
/deep-research What changed in the Node.js permission model between v20 and v22?
The workflow can fan out research across several angles, fetch and cross-check sources, and synthesize a cited report.
/deep-research with your question./workflows to watch progress./deep-research runs only when you invoke it. Saved workflows become commands in the same style.Workflows run in the background, so your main session stays responsive.
/workflows
The progress view shows phases, agent counts, token totals, elapsed time, and individual agent results.
| Key | Action |
|---|---|
↑ / ↓ | Select a phase or agent |
Enter / → | Drill into a phase or agent |
Esc / ← | Go back |
j / k | Scroll agent details |
f | Filter agents by status |
p | Pause or resume |
x | Stop an agent or the whole workflow |
r | Restart a selected running agent |
s | Save the run's script as a command |
You can explicitly ask Claude to use a workflow. The current documentation also supports the keyword ultracode.
ultracode: audit every API endpoint under src/routes/ for missing auth checks
You can also simply say:
Use a workflow to audit every API endpoint under src/routes/ for missing auth checks.
Claude writes the workflow script for the task rather than solving the entire task turn-by-turn.
The keyword is an opt-in trigger when it comes from human-entered input in supported interactive surfaces.
| Input source | Does the keyword trigger a workflow? |
|---|---|
| Interactive prompt | Yes |
| IDE extension panel | Yes |
| Remote Control client | Yes |
| Agent SDK with human-origin input | Yes |
-p prompt | No |
| Scheduled task prompt | No |
| Webhook / PR comment relayed into conversation | No |
The current documentation notes that before v2.1.210 the keyword could trigger from these other routes too.
If you did not mean to start a workflow, the current docs provide keyboard shortcuts to dismiss the highlight:
Option+WAlt+WYou can also turn off the Ultracode keyword trigger from /config.
ultracode can also be an effort level. It combines xhigh reasoning effort with automatic workflow orchestration.
/effort ultracode
Or start a session with:
claude --effort ultracode
With ultracode enabled, Claude decides when a substantive task warrants a workflow. A single request can produce several workflows, such as one for understanding the code, another for making the change, and another for verification.
/effort high for routine work.In the CLI, the workflow approval prompt can offer:
Ctrl+G opens the script in your editor, and Tab lets you adjust the prompt before the run starts.
| Mode | Typical workflow approval behavior |
|---|---|
| Auto | First launch only; later approval can be remembered. Ultracode skips this prompt. |
| Manual / accept edits | Prompt on each run unless remembered for the workflow/project. |
| Bypass permissions | No interactive prompt. |
claude -p / Agent SDK | No interactive approval prompt; normal permission evaluation applies. |
For claude -p and Agent SDK usage, Claude Code does not display the interactive workflow approval dialog. The workflow tool call is evaluated through the same permission system used for other tool calls.
Possible ways to allow a workflow include permission rules such as:
Workflow
or a named saved workflow:
Workflow(workflow-name)
Other supported mechanisms include Auto permission mode, Bypass permissions mode, a PreToolUse hook, or host-side permission callbacks/tools.
If a workflow performs a task you will repeat, save its generated script as a command.
/workflows
Select the run and press s.
| Location | Scope |
|---|---|
.claude/workflows/ | Project workflow shared with people who clone the repository |
~/.claude/workflows/ | Personal workflow available across projects |
After saving, the workflow runs as a slash command:
/workflow-name
.claude/workflows/ directory along the path according to the current documentation.For distribution across teams or repositories, a workflow can be included in a Claude Code plugin.
plugin-root/
└── workflows/
└── release-audit.js
Plugin workflows are namespaced by the plugin name. For example, a plugin named acme-tools with a workflow named release-audit can be invoked as:
/acme-tools:release-audit
Saved workflows can accept input through the args parameter. This lets you reuse one orchestration script with different data.
Run /triage-issues on issues 1024, 1025, and 1030
The workflow can access the supplied structured value through the global args.
A saved workflow contains a meta block followed by a JavaScript script body.
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: {
type: 'object',
required: ['files'],
properties: {
files: {
type: 'array',
items: { type: 'string' }
}
}
},
})
const audits = await pipeline(
found.files,
file => agent(`Audit ${file} for missing authentication checks.`, {
label: file,
})
)
return audits.filter(Boolean)
| Function | Purpose |
|---|---|
agent() | Spawns one subagent task. |
pipeline() | Runs one agent task per item in a list. |
parallel() | Runs a set of agent tasks at the same time and waits for them. |
phase() | Groups following agents under a title in the progress view. |
log() | Shows a message above the workflow phases. |
args | Reads structured input passed to the saved workflow. |
export const meta should be the first statement.meta block should be a plain object literal with name and description.await.import().phase(), log(), and args can be used in the body.Date.now(), Math.random(), and no-argument new Date() are blocked inside the script.The workflow runtime executes the script in an isolated environment separate from your conversation.
Intermediate results stay in script variables rather than filling Claude's main context. Each run's script is stored under the session's project directory in ~/.claude/projects/.
Agents in the same workflow run can share prompt-cache prefixes when they use the same model, effort level, agent type, tools, output schema, and working directory.
The current runtime normally keeps a workflow agent's cache for five minutes. The subagentPromptCacheTtl setting can extend this to 1h. One-hour cache writes are billed at a higher rate.
| Limit / rule | Meaning |
|---|---|
| No mid-run user input | Only agent permission prompts can pause a run. For sign-off between stages, separate stages into workflows. |
| No direct filesystem/shell access from workflow itself | Agents perform file and shell work; the script coordinates them. |
| No module loading | import() in the script causes the run to fail before starting. |
| Up to 16 concurrent agents | Actual concurrency can be lower when fewer CPUs are available. |
Up to 4,096 items in one parallel() or pipeline() | Larger lists are rejected. |
| 1,000 agents total per run | Protects against runaway workflows. |
Paused workflows can be resumed from /workflows by selecting the run and pressing p.
For a stopped run, Claude can relaunch the workflow using the same script. Completed agents can return saved results, while failed or still-running work may be rerun according to the documented replay rules.
Workflow results are kept under the session's project directory. A resumed Claude Code session can replay those results when asked to relaunch the workflow.
A workflow can spawn many agents, so it may use substantially more tokens than solving the same task directly in one conversation.
/workflows view shows token usage as the run progresses.By default, Claude Code shows a Large workflow warning when a workflow schedules more than 25 agents or its projected token total exceeds 1.5 million.
The warning is advisory: it does not automatically pause or limit the run.
A size guideline tells Claude how many agents to aim for when it writes a dynamic workflow.
| Setting | Agent count Claude aims for |
|---|---|
unrestricted | No size guideline |
small | Fewer than 5 agents |
medium | Fewer than 15 agents |
large | Fewer than 50 agents |
The current default is medium on versions that support the size guideline.
/config workflowSizeGuideline=small
Claude Code selects each workflow agent's model using the same general ordering used for subagents. A model specified for a stage has priority at that invocation. Otherwise the session's model can be used.
For large runs:
/model before starting.You have hundreds of route handlers and want to find missing authentication checks.
Use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it.
Workflows can express repeated loops.
Use a workflow to run npx tsc --noEmit and keep fixing the reported errors until the type check passes or two rounds in a row make no progress.
The workflow can therefore encode:
Use a workflow to migrate every component under src/components/ from JavaScript to TypeScript, working on each file in its own isolated copy.
This pattern is useful because many files can be transformed independently while verification can happen after the transformations.
Use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary.
The workflow can use one reviewer per file and then a final agent to rank and deduplicate the results.
Use a workflow to research how our three competitors handle rate limiting: read their public docs and recent changelog entries in parallel, then compare the approaches.
This is the same general pattern behind the bundled deep-research workflow: fan out research, collect evidence, cross-check, and synthesize.
Use a workflow to find flaky tests in this repo: run the suite repeatedly, record which tests fail intermittently, and stop once two rounds in a row find nothing new.
This demonstrates that workflows are not limited to simple one-pass parallelism. They can encode stopping conditions and repeated rounds.
| Mistake | Better approach |
|---|---|
| Using a workflow for a tiny change | Use the normal conversation or a single subagent. |
| Spawning many agents without independent work | Split the task only where parallelism helps. |
| Ignoring token cost | Run a small slice first and inspect usage. |
| Expecting mid-run user approval between every stage | Use separate workflows when human sign-off must occur between stages. |
| Putting filesystem logic directly in the script | Have agents perform file/shell operations; keep the script focused on orchestration. |
| Editing a saved workflow without understanding its structure | Use the bundled /workflow-authoring skill when supported. |
The current documentation recommends using the bundled /workflow-authoring skill before editing a saved workflow. That skill requires Claude Code v2.1.248 or later.
/workflow-authoring
After editing, use:
/reload-skills
to reload workflow directories before running the workflow again in the current session.
ultracode./workflows to watch progress.args to make reusable workflows configurable./workflows do?/deep-research?ultracode keyword do?/effort ultracode is enabled?args?agent(), pipeline(), and parallel()?/deep-research on a technical question and inspect its phases through /workflows.
args.
Dynamic workflows are Claude Code's way to turn complex multi-agent orchestration into executable, repeatable code. They are most valuable when the task is large, repetitive, parallelizable, or benefits from independent verification.