modified
--- a/workflows.md +++ b/workflows.md @@ -355,7 +355,7 @@ * Check `/model` before 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 -When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#when-an-allowlist-blocks-a-subagent-model>). +When an [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#when-an-allowlist-blocks-a-subagent-model>). ### Set a size guideline
modified
--- a/workflows.md +++ b/workflows.md @@ -100,7 +100,14 @@ #### Dismiss or turn off the keyword -If you didn’t mean to start a workflow, press `Option+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`. +To use the word `ultracode` without asking for a workflow, skip the keyword for one prompt or turn the keyword off for every prompt: + + * **One prompt, as you type** : put the word in backticks. For example, this prompt is a regular request to search your files: + + find every file that mentions `ultracode` + + * **One prompt, already highlighted in your terminal** : press Backspace right after the word, or press `Alt+W`. On macOS, that key is `Option+W` with [Option as Meta](</docs/en/terminal-config#enable-option-key-shortcuts-on-macos>). + * **Every prompt** : turn off [**Ultracode keyword trigger**](</docs/en/settings-reference#workflowkeywordtriggerenabled>) in `/config`. #### Where the keyword works @@ -177,7 +184,7 @@ Run /triage-issues on issues 1024, 1025, and 1030 -Claude passes the list as structured data, so the script can call array and object methods on `args` directly without parsing it first. If `args` is omitted, the global is `undefined` inside the script. +Claude passes the list as structured data, so the script can call array and object methods on `args` directly. If `args` is omitted, the global is `undefined` inside the script. ## Example workflow prompts @@ -221,7 +228,7 @@ ### 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: +When you save a workflow, the file in `.claude/workflows/` holds a `meta` block followed by a script body that orchestrates subagents. Here is the shape of a small one so you can recognize what Claude generated: export const meta = { name: 'audit-routes',
modified
--- a/workflows.md +++ b/workflows.md @@ -143,7 +143,7 @@ Bypass permissions| Claude Code doesn’t prompt you. The run starts immediately `claude -p`, Agent SDK| Claude Code doesn’t prompt you -In `claude -p` and the Agent SDK, Claude Code never shows this prompt. It runs the Workflow tool call through the same [permission evaluation](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) as the rest of the session, so deny rules, ask rules, and `dontAsk` mode apply to the launch as they apply to every tool call. To let the workflow start in these runs, use one of these: +In `claude -p` and the Agent SDK, the Workflow tool call goes through the same [permission evaluation](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) as the rest of the session. Deny rules, ask rules, and `dontAsk` mode apply to the call. To let the workflow start in these runs, use one of these: * **Permission rule** : add `Workflow` to your allow rules to approve every workflow, or `Workflow(<name>)` to approve one saved workflow by name. * **Auto permission mode** : run in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), where the classifier reviews the call and can approve it. @@ -373,7 +373,7 @@ To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled: - * `/workflows`, the workflow commands, and the `/workflow-authoring` skill are unavailable + * The `/workflows` progress view, the workflow commands, and the `/workflow-authoring` skill are unavailable * The `ultracode` keyword no longer triggers a run, and the **Ultracode** toggle is removed from `/effort` A run that was already in progress keeps going. Turning workflows off also makes ultracode unavailable. No managed setting rules out ultracode alone: wherever it’s [available](</docs/en/model-config#when-ultracode-is-available>), users can turn it on with `/effort ultracode`. An [effort cap](</docs/en/model-config#organization-effort-limits>) lowers the effort level a session with ultracode on runs at, but doesn’t turn ultracode off.
modified
--- a/workflows.md +++ b/workflows.md @@ -348,7 +348,7 @@ * Check `/model` before 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 -When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#choose-a-model>). +When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#when-an-allowlist-blocks-a-subagent-model>). ### Set a size guideline
modified
Show diff (421 lines)
--- a/workflows.md +++ b/workflows.md @@ -2,11 +2,7 @@ A dynamic workflow is a JavaScript script that orchestrates many [subagents](</docs/en/sub-agents>) at once. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. -## - -​ - -When to use a workflow +## When to use a workflow [Subagents](</docs/en/sub-agents>), [skills](</docs/en/skills>), [agent teams](</docs/en/agent-teams>), and workflows can all run a multi-step task. The difference is who holds the plan: @@ -21,11 +17,7 @@ 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 goes into 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 +## 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. @@ -61,11 +53,7 @@ To run a workflow for your own task, have Claude write one, and once a run does what you wanted you can save it as a command of your own. -### - -​ - -Bundled workflows +### Bundled workflows Claude Code includes `/deep-research` as a built-in workflow: @@ -73,13 +61,9 @@ ---|--- `/deep-research <question>`| 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 didn’t survive cross-checking filtered out. Requires the [WebSearch tool](</docs/en/tools-reference#websearch-tool-behavior>) to be available -`/deep-research` runs only when you invoke it. Workflows you save yourself become commands the same way and appear in `/` autocomplete alongside the bundled ones. - -### - -​ - -Watch the run +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. When the session has only one run, `/workflows` skips the list and opens that run. To stop a running workflow from the list without opening it, select it and press `x`. The progress view shows each phase with its agent counts. The footer lists the key for each action: @@ -97,11 +81,7 @@ The agent detail lists the agent’s prompt, its recent tool calls, and its result. Each call shows its state, such as still running or failed. When the agent keeps a task list of its own, the detail shows it too, with each task’s status. Press `Enter` to expand the detail. The prompt and result then show in full, and each listed call shows its input and the start of its result. -## - -​ - -Have Claude write a workflow +## Have Claude write a workflow You can have Claude write a workflow for your task in two ways: @@ -110,11 +90,7 @@ You can also run a workflow command that already exists: a bundled workflow like `/deep-research`, or one you’ve saved. -### - -​ - -Ask for a workflow in your prompt +### Ask for a workflow in your prompt To run a single task as a workflow without changing the session’s effort level, include the keyword `ultracode` 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. @@ -122,19 +98,11 @@ Claude Code highlights the keyword in your input and Claude writes a workflow script for the task instead of working through it turn by turn. The keyword only chooses how Claude structures the work: the agents’ tool calls receive the same permission checks and [sandboxing](</docs/en/sandboxing>) as any other tool call in the session. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. -#### - -​ - -Dismiss or turn off the keyword +#### Dismiss or turn off the keyword If you didn’t mean to start a workflow, press `Option+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 +#### 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](</docs/en/remote-control>) client, or in an Agent SDK application that stamps your keyboard input’s [`origin`](</docs/en/agent-sdk/typescript#sdkmessageorigin>) as `{ kind: "human" }`. It doesn’t start a workflow when it reaches the session another way: @@ -143,11 +111,7 @@ * a scheduled task prompt * a webhook payload or pull request comment relayed into the conversation -### - -​ - -Let Claude decide with ultracode +### Let Claude decide with ultracode Ultracode is a Claude Code setting that turns on automatic workflow orchestration for the session, at whichever [effort level](</docs/en/model-config#adjust-effort-level>) the session runs at. With it on, Claude plans a workflow for each substantive task instead of waiting for you to ask. Turn it on at the Claude Code prompt: @@ -161,11 +125,7 @@ `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Turn it off with `/effort ultracode off` when you return to routine work. The `/effort` slider offers the toggle only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). Before v2.1.284, `/effort ultracode` set the session to `xhigh`, and `/effort ultracode off` failed with `Invalid argument`. -### - -​ - -Approve the plan before it runs +### Approve the plan before it runs In the CLI, the per-run prompt shows the planned phases and these options: @@ -193,11 +153,7 @@ 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. The subagents the workflow spawns use your [permission rules](</docs/en/settings-reference#permission-settings>), and Claude Code picks their permission mode by the rules under [which permission mode a subagent runs in](</docs/en/sub-agents#permission-modes>). To avoid prompts on a long run, add the tools the agents need to your allow rules before starting. -### - -​ - -Save the workflow for reuse +### 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: @@ -211,19 +167,11 @@ In a monorepo with several `.claude/` directories, you can keep workflows alongside the package they apply to. 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. -### - -​ - -Distribute a workflow in a plugin +### Distribute a workflow in a plugin To share a workflow across teams or repositories, include it in a [plugin](</docs/en/plugins/overview>). Place the script in a `workflows/` directory at the plugin root, or point to a different location with the [`workflows` manifest field](</docs/en/plugins/manifest-reference#fields>). Plugin workflows are namespaced by the plugin name. A plugin called `acme-tools` containing a script whose `meta.name` is `release-audit` runs as `/acme-tools:release-audit`. -### - -​ - -Pass input to a saved workflow +### Pass input to a saved workflow A saved workflow can accept input through the `args` 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: @@ -231,79 +179,47 @@ Claude passes the list as structured data, so the script can call array and object methods on `args` directly without parsing it first. If `args` is omitted, the global is `undefined` inside the script. -## - -​ - -Example workflow prompts +## 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 +### Audit many files for the same issue Fan out one agent per file, then collect and verify the findings. use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it -### - -​ - -Keep fixing until a check passes +### Keep fixing until a check passes Run a checker, fix what failed, and repeat until it passes or stops making progress. 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 -### - -​ - -Migrate many files in parallel +### 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. use a workflow to migrate every component under src/components/ from JavaScript to TypeScript, working on each file in its own isolated copy -### - -​ - -Review every changed file and write one summary +### Review every changed file and write one summary Run a reviewer per file, then pass all the findings to one agent that ranks and deduplicates them. use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary -### - -​ - -Research a topic across many sources +### 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. 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 -### - -​ - -Find issues until the list stops growing +### Find issues until the list stops growing Keep searching in rounds and stop when new rounds turn up nothing new. 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 -### - -​ - -What the saved script looks like +### 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: @@ -324,11 +240,7 @@ The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps each `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries, including the slot of an agent that stalled on every attempt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the prompt your script passes to `agent()` doesn’t count as a request from you when the classifier reviews that subagent’s actions, because Claude Code marks it as text the script computed. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). -### - -​ - -Edit a saved script +### Edit a saved script To change a workflow you saved, edit its `.js` file or ask Claude to make the change. Before you edit or ask, run the `/workflow-authoring` [bundled skill](</docs/en/skills#bundled-skills>) to load the script-writing reference Claude works from. The skill requires Claude Code v2.1.248 or later. To run the edited version in the current session, run [`/reload-skills`](</docs/en/commands#all-commands>) to re-read the workflow directories, then run `/<name>` again. Claude Code applies these rules to each part of the file when it loads and runs the script: @@ -339,27 +251,15 @@ You can also edit the script of a single run rather than the saved copy. Resume after a pause covers which agents run again when you relaunch an edited script. For the Workflow tool’s inputs, see its entry in the [Agent SDK reference](</docs/en/agent-sdk/typescript#workflow>). -## - -​ - -How a workflow runs +## 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. Unless Claude starts a run from a script file’s path, Claude Code writes the run’s script to a file under your session’s directory in `~/.claude/projects/`. Claude receives the script’s 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. Claude can start a workflow only from a script file the session is already allowed to read. To run a script kept outside your working directory, add its directory with [`/add-dir`](</docs/en/permissions#working-directories>) or a [Read allow rule](</docs/en/permissions#read-and-edit>) first. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session. -### - -​ - -Prompt caching in a fan-out +### Prompt caching in a fan-out Agents in the same run can read each other’s [prompt cache](</docs/en/prompt-caching#subagents-and-the-cache>). Two agents that run with the same model, effort level, agent type, tools, output schema, and working directory build the same tools-and-system-prompt prefix, so an agent that starts after a matching sibling’s response has begun reads that sibling’s cache on its first request. A workflow agent’s requests fall outside the main conversation’s [cache TTL bucket](</docs/en/prompt-caching#which-ttl-each-request-gets>), so its cache holds for five minutes by default, including on a Claude subscription. To keep it for an hour, set [`subagentPromptCacheTtl`](</docs/en/settings-reference#subagentpromptcachettl>) to `1h`. The API bills 1-hour cache writes at a higher rate. When a fan-out starts several matching agents at once, Claude Code holds all but the first until the first agent’s response begins, then releases the held agents together so their first requests read the shared prefix instead of each processing it uncached. Claude Code caps the hold at [`CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS`](</docs/en/env-vars>) milliseconds, `5000` by default. Set it to `0` to disable the hold. -### - -​ - -Behavior and limits +### Behavior and limits The runtime applies the following constraints: @@ -373,27 +273,15 @@ Up to 4,096 items in a single `parallel()` or `pipeline()` call: the runtime rejects a longer list with an error| A silent cap would drop part of the workload without telling the script 1,000 agents total per run| Prevents runaway loops -## - -​ - -Manage runs +## 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. When you stop a run, it stays in the task panel while any of its agents’ processes are still running. If you stop it again, Claude Code re-signals those processes. -### - -​ - -Resume after a pause +### Resume after a pause Resume a paused run from `/workflows` by selecting it and pressing `p`. For a run you stopped, ask Claude to relaunch the workflow with the same script. If agents from the stopped run haven’t exited yet, Claude Code refuses the relaunch until they have, so a second copy of those agents can’t run alongside them. -#### - -​ - -Which agents run again +#### Which agents run again Claude Code replays the run in the order agents start, and each agent either returns its saved result or runs again: @@ -404,11 +292,7 @@ That last case means a **Failed** agent in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B is **Failed** , relaunching returns A from cache and runs B, C, and D again. If you edit a script that started A, B, C, and D so that it starts A, C, B, and D, the second agent to start is now C, where the previous run started B. Relaunching returns A from cache and runs C, B, and D again. -#### - -​ - -Resume after you leave the session +#### Resume after you leave the session If you background your session or exit Claude Code while a workflow run is in progress, the run doesn’t continue on its own. The run continues only when Claude relaunches it with a `Workflow` call, which replays the run from its saved results. @@ -418,11 +302,7 @@ In a [cloud session](</docs/en/claude-code-on-the-web>), Claude Code also saves the run’s results with the session’s conversation history, which survives when the session’s VM is reclaimed. When you [reopen such a session](</docs/en/claude-code-on-the-web#environment-expired>) and ask Claude to relaunch the workflow, completed agents still return their saved results. In local and cloud sessions alike, when Claude relaunches an earlier run and Claude Code can’t find that run’s saved results at all, the relaunch fails with a `nothing to resume` error instead of starting the run over on its own. Ask Claude to start the workflow over as a new run. -### - -​ - -When a run hits your usage limit +### When a run hits your usage limit When an agent hits your claude.ai [usage limit](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>), the run pauses rather than failing that agent. The agents that hit the limit wait for the reset, and no new agents start. Shortly after the limit resets, the waiting agents run again and the run continues on its own. Requires Claude Code v2.1.271 or later, or [v2.1.319 or later](</docs/en/desktop#claude-code-version-in-the-code-tab>) in the Desktop [Code tab](</docs/en/desktop>). On earlier versions, the affected agents fail. While the run waits, its progress line in the task panel and the `/workflows` header show when the limit resets. In the Code tab, the run shows a line such as `Paused at usage limit · continues after 3:45 PM if the app stays open`. Keep the app open. The run pauses only when all of these hold; when one doesn’t, the affected agent fails instead: @@ -436,11 +316,7 @@ To finish a run whose agents failed at the limit, ask Claude to relaunch the workflow after the limit resets. -### - -​ - -When an agent stalls and restarts +### When an agent stalls and restarts An agent whose output stops arriving for long enough starts over from the same prompt. In `/workflows`, its name gains a `(retry 1)` suffix and its detail shows `attempt 2 (stalled)`. The restart is automatic, so you don’t need to do anything. The new attempt starts without the stalled attempt’s transcript. Files the stalled attempt already changed stay changed, and the tokens it spent stay in the run’s total. The stall window is how long Claude Code waits for output from an agent before it ends the attempt. Time the agent spends waiting on its own tool calls or on a usage-limit reset doesn’t count toward the stall window. An agent restarts at most five times, counting any restart you ask for with `r`. If the sixth attempt stalls as well, the `agent()` call fails, and the start of the error says why: @@ -460,11 +336,7 @@ To try again, ask Claude to relaunch the workflow. Resume after a pause covers what runs again. -### - -​ - -Cost +### 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. 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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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. The warning is advisory: it doesn’t pause or limit the run. Two settings change when you see it: @@ -478,11 +350,7 @@ When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#choose-a-model>). -### - -​ - -Set a size guideline +### Set a size guideline A size guideline tells Claude how many agents to aim for when it writes a dynamic workflow. Claude Code sends the guideline to Claude as advice, not a cap, so a prompt that calls for a different scale still overrides it. Each value maps to an agent count: @@ -495,11 +363,7 @@ The default is `medium`, or `small` when you’re signed in on a Pro plan with Claude Code v2.1.271 or later. Until you choose a value, the `/config` row marks the value as the default, and the workflow’s `Running in background` line names the size in force. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. You can also set the [`workflowSizeGuideline` key](</docs/en/settings-reference#workflowsizeguideline>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. -### - -​ - -Turn workflows off +### Turn workflows off Workflows are available in the CLI, the Desktop app, the IDE extensions, [non-interactive mode](</docs/en/headless>) with `claude -p`, and the [Agent SDK](</docs/en/agent-sdk/overview>). The same disable settings apply on every surface. To turn workflows off for yourself: @@ -514,11 +378,7 @@ A run that was already in progress keeps going. Turning workflows off also makes ultracode unavailable. No managed setting rules out ultracode alone: wherever it’s [available](</docs/en/model-config#when-ultracode-is-available>), users can turn it on with `/effort ultracode`. An [effort cap](</docs/en/model-config#organization-effort-limits>) lowers the effort level a session with ultracode on runs at, but doesn’t turn ultracode off. -## - -​ - -Related resources +## Related resources * [Run agents in parallel](</docs/en/agents>): compare subagents, agent view, agent teams, and workflows * [Create custom subagents](</docs/en/sub-agents>): the worker primitive workflows orchestrate
modified
--- a/workflows.md +++ b/workflows.md @@ -399,9 +399,10 @@ * **Completed** : returns its saved result. The first agent whose prompt differs from the previous run, because you edited the script or an earlier agent returned something different, runs again, and so does every agent after it, even ones that completed. Before v2.1.305, completed agents could also run again when you relaunched an unedited script whose `pipeline()` items or `parallel()` tasks ran more than one agent each. To stop those reruns for new runs, update Claude Code. * **Still running when you stopped** : starts over. Stopping the whole run doesn’t count any agent as failed. + * **Failed at a usage limit on v2.1.318 or later**: runs again, and agents that completed return their saved results. If your script called another agent after the failure and that agent returned a result, every agent the script starts after the failed one also runs again. * **Failed** : runs again, and so does every agent the script starts after it, even ones that completed. Stopping one agent alone, by selecting it in `/workflows` and pressing `x`, counts as failing. -That last case means a failure in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B fails, relaunching returns A from cache and runs B, C, and D again. If you edit a script that started A, B, C, and D so that it starts A, C, B, and D, the second agent to start is now C, where the previous run started B. Relaunching returns A from cache and runs C, B, and D again. +That last case means a **Failed** agent in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B is **Failed** , relaunching returns A from cache and runs B, C, and D again. If you edit a script that started A, B, C, and D so that it starts A, C, B, and D, the second agent to start is now C, where the previous run started B. Relaunching returns A from cache and runs C, B, and D again. #### @@ -423,12 +424,17 @@ When a run hits your usage limit -When an agent hits your claude.ai [usage limit](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>), the run pauses rather than failing that agent: the agents that hit the limit wait for the reset, and no new agents start. Shortly after the limit resets, the waiting agents run again and the run continues on its own. Requires Claude Code v2.1.271 or later; on earlier versions, the affected agents fail. While the run waits, its progress line in the task panel and the `/workflows` header show when the limit resets. The run pauses only when all of these hold; when one doesn’t, the affected agent fails instead: - - * The session is interactive and signed in with a claude.ai subscription. A run doesn’t pause in [non-interactive mode](</docs/en/headless>) with `claude -p` or the [Agent SDK](</docs/en/agent-sdk/overview>), in a [background session](</docs/en/agent-view>), or in a [Remote Control](</docs/en/remote-control>) or [agent team](</docs/en/agent-teams>) teammate session. +When an agent hits your claude.ai [usage limit](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>), the run pauses rather than failing that agent. The agents that hit the limit wait for the reset, and no new agents start. Shortly after the limit resets, the waiting agents run again and the run continues on its own. Requires Claude Code v2.1.271 or later, or [v2.1.319 or later](</docs/en/desktop#claude-code-version-in-the-code-tab>) in the Desktop [Code tab](</docs/en/desktop>). On earlier versions, the affected agents fail. While the run waits, its progress line in the task panel and the `/workflows` header show when the limit resets. In the Code tab, the run shows a line such as `Paused at usage limit · continues after 3:45 PM if the app stays open`. Keep the app open. The run pauses only when all of these hold; when one doesn’t, the affected agent fails instead: + + * The session is signed in with a claude.ai subscription without [usage-based billing](</docs/en/interactive-mode#start-a-wait-yourself>), and is one of these session types: + * An interactive terminal session. A run doesn’t pause in [non-interactive mode](</docs/en/headless>) with `claude -p` or the [Agent SDK](</docs/en/agent-sdk/overview>), in a [background session](</docs/en/agent-view>), or in a [Remote Control](</docs/en/remote-control>) or [agent team](</docs/en/agent-teams>) teammate session. + * A local session you started in the Code tab. A run doesn’t pause in an SSH, WSL, [Dispatch](</docs/en/desktop#sessions-from-dispatch>), or [scheduled task](</docs/en/desktop-scheduled-tasks>) session, in one started from Remote Control or through a [corporate launcher](</docs/en/corporate-launcher>), or while [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](</docs/en/env-vars#variables>) is set. * [`autoContinueAtUsageLimit`](</docs/en/settings-reference#autocontinueatusagelimit>) is on, the same setting that lets the session itself [wait for a usage limit to reset](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>). If you turn it off during a wait, the wait ends and the waiting agents fail. + * In the Code tab, the **Auto-continue when limits reset** checkbox on a [session-limit card](</docs/en/errors#youve-hit-your-session-limit>) is checked, as it is by default. If you uncheck it, runs in your Code tab sessions stop pausing, unless managed settings set `autoContinueAtUsageLimit` to `true`. * The limit resets within 24 hours. A weekly limit can reset further out. * The run hasn’t already waited twice. When it hits the limit a third time, the agent fails. + +To finish a run whose agents failed at the limit, ask Claude to relaunch the workflow after the limit resets. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -204,12 +204,12 @@ * `.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 set [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>), this location is the `workflows/` directory under that path. -The save dialog shows the resolved path for the personal location. Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. Claude Code checks the save location for symlinks before writing, and shows an error instead of writing through one. What it checks depends on where you save: +The save dialog shows the resolved path for the personal location. Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. Claude Code checks the save location for symlinks before writing, and shows an error instead of writing through one: * Project location: Claude Code refuses if `.claude`, `.claude/workflows`, or the target file is a symlink. * Personal location: Claude Code refuses only if the target file itself is a symlink, so a `~/.claude` directory managed by a dotfiles tool still works. -Before v2.1.216, Claude Code followed the link, which could place the file outside the location you chose. In a monorepo with several `.claude/` directories, you can keep workflows alongside the package they apply to. 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. +In a monorepo with several `.claude/` directories, you can keep workflows alongside the package they apply to. 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. ### @@ -487,7 +487,7 @@ `medium`| Fewer than 10 agents `large`| Fewer than 50 agents -The default is `medium`, or `small` when you’re signed in on a Pro plan with Claude Code v2.1.271 or later. Until you choose a value, the `/config` row marks the value as the default, and the workflow’s `Running in background` line names the size in force. Requires Claude Code v2.1.219 or later; earlier versions default to `unrestricted`. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. On v2.1.219 and later, you can also set the [`workflowSizeGuideline` key](</docs/en/settings-reference#workflowsizeguideline>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. +The default is `medium`, or `small` when you’re signed in on a Pro plan with Claude Code v2.1.271 or later. Until you choose a value, the `/config` row marks the value as the default, and the workflow’s `Running in background` line names the size in force. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. You can also set the [`workflowSizeGuideline` key](</docs/en/settings-reference#workflowsizeguideline>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -159,7 +159,7 @@ * The session’s [concurrent subagent limit](</docs/en/sub-agents#concurrent-subagent-limit>) isn’t enforced for the subagents Claude spawns with the Agent tool * In auto permission mode, you aren’t asked to approve the first workflow launch -`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Turn it off with `/effort ultracode off` when you return to routine work. The `/effort` slider offers the toggle only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). +`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Turn it off with `/effort ultracode off` when you return to routine work. The `/effort` slider offers the toggle only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). Before v2.1.284, `/effort ultracode` set the session to `xhigh`, and `/effort ultracode off` failed with `Invalid argument`. ### @@ -345,7 +345,7 @@ 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. Claude can start a workflow only from a script file the session is already allowed to read. To run a script kept outside your working directory, add its directory with [`/add-dir`](</docs/en/permissions#working-directories>) or a [Read allow rule](</docs/en/permissions#read-and-edit>) first. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session. +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. Unless Claude starts a run from a script file’s path, Claude Code writes the run’s script to a file under your session’s directory in `~/.claude/projects/`. Claude receives the script’s 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. Claude can start a workflow only from a script file the session is already allowed to read. To run a script kept outside your working directory, add its directory with [`/add-dir`](</docs/en/permissions#working-directories>) or a [Read allow rule](</docs/en/permissions#read-and-edit>) first. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session. ### @@ -409,10 +409,11 @@ Resume after you leave the session -You can resume a run within the same Claude Code session. What happens to a running workflow when you leave the session depends on how you leave: - - * If you [background the session](</docs/en/agent-view#what-carries-over-when-you-background>), Claude Code replays the run the same way in the background session and continues it. - * If you exit Claude Code while a workflow is running and [agent view is on](</docs/en/agent-view#from-inside-a-session>), the exit dialog offers `Move to background and exit`, which carries the run over the same way. If you choose `Exit and stop tasks` instead, or the option isn’t offered, the run stops with the session. Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`, so a session you resume with `claude --resume` can replay them when you ask Claude to relaunch the workflow. In a session you start fresh, Claude has no earlier run to relaunch and starts the workflow over as a new run. +If you background your session or exit Claude Code while a workflow run is in progress, the run doesn’t continue on its own. The run continues only when Claude relaunches it with a `Workflow` call, which replays the run from its saved results. + + * **You backgrounded the session or chose[`Move to background and exit`](</docs/en/agent-view#from-inside-a-session>)**: if the run hasn’t continued when you check the [background session](</docs/en/agent-view#what-carries-over-when-you-background>), ask Claude there to relaunch the workflow. Depending on your permission mode, Claude Code asks you to approve the relaunch first. If the session shows under `Needs input` in agent view, [attach to it](</docs/en/agent-view#attach-to-a-session>) to answer the approval prompt. + * **The relaunch in the background session failed with`nothing to resume`**: ask Claude to start the workflow over as a new run. If Claude started the run from the path of a script file outside `~/.claude/projects/`, such as one in your working directory, Claude can’t relaunch it in the background session. + * **You chose`Exit and stop tasks`, or weren’t offered `Move to background and exit`**: the run stopped with the session, and Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`. Resume the session with `claude --resume` in your shell, then ask Claude to relaunch the workflow. In a fresh session, Claude has no earlier run to relaunch and starts the workflow over. In a [cloud session](</docs/en/claude-code-on-the-web>), Claude Code also saves the run’s results with the session’s conversation history, which survives when the session’s VM is reclaimed. When you [reopen such a session](</docs/en/claude-code-on-the-web#environment-expired>) and ask Claude to relaunch the workflow, completed agents still return their saved results. In local and cloud sessions alike, when Claude relaunches an earlier run and Claude Code can’t find that run’s saved results at all, the relaunch fails with a `nothing to resume` error instead of starting the run over on its own. Ask Claude to start the workflow over as a new run.
modified
--- a/workflows.md +++ b/workflows.md @@ -395,11 +395,11 @@ Which agents run again -Claude Code replays the run in the order agents started, and each agent either returns its saved result or runs again: - - * **Completed** : returns its saved result. The first agent whose prompt differs from the previous run, because you edited the script or an earlier agent returned something different, runs again, and so does every agent after it, even ones that completed. +Claude Code replays the run in the order agents start, and each agent either returns its saved result or runs again: + + * **Completed** : returns its saved result. The first agent whose prompt differs from the previous run, because you edited the script or an earlier agent returned something different, runs again, and so does every agent after it, even ones that completed. Before v2.1.305, completed agents could also run again when you relaunched an unedited script whose `pipeline()` items or `parallel()` tasks ran more than one agent each. To stop those reruns for new runs, update Claude Code. * **Still running when you stopped** : starts over. Stopping the whole run doesn’t count any agent as failed. - * **Failed** : runs again, and so does every agent that started after it, even ones that completed. Stopping one agent alone, by selecting it in `/workflows` and pressing `x`, counts as failing. + * **Failed** : runs again, and so does every agent the script starts after it, even ones that completed. Stopping one agent alone, by selecting it in `/workflows` and pressing `x`, counts as failing. That last case means a failure in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B fails, relaunching returns A from cache and runs B, C, and D again. If you edit a script that started A, B, C, and D so that it starts A, C, B, and D, the second agent to start is now C, where the previous run started B. Relaunching returns A from cache and runs C, B, and D again.
modified
--- a/workflows.md +++ b/workflows.md @@ -143,8 +143,6 @@ * 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. - ### ​
modified
--- a/workflows.md +++ b/workflows.md @@ -187,10 +187,10 @@ In `claude -p` and the Agent SDK, Claude Code never shows this prompt. It runs the Workflow tool call through the same [permission evaluation](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) as the rest of the session, so deny rules, ask rules, and `dontAsk` mode apply to the launch as they apply to every tool call. To let the workflow start in these runs, use one of these: - * **Permission rule** : `Workflow` in your allow rules approves every workflow, and `Workflow(<name>)` approves one saved workflow by name. - * **Auto permission mode** : the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) reviews the call and can approve it. - * **Bypass permissions mode** : Claude Code approves the call. - * **A hook** : a [`PreToolUse`](</docs/en/hooks#pretooluse>) hook that allows the call approves it. + * **Permission rule** : add `Workflow` to your allow rules to approve every workflow, or `Workflow(<name>)` to approve one saved workflow by name. + * **Auto permission mode** : run in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), where the classifier reviews the call and can approve it. + * **Bypass permissions mode** : run in bypass permissions mode. + * **A hook** : return `"allow"` for the call from a [`PreToolUse`](</docs/en/hooks#pretooluse>) hook. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the workflow doesn’t start on the hook’s approval alone, so use a permission rule or your host’s approval there instead. * **Your host** : a [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>) or, with the Agent SDK, a [`canUseTool`](</docs/en/agent-sdk/permissions>) callback approves it. 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. The subagents the workflow spawns use your [permission rules](</docs/en/settings-reference#permission-settings>), and Claude Code picks their permission mode by the rules under [which permission mode a subagent runs in](</docs/en/sub-agents#permission-modes>). To avoid prompts on a long run, add the tools the agents need to your allow rules before starting.
modified
--- a/workflows.md +++ b/workflows.md @@ -87,7 +87,7 @@ ---|--- `↑` / `↓`| Select a phase or agent `Enter` or `→`| Drill into the selected phase, then into an agent’s detail. In the detail, `Enter` expands or collapses it -`Esc` or `←`| Back out one level. In v2.1.203 through v2.1.205, `←` didn’t step back out of a phase or agent; use `Esc` on those versions +`Esc` or `←`| Back out one level `j` / `k`| Scroll within the agent detail when it overflows `f`| Filter the agent list in the selected phase by status. Press again to cycle `p`| Pause or resume the run @@ -155,7 +155,7 @@ /effort ultracode -To start a session with ultracode already on, launch with `claude --effort ultracode`, which also sets the effort level to `xhigh`. Requires Claude Code v2.1.203 or later. To turn it on from the `/effort` slider, press `Tab` to flip the **Ultracode** toggle, then `Enter` to apply it. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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 the same request without a workflow. On a subscription plan those tokens draw on your usage limits, so a session with ultracode on reaches a session or weekly limit sooner than the same work with it off. Turning ultracode on already opts you in to large runs, so these checks don’t apply while it’s on: +To start a session with ultracode already on, launch with `claude --effort ultracode`, which also sets the effort level to `xhigh`. To turn it on from the `/effort` slider, press `Tab` to flip the **Ultracode** toggle, then `Enter` to apply it. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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 the same request without a workflow. On a subscription plan those tokens draw on your usage limits, so a session with ultracode on reaches a session or weekly limit sooner than the same work with it off. Turning ultracode on already opts you in to large runs, so these checks don’t apply while it’s on: * The `Large workflow` warning doesn’t appear on a workflow run * The session’s [concurrent subagent limit](</docs/en/sub-agents#concurrent-subagent-limit>) isn’t enforced for the subagents Claude spawns with the Agent tool @@ -479,7 +479,7 @@ Set a size guideline -A size guideline tells Claude how many agents to aim for when it writes a dynamic workflow. Claude Code sends the guideline to Claude as advice, not a cap, so a prompt that calls for a different scale still overrides it. Requires Claude Code v2.1.202 or later. Each value maps to an agent count: +A size guideline tells Claude how many agents to aim for when it writes a dynamic workflow. Claude Code sends the guideline to Claude as advice, not a cap, so a prompt that calls for a different scale still overrides it. Each value maps to an agent count: Value| Agent count Claude aims for ---|---
modified
--- a/workflows.md +++ b/workflows.md @@ -389,13 +389,29 @@ Resume after a pause -Resume a paused run from `/workflows` by selecting it and pressing `p`. For a run you stopped, ask Claude to relaunch the workflow with the same script. If agents from the stopped run haven’t exited yet, Claude Code refuses the relaunch until they have, so a second copy of those agents can’t run alongside them. Claude Code replays the run in the order agents started, and each agent either returns its saved result or runs again: +Resume a paused run from `/workflows` by selecting it and pressing `p`. For a run you stopped, ask Claude to relaunch the workflow with the same script. If agents from the stopped run haven’t exited yet, Claude Code refuses the relaunch until they have, so a second copy of those agents can’t run alongside them. + +#### + +​ + +Which agents run again + +Claude Code replays the run in the order agents started, and each agent either returns its saved result or runs again: * **Completed** : returns its saved result. The first agent whose prompt differs from the previous run, because you edited the script or an earlier agent returned something different, runs again, and so does every agent after it, even ones that completed. * **Still running when you stopped** : starts over. Stopping the whole run doesn’t count any agent as failed. * **Failed** : runs again, and so does every agent that started after it, even ones that completed. Stopping one agent alone, by selecting it in `/workflows` and pressing `x`, counts as failing. -That last case means a failure in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B fails, relaunching returns A from cache and runs B, C, and D again. You can resume a run within the same Claude Code session. What happens to a running workflow when you leave the session depends on how you leave: +That last case means a failure in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B fails, relaunching returns A from cache and runs B, C, and D again. If you edit a script that started A, B, C, and D so that it starts A, C, B, and D, the second agent to start is now C, where the previous run started B. Relaunching returns A from cache and runs C, B, and D again. + +#### + +​ + +Resume after you leave the session + +You can resume a run within the same Claude Code session. What happens to a running workflow when you leave the session depends on how you leave: * If you [background the session](</docs/en/agent-view#what-carries-over-when-you-background>), Claude Code replays the run the same way in the background session and continues it. * If you exit Claude Code while a workflow is running and [agent view is on](</docs/en/agent-view#from-inside-a-session>), the exit dialog offers `Move to background and exit`, which carries the run over the same way. If you choose `Exit and stop tasks` instead, or the option isn’t offered, the run stops with the session. Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`, so a session you resume with `claude --resume` can replay them when you ask Claude to relaunch the workflow. In a session you start fresh, Claude has no earlier run to relaunch and starts the workflow over as a new run.
modified
--- a/workflows.md +++ b/workflows.md @@ -455,7 +455,7 @@ * Check `/model` before 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 -When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#choose-a-model>). The run’s progress view in `/workflows` shows a warning naming both the requested and substituted models. +When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#choose-a-model>). ###
modified
--- a/workflows.md +++ b/workflows.md @@ -324,7 +324,7 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps each `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the prompt your script passes to `agent()` doesn’t count as a request from you when the classifier reviews that subagent’s actions, because Claude Code marks it as text the script computed. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps each `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries, including the slot of an agent that stalled on every attempt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the prompt your script passes to `agent()` doesn’t count as a request from you when the classifier reviews that subagent’s actions, because Claude Code marks it as text the script computed. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). ### @@ -419,6 +419,30 @@ ​ +When an agent stalls and restarts + +An agent whose output stops arriving for long enough starts over from the same prompt. In `/workflows`, its name gains a `(retry 1)` suffix and its detail shows `attempt 2 (stalled)`. The restart is automatic, so you don’t need to do anything. The new attempt starts without the stalled attempt’s transcript. Files the stalled attempt already changed stay changed, and the tokens it spent stay in the run’s total. The stall window is how long Claude Code waits for output from an agent before it ends the attempt. Time the agent spends waiting on its own tool calls or on a usage-limit reset doesn’t count toward the stall window. An agent restarts at most five times, counting any restart you ask for with `r`. If the sixth attempt stalls as well, the `agent()` call fails, and the start of the error says why: + + * `agent stalled on all 6 attempts`: every attempt went the whole window without output. If the agent’s work keeps it silent that long, lengthen the window + * `agent lost its reply on all 6 attempts`: every attempt’s response stream went silent and Claude Code gave up waiting on it. Lengthening the stall window doesn’t help, since a [streaming idle watchdog](</docs/en/network-config#streaming-idle-watchdogs>) ended the response first and `CLAUDE_STREAM_IDLE_TIMEOUT_MS` sets that watchdog’s timeout + * `agent abandoned after 6 attempts`: the attempts ended in different ways, which the error lists in order + +To give an agent more time to produce output before the window ends: + + * **One agent** : pass `stallMs` in milliseconds on its `agent()` call, such as `agent(prompt, { stallMs: 1800000 })` for 30 minutes + * **Every agent** : set [`CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS`](</docs/en/env-vars#variables>), which also applies to subagents outside workflows + +Whether the run continues after the failure depends on how your script called the agent: + + * **Inside`parallel()` or `pipeline()`**: the run carries on with `null` in place of the agent’s result + * **Awaited directly** : the run ends with the error + +To try again, ask Claude to relaunch the workflow. Resume after a pause covers what runs again. + +### + +​ + 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. 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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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. The warning is advisory: it doesn’t pause or limit the run. Two settings change when you see it:
modified
--- a/workflows.md +++ b/workflows.md @@ -462,7 +462,12 @@ * Set `"disableWorkflows": true` in `~/.claude/settings.json`. Persists across sessions. * Set `CLAUDE_CODE_DISABLE_WORKFLOWS=1`. Read at startup, so it applies wherever you set it. -To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands and the `/workflow-authoring` skill are unavailable, the `ultracode` keyword no longer triggers a run, and the **Ultracode** toggle is removed from `/effort`. A run that was already in progress keeps going. Turning workflows off also makes ultracode unavailable. No managed setting rules out ultracode alone: wherever it’s [available](</docs/en/model-config#when-ultracode-is-available>), users can turn it on with `/effort ultracode`. An [effort cap](</docs/en/model-config#organization-effort-limits>) lowers the effort level a session with ultracode on runs at, but doesn’t turn ultracode off. +To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled: + + * `/workflows`, the workflow commands, and the `/workflow-authoring` skill are unavailable + * The `ultracode` keyword no longer triggers a run, and the **Ultracode** toggle is removed from `/effort` + +A run that was already in progress keeps going. Turning workflows off also makes ultracode unavailable. No managed setting rules out ultracode alone: wherever it’s [available](</docs/en/model-config#when-ultracode-is-available>), users can turn it on with `/effort ultracode`. An [effort cap](</docs/en/model-config#organization-effort-limits>) lowers the effort level a session with ultracode on runs at, but doesn’t turn ultracode off. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -47,11 +47,11 @@ Watch progress -The run starts in the background. Run `/workflows`, use the arrow keys to select the run, and press Enter to open its progress view: +The run starts in the background. Run `/workflows` to open its progress view: /workflows -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. +If `/workflows` shows a list of runs instead, select the run you just started and press Enter. The view shows each phase with its agent count. 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. 4 @@ -81,7 +81,7 @@ 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. To stop a running workflow without opening it, select it in the list and press `x`. The progress view shows each phase with its agent counts, token totals, and elapsed time. The footer lists the key for each action: +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. When the session has only one run, `/workflows` skips the list and opens that run. To stop a running workflow from the list without opening it, select it and press `x`. The progress view shows each phase with its agent counts. The footer lists the key for each action: Key| Action ---|--- @@ -176,7 +176,7 @@ * **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](</docs/en/permission-modes>): +`Ctrl+G` opens the script in your editor. With **Yes, run it** or **No** selected, press `Tab` to [add a comment](</docs/en/permissions#add-a-comment-when-you-answer-a-permission-prompt>) to your answer. Whether you see this prompt depends on your [permission mode](</docs/en/permission-modes>): Permission mode| When you’re prompted ---|---
modified
--- a/workflows.md +++ b/workflows.md @@ -190,8 +190,8 @@ * **Permission rule** : `Workflow` in your allow rules approves every workflow, and `Workflow(<name>)` approves one saved workflow by name. * **Auto permission mode** : the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) reviews the call and can approve it. * **Bypass permissions mode** : Claude Code approves the call. - * **A`PreToolUse` hook**: a [hook](</docs/en/hooks#pretooluse>) that returns `allow` for the call approves it. - * **Your host** : a [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>) approves it, or, with the Agent SDK, a [`canUseTool`](</docs/en/agent-sdk/permissions>) callback or a [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) approves it. + * **A hook** : a [`PreToolUse`](</docs/en/hooks#pretooluse>) hook that allows the call approves it. + * **Your host** : a [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>) or, with the Agent SDK, a [`canUseTool`](</docs/en/agent-sdk/permissions>) callback approves it. 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. The subagents the workflow spawns use your [permission rules](</docs/en/settings-reference#permission-settings>), and Claude Code picks their permission mode by the rules under [which permission mode a subagent runs in](</docs/en/sub-agents#permission-modes>). To avoid prompts on a long run, add the tools the agents need to your allow rules before starting.
modified
--- a/workflows.md +++ b/workflows.md @@ -81,7 +81,7 @@ 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. The progress view shows each phase with its agent counts, token totals, and elapsed time. The footer lists the key for each action: +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. To stop a running workflow without opening it, select it in the list and press `x`. The progress view shows each phase with its agent counts, token totals, and elapsed time. The footer lists the key for each action: Key| Action ---|---
modified
--- a/workflows.md +++ b/workflows.md @@ -151,17 +151,17 @@ Let Claude decide with ultracode -Ultracode is a Claude Code setting that combines `xhigh` [reasoning effort](</docs/en/model-config#adjust-effort-level>) with automatic workflow orchestration. With it on, Claude plans a workflow for each substantive task instead of waiting for you to ask. +Ultracode is a Claude Code setting that turns on automatic workflow orchestration for the session, at whichever [effort level](</docs/en/model-config#adjust-effort-level>) the session runs at. With it on, Claude plans a workflow for each substantive task instead of waiting for you to ask. Turn it on at the Claude Code prompt: /effort ultracode -To start a session with ultracode already on, launch with `claude --effort ultracode`. Requires Claude Code v2.1.203 or later. To turn it on while you choose a model, move the `/model` picker’s effort slider to `ultracode` with the arrow keys. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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. On a subscription plan those tokens draw on your usage limits, so a session with ultracode on reaches a session or weekly limit sooner than the same work at `high`. Turning ultracode on already opts you in to large runs, so these checks don’t apply while it’s on: +To start a session with ultracode already on, launch with `claude --effort ultracode`, which also sets the effort level to `xhigh`. Requires Claude Code v2.1.203 or later. To turn it on from the `/effort` slider, press `Tab` to flip the **Ultracode** toggle, then `Enter` to apply it. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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 the same request without a workflow. On a subscription plan those tokens draw on your usage limits, so a session with ultracode on reaches a session or weekly limit sooner than the same work with it off. Turning ultracode on already opts you in to large runs, so these checks don’t apply while it’s on: * The `Large workflow` warning doesn’t appear on a workflow run * The session’s [concurrent subagent limit](</docs/en/sub-agents#concurrent-subagent-limit>) isn’t enforced for the subagents Claude spawns with the Agent tool * In auto permission mode, you aren’t asked to approve the first workflow launch -`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. The `/effort` menu offers it only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). +`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Turn it off with `/effort ultracode off` when you return to routine work. The `/effort` slider offers the toggle only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). ### @@ -462,7 +462,7 @@ * Set `"disableWorkflows": true` in `~/.claude/settings.json`. Persists across sessions. * Set `CLAUDE_CODE_DISABLE_WORKFLOWS=1`. Read at startup, so it applies wherever you set it. -To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands and the `/workflow-authoring` skill are unavailable, the `ultracode` keyword no longer triggers a run, and `ultracode` is removed from the `/effort` menu. A run that was already in progress keeps going. No setting turns off ultracode alone. To keep workflows but rule out ultracode, set an [effort cap](</docs/en/model-config#organization-effort-limits>) below `xhigh` on the models you want to cover. Ultracode needs `xhigh`, so it’s then [unavailable](</docs/en/model-config#when-ultracode-is-available>) on those models. +To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands and the `/workflow-authoring` skill are unavailable, the `ultracode` keyword no longer triggers a run, and the **Ultracode** toggle is removed from `/effort`. A run that was already in progress keeps going. Turning workflows off also makes ultracode unavailable. No managed setting rules out ultracode alone: wherever it’s [available](</docs/en/model-config#when-ultracode-is-available>), users can turn it on with `/effort ultracode`. An [effort cap](</docs/en/model-config#organization-effort-limits>) lowers the effort level a session with ultracode on runs at, but doesn’t turn ultracode off. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -155,7 +155,13 @@ /effort ultracode -To start a session with ultracode already on, launch with `claude --effort ultracode`. Requires Claude Code v2.1.203 or later. To turn it on while you choose a model, move the `/model` picker’s effort slider to `ultracode` with the arrow keys. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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. `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. The `/effort` menu offers it only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). +To start a session with ultracode already on, launch with `claude --effort ultracode`. Requires Claude Code v2.1.203 or later. To turn it on while you choose a model, move the `/model` picker’s effort slider to `ultracode` with the arrow keys. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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. On a subscription plan those tokens draw on your usage limits, so a session with ultracode on reaches a session or weekly limit sooner than the same work at `high`. Turning ultracode on already opts you in to large runs, so these checks don’t apply while it’s on: + + * The `Large workflow` warning doesn’t appear on a workflow run + * The session’s [concurrent subagent limit](</docs/en/sub-agents#concurrent-subagent-limit>) isn’t enforced for the subagents Claude spawns with the Agent tool + * In auto permission mode, you aren’t asked to approve the first workflow launch + +`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. The `/effort` menu offers it only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). ### @@ -456,7 +462,7 @@ * Set `"disableWorkflows": true` in `~/.claude/settings.json`. Persists across sessions. * Set `CLAUDE_CODE_DISABLE_WORKFLOWS=1`. Read at startup, so it applies wherever you set it. -To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands and the `/workflow-authoring` skill are unavailable, the `ultracode` keyword no longer triggers a run, and `ultracode` is removed from the `/effort` menu. +To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands and the `/workflow-authoring` skill are unavailable, the `ultracode` keyword no longer triggers a run, and `ultracode` is removed from the `/effort` menu. A run that was already in progress keeps going. No setting turns off ultracode alone. To keep workflows but rule out ultracode, set an [effort cap](</docs/en/model-config#organization-effort-limits>) below `xhigh` on the models you want to cover. Ultracode needs `xhigh`, so it’s then [unavailable](</docs/en/model-config#when-ultracode-is-available>) on those models. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -213,7 +213,7 @@ Distribute a workflow in a plugin -To share a workflow across teams or repositories, include it in a [plugin](</docs/en/plugins>). Place the script in a `workflows/` directory at the plugin root, or point to a different location with the [`workflows` manifest field](</docs/en/plugins-reference#component-path-fields>). Plugin workflows are namespaced by the plugin name. A plugin called `acme-tools` containing a script whose `meta.name` is `release-audit` runs as `/acme-tools:release-audit`. +To share a workflow across teams or repositories, include it in a [plugin](</docs/en/plugins/overview>). Place the script in a `workflows/` directory at the plugin root, or point to a different location with the [`workflows` manifest field](</docs/en/plugins/manifest-reference#fields>). Plugin workflows are namespaced by the plugin name. A plugin called `acme-tools` containing a script whose `meta.name` is `release-audit` runs as `/acme-tools:release-audit`. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -205,7 +205,7 @@ * Project location: Claude Code refuses if `.claude`, `.claude/workflows`, or the target file is a symlink. * Personal location: Claude Code refuses only if the target file itself is a symlink, so a `~/.claude` directory managed by a dotfiles tool still works. -Before v2.1.216, Claude Code followed the link, which could place the file outside the location you chose. 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. +Before v2.1.216, Claude Code followed the link, which could place the file outside the location you chose. In a monorepo with several `.claude/` directories, you can keep workflows alongside the package they apply to. 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. ### @@ -318,7 +318,7 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier can block an `agent()` call before the subagent starts. A blocked call resolves to `null` and shows in the run’s progress view with the reason. `pipeline()` keeps each `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps each `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the prompt your script passes to `agent()` doesn’t count as a request from you when the classifier reviews that subagent’s actions, because Claude Code marks it as text the script computed. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). ###
modified
--- a/workflows.md +++ b/workflows.md @@ -364,7 +364,7 @@ No mid-run user input| A run pauses on its own only for agent permission prompts and a usage-limit wait. For sign-off between stages, run each stage as its own workflow No direct filesystem or shell access from the workflow itself| Agents read, write, and run commands. The script coordinates the agents No module loading: a script that contains `import()` fails before the run starts| The script body is plain JavaScript. Put work that needs a library in an agent’s task -Up to 16 concurrent agents, fewer when Claude Code has fewer CPUs available, including inside a CPU-limited container| Bounds local resource use +Up to 16 concurrent agents by default, fewer when Claude Code has fewer CPUs available, including inside a CPU-limited container. To change the limit, set [`CLAUDE_CODE_WORKFLOW_MAX_CONCURRENT_AGENTS`](</docs/en/env-vars#variables>) to a value from 1 to 256, which requires Claude Code v2.1.269 or later| Bounds local resource use In a fan-out, agents that share the first agent’s prompt-cache prefix start up to 5 seconds after it by default| All but the first read the prefix the first agent cached instead of each processing it uncached Up to 4,096 items in a single `parallel()` or `pipeline()` call: the runtime rejects a longer list with an error| A silent cap would drop part of the workload without telling the script 1,000 agents total per run| Prevents runaway loops
modified
--- a/workflows.md +++ b/workflows.md @@ -19,7 +19,7 @@ Scale| A few delegated tasks per turn| Same as subagents| A handful of long-running peers| Dozens to hundreds of agents per run Interruption| Restarts the turn| Restarts the turn| Teammates keep running| Resumable in the same session -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. +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 goes into 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. ## @@ -57,7 +57,7 @@ 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.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. +When the run finishes, the report appears in your session. It cites the sources each claim came from, with claims that didn’t survive cross-checking already filtered out.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. To run a workflow for your own task, have Claude write one, and once a run does what you wanted you can save it as a command of your own. @@ -271,7 +271,7 @@ 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. +Run a reviewer per file, then pass all the findings to one agent that ranks and deduplicates them. use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary
modified
--- a/workflows.md +++ b/workflows.md @@ -361,7 +361,7 @@ Constraint| Why ---|--- -No mid-run user input| Only agent permission prompts can pause a run. For sign-off between stages, run each stage as its own workflow +No mid-run user input| A run pauses on its own only for agent permission prompts and a usage-limit wait. For sign-off between stages, run each stage as its own workflow No direct filesystem or shell access from the workflow itself| Agents read, write, and run commands. The script coordinates the agents No module loading: a script that contains `import()` fails before the run starts| The script body is plain JavaScript. Put work that needs a library in an agent’s task Up to 16 concurrent agents, fewer when Claude Code has fewer CPUs available, including inside a CPU-limited container| Bounds local resource use @@ -400,9 +400,22 @@ ​ +When a run hits your usage limit + +When an agent hits your claude.ai [usage limit](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>), the run pauses rather than failing that agent: the agents that hit the limit wait for the reset, and no new agents start. Shortly after the limit resets, the waiting agents run again and the run continues on its own. Requires Claude Code v2.1.271 or later; on earlier versions, the affected agents fail. While the run waits, its progress line in the task panel and the `/workflows` header show when the limit resets. The run pauses only when all of these hold; when one doesn’t, the affected agent fails instead: + + * The session is interactive and signed in with a claude.ai subscription. A run doesn’t pause in [non-interactive mode](</docs/en/headless>) with `claude -p` or the [Agent SDK](</docs/en/agent-sdk/overview>), in a [background session](</docs/en/agent-view>), or in a [Remote Control](</docs/en/remote-control>) or [agent team](</docs/en/agent-teams>) teammate session. + * [`autoContinueAtUsageLimit`](</docs/en/settings-reference#autocontinueatusagelimit>) is on, the same setting that lets the session itself [wait for a usage limit to reset](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>). If you turn it off during a wait, the wait ends and the waiting agents fail. + * The limit resets within 24 hours. A weekly limit can reset further out. + * The run hasn’t already waited twice. When it hits the limit a third time, the agent fails. + +### + +​ + 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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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. The warning is advisory: it doesn’t pause or limit the run. Two settings change when you see it: +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. 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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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. The warning is advisory: it doesn’t pause or limit the run. Two settings change when you see it: * If you choose a size guideline yourself, its agent count replaces the 25-agent threshold. The built-in default guideline leaves the threshold at 25. * Sessions with ultracode on don’t show the warning, because turning ultracode on already opts you in to large runs. @@ -426,10 +439,10 @@ ---|--- `unrestricted`| No guideline: Claude sizes the workflow to the task `small`| Fewer than 5 agents -`medium`| Fewer than 15 agents +`medium`| Fewer than 10 agents `large`| Fewer than 50 agents -The default is `medium`. Until you choose a value, the `/config` row shows `medium (default)` and the workflow’s `Running in background` line shows `medium size (/config)`. Requires Claude Code v2.1.219 or later; earlier versions default to `unrestricted`. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. On v2.1.219 and later, you can also set the [`workflowSizeGuideline` key](</docs/en/settings-reference#workflowsizeguideline>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. +The default is `medium`, or `small` when you’re signed in on a Pro plan with Claude Code v2.1.271 or later. Until you choose a value, the `/config` row marks the value as the default, and the workflow’s `Running in background` line names the size in force. Requires Claude Code v2.1.219 or later; earlier versions default to `unrestricted`. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. On v2.1.219 and later, you can also set the [`workflowSizeGuideline` key](</docs/en/settings-reference#workflowsizeguideline>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -155,7 +155,7 @@ /effort ultracode -To start a session with ultracode already on, launch with `claude --effort ultracode`. Requires Claude Code v2.1.203 or later. To turn it on while you choose a model, move the `/model` picker’s effort slider to `ultracode` with the arrow keys. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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. `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. It’s available on models that support `xhigh` [effort](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. +To start a session with ultracode already on, launch with `claude --effort ultracode`. Requires Claude Code v2.1.203 or later. To turn it on while you choose a model, move the `/model` picker’s effort slider to `ultracode` with the arrow keys. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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. `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. The `/effort` menu offers it only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). ### @@ -318,7 +318,7 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier can block an `agent()` call before the subagent starts. A blocked call resolves to `null` and shows in the run’s progress view with the reason. `pipeline()` keeps each `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). ###
modified
--- a/workflows.md +++ b/workflows.md @@ -86,7 +86,7 @@ Key| Action ---|--- `↑` / `↓`| Select a phase or agent -`Enter` or `→`| Drill into the selected phase, then into an agent to read its prompt, recent tool calls, and result +`Enter` or `→`| Drill into the selected phase, then into an agent’s detail. In the detail, `Enter` expands or collapses it `Esc` or `←`| Back out one level. In v2.1.203 through v2.1.205, `←` didn’t step back out of a phase or agent; use `Esc` on those versions `j` / `k`| Scroll within the agent detail when it overflows `f`| Filter the agent list in the selected phase by status. Press again to cycle @@ -95,6 +95,8 @@ `r`| Restart the selected running agent `s`| Save the run’s script as a command +The agent detail lists the agent’s prompt, its recent tool calls, and its result. Each call shows its state, such as still running or failed. When the agent keeps a task list of its own, the detail shows it too, with each task’s status. Press `Enter` to expand the detail. The prompt and result then show in full, and each listed call shows its input and the start of its result. + ## ​ @@ -316,7 +318,7 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. If you pass a `schema` on an `agent()` call, that subagent returns JSON matching the shape instead of prose. Claude Code checks the schema before starting the subagent: when it can prove the schema contradicts itself, the call fails with an error naming the contradiction, and the subagent never starts. One contradiction it can prove is a `required` key that `additionalProperties: false` rules out. If the subagent’s output still fails validation after five attempts, the call fails with an error that includes the last validation failure. To change the attempt count, set [`MAX_STRUCTURED_OUTPUT_RETRIES`](</docs/en/env-vars>). ### @@ -373,7 +375,7 @@ 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. +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. When you stop a run, it stays in the task panel while any of its agents’ processes are still running. If you stop it again, Claude Code re-signals those processes. ### @@ -381,7 +383,7 @@ Resume after a pause -Resume a paused run from `/workflows` by selecting it and pressing `p`. For a run you stopped, ask Claude to relaunch the workflow with the same script. Claude Code replays the run in the order agents started, and each agent either returns its saved result or runs again: +Resume a paused run from `/workflows` by selecting it and pressing `p`. For a run you stopped, ask Claude to relaunch the workflow with the same script. If agents from the stopped run haven’t exited yet, Claude Code refuses the relaunch until they have, so a second copy of those agents can’t run alongside them. Claude Code replays the run in the order agents started, and each agent either returns its saved result or runs again: * **Completed** : returns its saved result. The first agent whose prompt differs from the previous run, because you edited the script or an earlier agent returned something different, runs again, and so does every agent after it, even ones that completed. * **Still running when you stopped** : starts over. Stopping the whole run doesn’t count any agent as failed. @@ -390,7 +392,9 @@ That last case means a failure in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B fails, relaunching returns A from cache and runs B, C, and D again. You can resume a run within the same Claude Code session. What happens to a running workflow when you leave the session depends on how you leave: * If you [background the session](</docs/en/agent-view#what-carries-over-when-you-background>), Claude Code replays the run the same way in the background session and continues it. - * If you exit Claude Code while a workflow is running and [agent view is on](</docs/en/agent-view#from-inside-a-session>), the exit dialog offers `Move to background and exit`, which carries the run over the same way. If you choose `Exit and stop tasks` instead, or the option isn’t offered, the run stops with the session. Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`, so a session you resume with `claude --resume` can replay them when you ask Claude to relaunch the workflow, while a session you start fresh has nothing to replay and starts the workflow over. + * If you exit Claude Code while a workflow is running and [agent view is on](</docs/en/agent-view#from-inside-a-session>), the exit dialog offers `Move to background and exit`, which carries the run over the same way. If you choose `Exit and stop tasks` instead, or the option isn’t offered, the run stops with the session. Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`, so a session you resume with `claude --resume` can replay them when you ask Claude to relaunch the workflow. In a session you start fresh, Claude has no earlier run to relaunch and starts the workflow over as a new run. + +In a [cloud session](</docs/en/claude-code-on-the-web>), Claude Code also saves the run’s results with the session’s conversation history, which survives when the session’s VM is reclaimed. When you [reopen such a session](</docs/en/claude-code-on-the-web#environment-expired>) and ask Claude to relaunch the workflow, completed agents still return their saved results. In local and cloud sessions alike, when Claude relaunches an earlier run and Claude Code can’t find that run’s saved results at all, the relaunch fails with a `nothing to resume` error instead of starting the run over on its own. Ask Claude to start the workflow over as a new run. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -114,7 +114,7 @@ Ask for a workflow in your prompt -To run a single task as a workflow without changing the session’s effort level, include the keyword `ultracode` 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. +To run a single task as a workflow without changing the session’s effort level, include the keyword `ultracode` 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. ultracode: audit every API endpoint under src/routes/ for missing auth checks
modified
--- a/workflows.md +++ b/workflows.md @@ -153,7 +153,7 @@ /effort ultracode -To start a session with ultracode already on, launch with `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. `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. It’s available on models that support `xhigh` [effort](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. +To start a session with ultracode already on, launch with `claude --effort ultracode`. Requires Claude Code v2.1.203 or later. To turn it on while you choose a model, move the `/model` picker’s effort slider to `ultracode` with the arrow keys. [Adjust effort level](</docs/en/model-config#adjust-effort-level>) lists the routes that turn ultracode on. 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. `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. It’s available on models that support `xhigh` [effort](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. ### @@ -403,7 +403,7 @@ * If you choose a size guideline yourself, its agent count replaces the 25-agent threshold. The built-in default guideline leaves the threshold at 25. * Sessions with ultracode on don’t show the warning, because turning ultracode on already opts you in to large runs. -Every agent in a workflow uses your session’s model unless the script routes a stage to a different one or the [`CLAUDE_CODE_SUBAGENT_MODEL`](</docs/en/model-config#environment-variables>) environment variable is set, which overrides both. To control the model cost: +Claude Code picks each workflow agent’s model in the same [order it uses for subagents](</docs/en/sub-agents#choose-a-model>). A model the script names for a stage counts as the per-invocation model in that order. When nothing else assigns one, the agent runs on your session’s model. To control the model cost: * Check `/model` before 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
modified
--- a/workflows.md +++ b/workflows.md @@ -1,6 +1,6 @@ Dynamic workflows 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`. -A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. +A dynamic workflow is a JavaScript script that orchestrates many [subagents](</docs/en/sub-agents>) at once. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. ## @@ -316,7 +316,22 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent and `pipeline()` runs one per item in a list. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. 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](</docs/en/agent-sdk/typescript>) for the full set of options. +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agent tasks at the same time and waits for all of them. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. + +### + +​ + +Edit a saved script + +To change a workflow you saved, edit its `.js` file or ask Claude to make the change. Before you edit or ask, run the `/workflow-authoring` [bundled skill](</docs/en/skills#bundled-skills>) to load the script-writing reference Claude works from. The skill requires Claude Code v2.1.248 or later. To run the edited version in the current session, run [`/reload-skills`](</docs/en/commands#all-commands>) to re-read the workflow directories, then run `/<name>` again. Claude Code applies these rules to each part of the file when it loads and runs the script: + + * **`meta` block**: keep `export const meta` as the first statement, and keep it a plain object literal with a `name` and a `description`. If it contains anything other than literal values, such as a variable, a function call, or a spread, Claude Code drops `/<name>` from `/` autocomplete. + * **Body** : besides `agent()`, `pipeline()`, and `parallel()`, you can call `phase()` to group the agents that follow under a title in the progress view, call `log()` to show a message above the phases, and read the `args` global. If the body has a syntax error, Claude Code reports it when you run the workflow. + * **`phases`** : if you list them in `meta`, give each entry exactly the title you pass to `phase()`. A `phase()` title with no entry gets a progress group of its own. + * **Timestamps and randomness** : Claude Code makes `Date.now()`, `Math.random()`, and a no-argument `new Date()` throw inside the script, so that a relaunched run repeats the same `agent()` calls. Pass a timestamp in through `args` instead. + +You can also edit the script of a single run rather than the saved copy. Resume after a pause covers which agents run again when you relaunch an edited script. For the Workflow tool’s inputs, see its entry in the [Agent SDK reference](</docs/en/agent-sdk/typescript#workflow>). ## @@ -324,7 +339,7 @@ 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. +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. Claude can start a workflow only from a script file the session is already allowed to read. To run a script kept outside your working directory, add its directory with [`/add-dir`](</docs/en/permissions#working-directories>) or a [Read allow rule](</docs/en/permissions#read-and-edit>) first. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session. ### @@ -349,6 +364,7 @@ No module loading: a script that contains `import()` fails before the run starts| The script body is plain JavaScript. Put work that needs a library in an agent’s task Up to 16 concurrent agents, fewer when Claude Code has fewer CPUs available, including inside a CPU-limited container| Bounds local resource use In a fan-out, agents that share the first agent’s prompt-cache prefix start up to 5 seconds after it by default| All but the first read the prefix the first agent cached instead of each processing it uncached +Up to 4,096 items in a single `parallel()` or `pipeline()` call: the runtime rejects a longer list with an error| A silent cap would drop part of the workload without telling the script 1,000 agents total per run| Prevents runaway loops ## @@ -423,7 +439,7 @@ * Set `"disableWorkflows": true` in `~/.claude/settings.json`. Persists across sessions. * Set `CLAUDE_CODE_DISABLE_WORKFLOWS=1`. Read at startup, so it applies wherever you set it. -To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) 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. +To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands and the `/workflow-authoring` skill are unavailable, the `ultracode` keyword no longer triggers a run, and `ultracode` is removed from the `/effort` menu. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -1,4 +1,4 @@ -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`. +Dynamic workflows 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`. A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. @@ -118,7 +118,7 @@ ultracode: audit every API endpoint under src/routes/ for missing auth checks -Claude Code highlights the keyword in your input and Claude writes a workflow script for the task instead of working through it turn by turn. The keyword only chooses how Claude structures the work: a workflow started this way runs inside the session’s existing [permission mode](</docs/en/permission-modes>), and its agents’ tool calls receive the same permission checks and [sandboxing](</docs/en/sandboxing>) as any other tool call in the session. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. +Claude Code highlights the keyword in your input and Claude writes a workflow script for the task instead of working through it turn by turn. The keyword only chooses how Claude structures the work: the agents’ tool calls receive the same permission checks and [sandboxing](</docs/en/sandboxing>) as any other tool call in the session. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. #### @@ -164,7 +164,7 @@ 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 + * **Yes, and don’t ask again for`<name>` in `<path>`**: start, and skip this prompt for this workflow in this project from now on. Claude Code offers this option when you run a bundled, saved, or plugin workflow by name, not for a script Claude wrote for the current task. * **View raw script** : read the script before deciding * **No** : cancel @@ -174,9 +174,18 @@ ---|--- Auto| First launch only. Any **Yes** records consent in your user settings, and later launches start without prompting. Skipped entirely when ultracode is on Manual, accept edits| Every run, unless you’ve selected **Yes, and don’t ask again** for that workflow in this project -Bypass permissions, `claude -p`, Agent SDK| Never. The run starts immediately - -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](</docs/en/settings-reference#permission-settings>), 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. +Bypass permissions| Claude Code doesn’t prompt you. The run starts immediately +`claude -p`, Agent SDK| Claude Code doesn’t prompt you + +In `claude -p` and the Agent SDK, Claude Code never shows this prompt. It runs the Workflow tool call through the same [permission evaluation](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) as the rest of the session, so deny rules, ask rules, and `dontAsk` mode apply to the launch as they apply to every tool call. To let the workflow start in these runs, use one of these: + + * **Permission rule** : `Workflow` in your allow rules approves every workflow, and `Workflow(<name>)` approves one saved workflow by name. + * **Auto permission mode** : the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) reviews the call and can approve it. + * **Bypass permissions mode** : Claude Code approves the call. + * **A`PreToolUse` hook**: a [hook](</docs/en/hooks#pretooluse>) that returns `allow` for the call approves it. + * **Your host** : a [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>) approves it, or, with the Agent SDK, a [`canUseTool`](</docs/en/agent-sdk/permissions>) callback or a [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) approves it. + +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. The subagents the workflow spawns use your [permission rules](</docs/en/settings-reference#permission-settings>), and Claude Code picks their permission mode by the rules under [which permission mode a subagent runs in](</docs/en/sub-agents#permission-modes>). To avoid prompts on a long run, add the tools the agents need to your allow rules before starting. ### @@ -356,12 +365,16 @@ Resume after a pause -If you stop a run, you can resume it. Agents that already completed usually return their cached results, and the rest run live. Two rules decide which results survive: - - * An agent that was still running when you stopped isn’t saved, so it starts over on resume. - * Replay follows the order agents started. Cached results stop at the first agent that didn’t finish, and every agent that started after that one runs again, even if it completed. - -The second rule is what makes stopping mid fan-out expensive. Say a script starts four agents, A, B, C, and D, in that order, and you stop the run while B is still going. On resume, A returns from cache. B runs again because it never finished. C and D run again too, because they started after B, even though both completed before you stopped. A workflow that fans work out across many small agents therefore 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. +Resume a paused run from `/workflows` by selecting it and pressing `p`. For a run you stopped, ask Claude to relaunch the workflow with the same script. Claude Code replays the run in the order agents started, and each agent either returns its saved result or runs again: + + * **Completed** : returns its saved result. The first agent whose prompt differs from the previous run, because you edited the script or an earlier agent returned something different, runs again, and so does every agent after it, even ones that completed. + * **Still running when you stopped** : starts over. Stopping the whole run doesn’t count any agent as failed. + * **Failed** : runs again, and so does every agent that started after it, even ones that completed. Stopping one agent alone, by selecting it in `/workflows` and pressing `x`, counts as failing. + +That last case means a failure in the middle of a fan-out reruns work that already finished. If a script starts A, B, C, and D in that order and B fails, relaunching returns A from cache and runs B, C, and D again. You can resume a run within the same Claude Code session. What happens to a running workflow when you leave the session depends on how you leave: + + * If you [background the session](</docs/en/agent-view#what-carries-over-when-you-background>), Claude Code replays the run the same way in the background session and continues it. + * If you exit Claude Code while a workflow is running and [agent view is on](</docs/en/agent-view#from-inside-a-session>), the exit dialog offers `Move to background and exit`, which carries the run over the same way. If you choose `Exit and stop tasks` instead, or the option isn’t offered, the run stops with the session. Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`, so a session you resume with `claude --resume` can replay them when you ask Claude to relaunch the workflow, while a session you start fresh has nothing to replay and starts the workflow over. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -252,7 +252,7 @@ Discover the files to migrate, transform each one in an isolated copy so edits don’t conflict, and verify each result. - use a workflow to migrate every component under src/components/ from styled-components to Tailwind, working on each file in its own isolated copy + use a workflow to migrate every component under src/components/ from JavaScript to TypeScript, working on each file in its own isolated copy ###
modified
--- a/workflows.md +++ b/workflows.md @@ -323,7 +323,7 @@ Prompt caching in a fan-out -Agents in the same run can read each other’s [prompt cache](</docs/en/prompt-caching#subagents-and-the-cache>). Two agents that run with the same model, effort level, agent type, tools, output schema, and working directory build the same tools-and-system-prompt prefix, so an agent that starts after a matching sibling’s response has begun reads that sibling’s cache on its first request. When a fan-out starts several matching agents at once, Claude Code holds all but the first until the first agent’s response begins, then releases the held agents together so their first requests read the shared prefix instead of each processing it uncached. Claude Code caps the hold at [`CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS`](</docs/en/env-vars>) milliseconds, `5000` by default. Set it to `0` to disable the hold. +Agents in the same run can read each other’s [prompt cache](</docs/en/prompt-caching#subagents-and-the-cache>). Two agents that run with the same model, effort level, agent type, tools, output schema, and working directory build the same tools-and-system-prompt prefix, so an agent that starts after a matching sibling’s response has begun reads that sibling’s cache on its first request. A workflow agent’s requests fall outside the main conversation’s [cache TTL bucket](</docs/en/prompt-caching#which-ttl-each-request-gets>), so its cache holds for five minutes by default, including on a Claude subscription. To keep it for an hour, set [`subagentPromptCacheTtl`](</docs/en/settings-reference#subagentpromptcachettl>) to `1h`. The API bills 1-hour cache writes at a higher rate. When a fan-out starts several matching agents at once, Claude Code holds all but the first until the first agent’s response begins, then releases the held agents together so their first requests read the shared prefix instead of each processing it uncached. Claude Code caps the hold at [`CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS`](</docs/en/env-vars>) milliseconds, `5000` by default. Set it to `0` to disable the hold. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -153,7 +153,7 @@ /effort ultracode -To start a session with ultracode already on, launch with `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](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. +To start a session with ultracode already on, launch with `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. `/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Drop back with `/effort high` when you return to routine work. It’s available on models that support `xhigh` [effort](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. ### @@ -176,7 +176,7 @@ Manual, accept edits| Every run, unless you’ve selected **Yes, and don’t ask again** for that workflow in this project Bypass permissions, `claude -p`, Agent SDK| Never. The run starts immediately -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](</docs/en/settings#permission-settings>), 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. +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](</docs/en/settings-reference#permission-settings>), 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. ### @@ -396,7 +396,7 @@ `medium`| Fewer than 15 agents `large`| Fewer than 50 agents -The default is `medium`. Until you choose a value, the `/config` row shows `medium (default)` and the workflow’s `Running in background` line shows `medium size (/config)`. Requires Claude Code v2.1.219 or later; earlier versions default to `unrestricted`. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. On v2.1.219 and later, you can also set the [`workflowSizeGuideline` key](</docs/en/settings#available-settings>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. +The default is `medium`. Until you choose a value, the `/config` row shows `medium (default)` and the workflow’s `Running in background` line shows `medium size (/config)`. Requires Claude Code v2.1.219 or later; earlier versions default to `unrestricted`. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. On v2.1.219 and later, you can also set the [`workflowSizeGuideline` key](</docs/en/settings-reference#workflowsizeguideline>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -81,11 +81,7 @@ 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. - - /workflows - -The progress view shows each phase with its agent counts, token totals, and elapsed time. The footer lists the key for each action: +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. The progress view shows each phase with its agent counts, token totals, and elapsed time. The footer lists the key for each action: Key| Action ---|---
modified
--- a/workflows.md +++ b/workflows.md @@ -176,8 +176,8 @@ Permission mode| When you’re prompted ---|--- -Default, accept edits| Every run, unless you’ve selected **Yes, and don’t ask again** for that workflow in this project Auto| First launch only. Any **Yes** records consent in your user settings, and later launches start without prompting. Skipped entirely when ultracode is on +Manual, accept edits| Every run, unless you’ve selected **Yes, and don’t ask again** for that workflow in this project Bypass permissions, `claude -p`, Agent SDK| Never. The run starts immediately 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](</docs/en/settings#permission-settings>), 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.
modified
--- a/workflows.md +++ b/workflows.md @@ -57,7 +57,7 @@ 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. +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.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. To run a workflow for your own task, have Claude write one, and once a run does what you wanted you can save it as a command of your own. @@ -73,7 +73,7 @@ ---|--- `/deep-research <question>`| 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 didn’t survive cross-checking filtered out. Requires the [WebSearch tool](</docs/en/tools-reference#websearch-tool-behavior>) to be available -`/deep-research` runs only when you invoke it. Before v2.1.218, Claude could also start it on its own. Workflows you save yourself become commands the same way and appear in `/` autocomplete alongside the bundled ones. +`/deep-research` runs only when you invoke it. Workflows you save yourself become commands the same way and appear in `/` autocomplete alongside the bundled ones. ### @@ -193,7 +193,7 @@ * `.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 set [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>), this location is the `workflows/` directory under that path. -The save dialog shows the resolved path for the personal location. Before v2.1.208, it showed `~/.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. Claude Code checks the save location for symlinks before writing, and shows an error instead of writing through one. What it checks depends on where you save: +The save dialog shows the resolved path for the personal location. Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. Claude Code checks the save location for symlinks before writing, and shows an error instead of writing through one. What it checks depends on where you save: * Project location: Claude Code refuses if `.claude`, `.claude/workflows`, or the target file is a symlink. * Personal location: Claude Code refuses only if the target file itself is a symlink, so a `~/.claude` directory managed by a dotfiles tool still works. @@ -320,6 +320,14 @@ 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. + +### + +​ + +Prompt caching in a fan-out + +Agents in the same run can read each other’s [prompt cache](</docs/en/prompt-caching#subagents-and-the-cache>). Two agents that run with the same model, effort level, agent type, tools, output schema, and working directory build the same tools-and-system-prompt prefix, so an agent that starts after a matching sibling’s response has begun reads that sibling’s cache on its first request. When a fan-out starts several matching agents at once, Claude Code holds all but the first until the first agent’s response begins, then releases the held agents together so their first requests read the shared prefix instead of each processing it uncached. Claude Code caps the hold at [`CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS`](</docs/en/env-vars>) milliseconds, `5000` by default. Set it to `0` to disable the hold. ### @@ -334,7 +342,8 @@ No mid-run user input| Only agent permission prompts can pause a run. For sign-off between stages, run each stage as its own workflow No direct filesystem or shell access from the workflow itself| Agents read, write, and run commands. The script coordinates the agents No module loading: a script that contains `import()` fails before the run starts| The script body is plain JavaScript. Put work that needs a library in an agent’s task -Up to 16 concurrent agents, fewer on machines with limited CPU cores| Bounds local resource use +Up to 16 concurrent agents, fewer when Claude Code has fewer CPUs available, including inside a CPU-limited container| Bounds local resource use +In a fan-out, agents that share the first agent’s prompt-cache prefix start up to 5 seconds after it by default| All but the first read the prefix the first agent cached instead of each processing it uncached 1,000 agents total per run| Prevents runaway loops ## @@ -364,7 +373,7 @@ 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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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: +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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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. The warning is advisory: it doesn’t pause or limit the run. Two settings change when you see it: * If you choose a size guideline yourself, its agent count replaces the 25-agent threshold. The built-in default guideline leaves the threshold at 25. * Sessions with ultracode on don’t show the warning, because turning ultracode on already opts you in to large runs.
modified
--- a/workflows.md +++ b/workflows.md @@ -333,6 +333,7 @@ ---|--- No mid-run user input| Only agent permission prompts can pause a run. For sign-off between stages, run each stage as its own workflow No direct filesystem or shell access from the workflow itself| Agents read, write, and run commands. The script coordinates the agents +No module loading: a script that contains `import()` fails before the run starts| The script body is plain JavaScript. Put work that needs a library in an agent’s task Up to 16 concurrent agents, fewer on machines with limited CPU cores| Bounds local resource use 1,000 agents total per run| Prevents runaway loops @@ -372,6 +373,8 @@ * Check `/model` before 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 + +When your organization’s [`availableModels` allowlist](</docs/en/model-config#restrict-model-selection>) blocks a model the script requests for an agent, that agent runs on a substituted model instead, following the same [substitution rules as subagents](</docs/en/sub-agents#choose-a-model>). The run’s progress view in `/workflows` shows a warning naming both the requested and substituted models. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -311,7 +311,7 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `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](</docs/en/agent-sdk/typescript>) for the full set of options. +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent and `pipeline()` runs one per item in a list. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. 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](</docs/en/agent-sdk/typescript>) for the full set of options. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -216,7 +216,7 @@ A saved workflow can accept input through the `args` 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: - > Run /triage-issues on issues 1024, 1025, and 1030 + Run /triage-issues on issues 1024, 1025, and 1030 Claude passes the list as structured data, so the script can call array and object methods on `args` directly without parsing it first. If `args` is omitted, the global is `undefined` inside the script. @@ -236,7 +236,7 @@ Fan out one agent per file, then collect and verify the findings. - > use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it + use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it ### @@ -246,7 +246,7 @@ Run a checker, fix what failed, and repeat until it passes or stops making progress. - > 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 + 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 ### @@ -256,7 +256,7 @@ Discover the files to migrate, transform each one in an isolated copy so edits don’t conflict, and verify each result. - > use a workflow to migrate every component under src/components/ from styled-components to Tailwind, working on each file in its own isolated copy + use a workflow to migrate every component under src/components/ from styled-components to Tailwind, working on each file in its own isolated copy ### @@ -266,7 +266,7 @@ Run a reviewer per file, then hand all the findings to one agent that ranks and deduplicates them. - > use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary + use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary ### @@ -276,7 +276,7 @@ Fan out readers across changelogs, issues, and docs, then synthesize. The bundled `/deep-research` workflow does this; you can also describe a narrower version. - > 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 + 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 ### @@ -286,7 +286,7 @@ Keep searching in rounds and stop when new rounds turn up nothing new. - > 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 + 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 ### @@ -350,7 +350,12 @@ 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. +If you stop a run, you can resume it. Agents that already completed usually return their cached results, and the rest run live. Two rules decide which results survive: + + * An agent that was still running when you stopped isn’t saved, so it starts over on resume. + * Replay follows the order agents started. Cached results stop at the first agent that didn’t finish, and every agent that started after that one runs again, even if it completed. + +The second rule is what makes stopping mid fan-out expensive. Say a script starts four agents, A, B, C, and D, in that order, and you stop the run while B is still going. On resume, A returns from cache. B runs again because it never finished. C and D run again too, because they started after B, even though both completed before you stopped. A workflow that fans work out across many small agents therefore 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. ### @@ -358,7 +363,7 @@ 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 runs to fewer agents, choose the `small` size guideline. 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: +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, usually without losing completed work. Resume after a pause covers what a stopped run keeps. The runtime’s agent caps limit how many agents a single run can spawn, which bounds the cost of a runaway script. To keep runs to fewer agents, choose the `small` size guideline. 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 choose a size guideline yourself, its agent count replaces the 25-agent threshold. The built-in default guideline leaves the threshold at 25. * Sessions with ultracode on don’t show the warning, because turning ultracode on already opts you in to large runs.
modified
--- a/workflows.md +++ b/workflows.md @@ -358,9 +358,9 @@ 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. +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 runs to fewer agents, choose the `small` size guideline. 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 choose a size guideline yourself, its agent count replaces the 25-agent threshold. The built-in default guideline leaves the threshold at 25. * Sessions with ultracode on don’t show the warning, because turning ultracode on already opts you in to large runs. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one or the [`CLAUDE_CODE_SUBAGENT_MODEL`](</docs/en/model-config#environment-variables>) environment variable is set, which overrides both. To control the model cost: @@ -374,16 +374,16 @@ 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. - -Value| Guidance sent to Claude +A size guideline tells Claude how many agents to aim for when it writes a dynamic workflow. Claude Code sends the guideline to Claude as advice, not a cap, so a prompt that calls for a different scale still overrides it. Requires Claude Code v2.1.202 or later. Each value maps to an agent count: + +Value| Agent count Claude aims for ---|--- -`unrestricted`| No guideline. This is the default. -`small`| Aim for fewer than 5 agents. -`medium`| Aim for fewer than 15 agents. -`large`| Aim for fewer than 50 agents. - -Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. +`unrestricted`| No guideline: Claude sizes the workflow to the task +`small`| Fewer than 5 agents +`medium`| Fewer than 15 agents +`large`| Fewer than 50 agents + +The default is `medium`. Until you choose a value, the `/config` row shows `medium (default)` and the workflow’s `Running in background` line shows `medium size (/config)`. Requires Claude Code v2.1.219 or later; earlier versions default to `unrestricted`. To change the guideline, pick a value for the Dynamic workflow size setting in `/config`, or run `/config workflowSizeGuideline=small`. On v2.1.219 and later, you can also set the [`workflowSizeGuideline` key](</docs/en/settings#available-settings>) in any settings file; that value takes precedence over `/config`, and Claude Code hides the `/config` row while a settings file provides one. Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -193,7 +193,20 @@ * `.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 set [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>), this location is the `workflows/` directory under that path. -The save dialog shows the resolved path for the personal location. Before v2.1.208, it showed `~/.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. +The save dialog shows the resolved path for the personal location. Before v2.1.208, it showed `~/.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. Claude Code checks the save location for symlinks before writing, and shows an error instead of writing through one. What it checks depends on where you save: + + * Project location: Claude Code refuses if `.claude`, `.claude/workflows`, or the target file is a symlink. + * Personal location: Claude Code refuses only if the target file itself is a symlink, so a `~/.claude` directory managed by a dotfiles tool still works. + +Before v2.1.216, Claude Code followed the link, which could place the file outside the location you chose. 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. + +### + +​ + +Distribute a workflow in a plugin + +To share a workflow across teams or repositories, include it in a [plugin](</docs/en/plugins>). Place the script in a `workflows/` directory at the plugin root, or point to a different location with the [`workflows` manifest field](</docs/en/plugins-reference#component-path-fields>). Plugin workflows are namespaced by the plugin name. A plugin called `acme-tools` containing a script whose `meta.name` is `release-audit` runs as `/acme-tools:release-audit`. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -73,7 +73,7 @@ ---|--- `/deep-research <question>`| 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 didn’t survive cross-checking filtered out. Requires the [WebSearch tool](</docs/en/tools-reference#websearch-tool-behavior>) to be available -Workflows you save yourself become commands the same way and appear in `/` autocomplete alongside the bundled ones. +`/deep-research` runs only when you invoke it. Before v2.1.218, Claude could also start it on its own. Workflows you save yourself become commands the same way and appear in `/` autocomplete alongside the bundled ones. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -122,7 +122,30 @@ ultracode: audit every API endpoint under src/routes/ for missing auth checks -Claude Code highlights the keyword in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If you didn’t mean to start a workflow, press `Option+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`. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. +Claude Code highlights the keyword in your input and Claude writes a workflow script for the task instead of working through it turn by turn. The keyword only chooses how Claude structures the work: a workflow started this way runs inside the session’s existing [permission mode](</docs/en/permission-modes>), and its agents’ tool calls receive the same permission checks and [sandboxing](</docs/en/sandboxing>) as any other tool call in the session. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. + +#### + +​ + +Dismiss or turn off the keyword + +If you didn’t mean to start a workflow, press `Option+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](</docs/en/remote-control>) client, or in an Agent SDK application that stamps your keyboard input’s [`origin`](</docs/en/agent-sdk/typescript#sdkmessageorigin>) 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. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -168,9 +168,9 @@ 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 - -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. + * `~/.claude/workflows/` in your home directory: available in every project, visible only to you. If you set [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>), this location is the `workflows/` directory under that path. + +The save dialog shows the resolved path for the personal location. Before v2.1.208, it showed `~/.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. ### @@ -314,7 +314,7 @@ 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. 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. +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. ### @@ -327,7 +327,7 @@ * 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. -Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model cost: +Every agent in a workflow uses your session’s model unless the script routes a stage to a different one or the [`CLAUDE_CODE_SUBAGENT_MODEL`](</docs/en/model-config#environment-variables>) environment variable is set, which overrides both. To control the model cost: * Check `/model` before 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
modified
--- a/workflows.md +++ b/workflows.md @@ -91,7 +91,7 @@ ---|--- `↑` / `↓`| Select a phase or agent `Enter` or `→`| Drill into the selected phase, then into an agent to read its prompt, recent tool calls, and result -`Esc`| Back out one level +`Esc` or `←`| Back out one level. In v2.1.203 through v2.1.205, `←` didn’t step back out of a phase or agent; use `Esc` on those versions `j` / `k`| Scroll within the agent detail when it overflows `f`| Filter the agent list in the selected phase by status. Press again to cycle `p`| Pause or resume the run
modified
--- a/workflows.md +++ b/workflows.md @@ -134,7 +134,7 @@ /effort ultracode -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](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. +To start a session with ultracode already on, launch with `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](</docs/en/model-config#adjust-effort-level>); on other models the `/effort` menu doesn’t offer it. ### @@ -322,7 +322,12 @@ 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`. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model 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. + +Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model cost: * Check `/model` before 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
modified
--- a/workflows.md +++ b/workflows.md @@ -322,10 +322,27 @@ 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. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model 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`. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model cost: * Check `/model` before 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. + +Value| Guidance sent to Claude +---|--- +`unrestricted`| No guideline. This is the default. +`small`| Aim for fewer than 5 agents. +`medium`| Aim for fewer than 15 agents. +`large`| Aim for fewer than 50 agents. + +Changes take effect on the next prompt. The runtime agent caps still apply regardless of the setting. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -1,4 +1,4 @@ -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 Vertex AI, and Microsoft Foundry. On Pro, turn them on from the Dynamic workflows row in `/config`. +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`. A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one.
modified
Show diff (102 lines)
--- a/workflows.md +++ b/workflows.md @@ -188,6 +188,99 @@ ​ +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. + + > use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it + +### + +​ + +Keep fixing until a check passes + +Run a checker, fix what failed, and repeat until it passes or stops making progress. + + > 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 + +### + +​ + +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. + + > use a workflow to migrate every component under src/components/ from styled-components to Tailwind, working on each file in its own isolated copy + +### + +​ + +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. + + > use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary + +### + +​ + +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. + + > 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 + +### + +​ + +Find issues until the list stops growing + +Keep searching in rounds and stop when new rounds turn up nothing new. + + > 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 + +### + +​ + +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: + + 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) + +The body is plain JavaScript with top-level `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](</docs/en/agent-sdk/typescript>) 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.
modified
--- a/workflows.md +++ b/workflows.md @@ -57,7 +57,7 @@ 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. +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. To run a workflow for your own task, have Claude write one, and once a run does what you wanted you can save it as a command of your own.
modified
--- a/workflows.md +++ b/workflows.md @@ -1,11 +1,6 @@ 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 Vertex AI, and Microsoft Foundry. On Pro, turn them on from the Dynamic workflows row in `/config`. -A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. This page covers how to: - - * Decide when to use a workflow instead of subagents or skills - * Run a bundled workflow with `/deep-research` - * Have Claude write a workflow for your task and save it - * Understand how a workflow runs and manage runs +A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -98,6 +98,7 @@ `Enter` or `→`| Drill into the selected phase, then into an agent to read its prompt, recent tool calls, and result `Esc`| Back out one level `j` / `k`| Scroll within the agent detail when it overflows +`f`| Filter the agent list in the selected phase by status. Press again to cycle `p`| Pause or resume the run `x`| Stop the selected agent, or stop the whole workflow when focus is on the run `r`| Restart the selected running agent
modified
--- a/workflows.md +++ b/workflows.md @@ -174,7 +174,7 @@ * `.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 -Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. 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. +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. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -174,7 +174,7 @@ * `.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 -Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. If a project workflow and a personal workflow share a name, the project one runs. +Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. 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. ###
modified
--- a/workflows.md +++ b/workflows.md @@ -1,4 +1,4 @@ -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. On Pro, turn them on from the Dynamic workflows row in `/config`. +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 Vertex AI, and Microsoft Foundry. On Pro, turn them on from the Dynamic workflows row in `/config`. A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. This page covers how to:
modified
--- a/workflows.md +++ b/workflows.md @@ -1,9 +1,3 @@ -> ## Documentation Index -> -> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> -> -> Use this file to discover all available pages before exploring further. - 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. On Pro, turn them on from the Dynamic workflows row in `/config`. A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. This page covers how to:
modified
--- a/workflows.md +++ b/workflows.md @@ -117,7 +117,7 @@ You can have Claude write a workflow for your task in two ways: - * Ask for a workflow in your prompt with the word `workflow`, and Claude writes one for the task. + * 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 ultracode` and Claude plans a workflow for every substantive task in the session. You can also run a workflow command that already exists: a bundled workflow like `/deep-research`, or one you’ve saved. @@ -128,11 +128,11 @@ Ask for a workflow in your prompt -To run a single task as a workflow without changing the session’s effort level, include the word `workflow` anywhere in your prompt. - - Run a workflow to audit every API endpoint under src/routes/ for missing auth checks - -Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If you didn’t mean to start a workflow, press `Option+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 word. To stop the word from triggering at all, turn off Workflow keyword trigger in `/config`. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. +To run a single task as a workflow without changing the session’s effort level, include the keyword `ultracode` 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. + + ultracode: audit every API endpoint under src/routes/ for missing auth checks + +Claude Code highlights the keyword in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If you didn’t mean to start a workflow, press `Option+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`. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. ### @@ -256,7 +256,7 @@ * Set `"disableWorkflows": true` in `~/.claude/settings.json`. Persists across sessions. * Set `CLAUDE_CODE_DISABLE_WORKFLOWS=1`. Read at startup, so it applies wherever you set it. -To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands are unavailable, the `workflow` keyword no longer triggers a run, and `ultracode` is removed from the `/effort` menu. +To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) 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. ##
modified
--- a/workflows.md +++ b/workflows.md @@ -19,18 +19,18 @@ When to use a workflow -[Subagents](</docs/en/sub-agents>), [skills](</docs/en/skills>), and workflows can all run a multi-step task. The difference is who holds the plan: - -| Subagents| Skills| Workflows ----|---|---|--- -What it is| A worker Claude spawns| Instructions Claude follows| A script the runtime executes -Who decides what runs next| Claude, turn by turn| Claude, following the prompt| The script -Where intermediate results live| Claude’s context window| Claude’s context window| Script variables -What’s repeatable| The worker definition| The instructions| The orchestration itself -Scale| A few delegated tasks per turn| Same as subagents| Dozens to hundreds of agents per run -Interruption| Restarts the turn| Restarts the turn| Resumable in the same session - -A workflow moves the plan into code. 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. 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. +[Subagents](</docs/en/sub-agents>), [skills](</docs/en/skills>), [agent teams](</docs/en/agent-teams>), and workflows can all run a multi-step task. The difference is who holds the plan: + +| Subagents| Skills| Agent teams| Workflows +---|---|---|---|--- +What it is| A worker Claude spawns| Instructions Claude follows| A lead agent supervising peer sessions| A script the runtime executes +Who decides what runs next| Claude, turn by turn| Claude, following the prompt| The lead agent, turn by turn| The script +Where intermediate results live| Claude’s context window| Claude’s context window| A shared task list| Script variables +What’s repeatable| The worker definition| The instructions| The team definition| The orchestration itself +Scale| A few delegated tasks per turn| Same as subagents| A handful of long-running peers| Dozens to hundreds of agents per run +Interruption| Restarts the turn| Restarts the turn| Teammates keep running| Resumable in the same session + +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. ## @@ -132,7 +132,7 @@ Run a workflow to audit every API endpoint under src/routes/ for missing auth checks -Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If the run does what you wanted, you can save it as a command afterward. If Claude Code highlights the word when you didn’t mean to trigger one, press `alt+w` to ignore it for this prompt, or press backspace while the cursor is right after the highlighted word. To stop the word from triggering at all, turn off Workflow keyword trigger in `/config`. +Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If you didn’t mean to start a workflow, press `Option+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 word. To stop the word from triggering at all, turn off Workflow keyword trigger in `/config`. If the run does what you wanted, you can save it as a command afterward. If you already have an orchestrator built another way, such as a folder of subagent prompts or a skill that fans work out, you can point Claude at it and ask for a workflow that does the same thing. ### @@ -182,13 +182,25 @@ Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. 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 the `args` 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: + + > Run /triage-issues on issues 1024, 1025, and 1030 + +Claude passes the list as structured data, so the script can call array and object methods on `args` directly without parsing it first. If `args` is omitted, the global is `undefined` inside the script. + ## ​ 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. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session. +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. ### @@ -227,7 +239,7 @@ 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. You can stop a running workflow from `/workflows` at any time without losing completed work. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model 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. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model cost: * Check `/model` before 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
modified
--- a/workflows.md +++ b/workflows.md @@ -132,7 +132,7 @@ Run a workflow to audit every API endpoint under src/routes/ for missing auth checks -Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If the run does what you wanted, you can save it as a command afterward. If Claude Code highlights the word when you didn’t mean to trigger one, press `alt+w` to ignore it for this prompt. +Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If the run does what you wanted, you can save it as a command afterward. If Claude Code highlights the word when you didn’t mean to trigger one, press `alt+w` to ignore it for this prompt, or press backspace while the cursor is right after the highlighted word. To stop the word from triggering at all, turn off Workflow keyword trigger in `/config`. ###
added
Show diff (260 lines)
--- a/workflows.md +++ b/workflows.md @@ -0,0 +1,257 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + +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. On Pro, turn them on from the Dynamic workflows row in `/config`. + +A dynamic workflow is a JavaScript script that orchestrates [subagents](</docs/en/sub-agents>) at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. 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. Examples include a codebase-wide bug sweep, a 500-file migration, a research question that needs sources cross-checked against each other, and a hard plan worth drafting from several independent angles before you commit to one. This page covers how to: + + * Decide when to use a workflow instead of subagents or skills + * Run a bundled workflow with `/deep-research` + * Have Claude write a workflow for your task and save it + * Understand how a workflow runs and manage runs + +## + +​ + +When to use a workflow + +[Subagents](</docs/en/sub-agents>), [skills](</docs/en/skills>), and workflows can all run a multi-step task. The difference is who holds the plan: + +| Subagents| Skills| Workflows +---|---|---|--- +What it is| A worker Claude spawns| Instructions Claude follows| A script the runtime executes +Who decides what runs next| Claude, turn by turn| Claude, following the prompt| The script +Where intermediate results live| Claude’s context window| Claude’s context window| Script variables +What’s repeatable| The worker definition| The instructions| The orchestration itself +Scale| A few delegated tasks per turn| Same as subagents| Dozens to hundreds of agents per run +Interruption| Restarts the turn| Restarts the turn| Resumable in the same session + +A workflow moves the plan into code. 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. 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. + + /deep-research What changed in the Node.js permission model between v20 and v22? + +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 `/workflows`, use the arrow keys to select the run, and press Enter to open its progress view: + + /workflows + +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. + +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. + +To run a workflow for your own task, have Claude write one, and once a run does what you wanted you can save it as a command of your own. + +### + +​ + +Bundled workflows + +Claude Code includes `/deep-research` as a built-in workflow: + +Command| What it does +---|--- +`/deep-research <question>`| 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 didn’t survive cross-checking filtered out. Requires the [WebSearch tool](</docs/en/tools-reference#websearch-tool-behavior>) to be available + +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. + + /workflows + +The progress view shows each phase with its agent counts, token totals, and elapsed time. The footer lists the key for each action: + +Key| Action +---|--- +`↑` / `↓`| Select a phase or agent +`Enter` or `→`| Drill into the selected phase, then into an agent to read its prompt, recent tool calls, and result +`Esc`| Back out one level +`j` / `k`| Scroll within the agent detail when it overflows +`p`| Pause or resume the run +`x`| Stop the selected agent, or stop the whole workflow when focus is on the run +`r`| Restart the selected running agent +`s`| Save the run’s script as a command + +## + +​ + +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 with the word `workflow`, and Claude writes one for the task. + * Let Claude decide with ultracode: set `/effort ultracode` and Claude plans a workflow for every substantive task in the session. + +You can also run a workflow command that already exists: a bundled workflow like `/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 word `workflow` anywhere in your prompt. + + Run a workflow to audit every API endpoint under src/routes/ for missing auth checks + +Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If the run does what you wanted, you can save it as a command afterward. If Claude Code highlights the word when you didn’t mean to trigger one, press `alt+w` to ignore it for this prompt. + +### + +​ + +Let Claude decide with ultracode + +Ultracode is a Claude Code setting that combines `xhigh` [reasoning effort](</docs/en/model-config#adjust-effort-level>) with automatic workflow orchestration. With it on, Claude plans a workflow for each substantive task instead of waiting for you to ask. + + /effort ultracode + +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](</docs/en/model-config#adjust-effort-level>); 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](</docs/en/permission-modes>): + +Permission mode| When you’re prompted +---|--- +Default, accept edits| Every run, unless you’ve selected **Yes, and don’t ask again** for that workflow in this project +Auto| First launch only. Any **Yes** records consent in your user settings, and later launches start without prompting. Skipped entirely when ultracode is on +Bypass permissions, `claude -p`, Agent SDK| Never. The run starts immediately + +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](</docs/en/settings#permission-settings>), 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 + +Press Enter to save. The workflow runs as `/<name>` in future sessions from either location. If a project workflow and a personal workflow share a name, the project one runs. + +## + +​ + +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. 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: + +Constraint| Why +---|--- +No mid-run user input| Only agent permission prompts can pause a run. For sign-off between stages, run each stage as its own workflow +No direct filesystem or shell access from the workflow itself| Agents read, write, and run commands. The script coordinates the agents +Up to 16 concurrent agents, fewer on machines with limited CPU cores| Bounds local resource use +1,000 agents total per run| Prevents runaway loops + +## + +​ + +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. 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. You can stop a running workflow from `/workflows` at any time without losing completed work. Every agent in a workflow uses your session’s model unless the script routes a stage to a different one. To control the model cost: + + * Check `/model` before 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 + +### + +​ + +Turn workflows off + +Workflows are available in the CLI, the Desktop app, the IDE extensions, [non-interactive mode](</docs/en/headless>) with `claude -p`, and the [Agent SDK](</docs/en/agent-sdk/overview>). 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": true` in `~/.claude/settings.json`. Persists across sessions. + * Set `CLAUDE_CODE_DISABLE_WORKFLOWS=1`. Read at startup, so it applies wherever you set it. + +To turn workflows off for your whole organization, set `"disableWorkflows": true` in [managed settings](</docs/en/server-managed-settings>), or use the toggle on the [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>) page. When workflows are disabled, the bundled workflow commands are unavailable, the `workflow` keyword no longer triggers a run, and `ultracode` is removed from the `/effort` menu. + +## + +​ + +Related resources + + * [Run agents in parallel](</docs/en/agents>): compare subagents, agent view, agent teams, and workflows + * [Create custom subagents](</docs/en/sub-agents>): the worker primitive workflows orchestrate + * [Manage costs](</docs/en/costs>): how multi-agent runs count toward usage limits