Advanced 2 concepts to know first

Dynamic Workflows

A JavaScript script Claude writes to orchestrate dozens of subagents at once and cross-check their results, run in the background and saved as a command you can rerun.

The animation needs JavaScript; every step is described below.

0:15

Know these first

2 concepts · basics first
  1. Context

    The context window is everything Claude can see in a session: your messages, the files it reads, tool output and auto-loaded instructions. It fills as you work, and Claude Code compacts it when it gets full.

  2. Subagents

    Helpers Claude hands a side task to. Each works in its own fresh context window with its own prompt and tools, and only its summary comes back.

  3. Dynamic Workflows · you are here

With subagents, Claude is the orchestrator: it decides turn by turn what to spawn next, and every result lands in its context. That works for a few delegated tasks. It strains when a job needs fifty agents, or when you want findings checked against each other rather than taken on trust.

A dynamic workflow moves the plan into code. Claude writes a JavaScript script for your task, and a runtime executes it in the background while your session stays responsive. The script holds the loop, the branching and the intermediate results in its own variables, so Claude’s context receives only the final answer.

What the script looks like

export const meta = { name: 'audit-routes', description: 'Check each route for an auth check' }
 
const list = { type: 'object', properties: { files: { type: 'array', items: { type: 'string' } } } }
const found = await agent('List the route files under src/routes/.', { schema: list })
const audits = await pipeline(found.files, (file) => agent(`Does ${file} check auth?`))
return audits.filter(Boolean)

agent() spawns one subagent, pipeline() runs one per item in a list, and parallel() runs a set at once. Because the orchestration is code, it can apply a quality pattern, such as having independent agents adversarially review each other’s findings before anything is reported.

How you start one

Ask for it (“use a workflow to…”), or put the keyword ultracode in your prompt. /effort ultracode goes further: Claude plans a workflow for every substantive task in the session. To see one first, run the bundled /deep-research <question>. Before a run starts, Claude Code shows its planned phases for approval (how often depends on your permission mode).

/workflows lists runs and opens a progress view of each phase and agent. Press s there to save a run’s script to .claude/workflows/ (shared with the repo) or ~/.claude/workflows/ (just you), and it runs as /<name> from then on, like a skill that holds a process instead of instructions.

The catch

Cost. A run spawns many agents and can use far more tokens than doing the task in conversation. Try it on one directory before the whole repo; Claude Code flags a Large workflow past 25 agents or a projected 1.5 million tokens.

Limits. No input from you mid-run, and the script itself can’t touch files or the shell; its agents do that, under your usual permission rules. Up to 16 agents run at once by default, and 1,000 per run. A stopped run can be resumed in the same session.

Workflows are on for paid plans; on Pro, switch them on under Dynamic workflows in /config.

Where it sits

Before this

Subagents
Dynamic Workflows

Leads to

Nothing yet.

The ideas underneath · Field Guide

Further reading from claude.dev

Posts from Anthropic's developer blog that go deeper. Summaries are ours; the posts are Anthropic's.

Sources

  1. Orchestrate subagents at scale with dynamic workflows . Claude Code docs: ultracode, the script API, /workflows, saving, limits and cost
  2. Run agents in parallel . Claude Code docs: how workflows compare to subagents, agent view and agent teams

Verified against the official Claude Code docs on October 1, 2026 · next review by January 1, 2027. Claude Code changes quickly; the docs are the source of truth.