Skip to content

Dynamic Workflows

A dynamic workflow is a JavaScript script that orchestrates subagents at scale. Claude writes the script for the task you describe, and a runtime executes it in the background while your session stays responsive. Use workflows when a task needs more agents than one conversation can coordinate, a codebase-wide bug sweep, a 500-file migration, or a research question that needs sources cross-checked.

Owl mascot

What you'll learn

  • Workflows move the orchestration plan into code, the script holds the loop, branching, and intermediate results
  • ultracode keyword triggers a workflow; /effort ultracode makes Claude write one for every substantive task
  • The bundled /deep-research workflow fans out web searches, cross-checks sources, and returns a cited report

The problem

Subagents handle a few delegated tasks per turn. But some tasks need dozens of agents working simultaneously, auditing 500 files, cross-checking 20 sources against each other, or generating a plan from five independent angles. Subagents flood your context. Workflows keep the orchestration in a script and return only the final answer.

Options & when to use each

ToolScaleOrchestratorRepeatable
SubagentsA few per turnClaude, turn by turnWorker definitions
Agent teamsHandful of peersLead agentTeam definitions
WorkflowsDozens to hundredsJavaScript scriptFull orchestration is replayable

Build it

Step 1: Run a bundled workflow

You can invoke predefined workflows directly from the CLI using the slash command syntax. The /deep-research workflow, for example, orchestrates parallel web searches and source cross-checking to synthesize a comprehensive report.

bash
claude
# /deep-research What changed in the Node.js permission model between v20 and v22?

Claude Code runs agents through web search, source fetching, cross-checking, and synthesis. Watch progress with /workflows.

Step 2: Trigger a workflow with ultracode

ultracode: audit every API endpoint under src/routes/ for missing auth checks

The keyword tells Claude to write a workflow script instead of working turn by turn. Or set it globally:

/effort ultracode

Now Claude writes a workflow for every substantive task.

Step 3: Watch workflow progress

Use the /workflows command to monitor background tasks in real time. This interactive dashboard displays active phases, agent token consumption, and provides controls to pause or terminate execution.

bash
/workflows

The view shows each phase with agent counts, token totals, and elapsed time. Controls:

KeyAction
Enter / →Drill into phase, then into agent
Esc / ←Back out
pPause/resume
xStop agent or workflow
sSave script as a command

Step 4: Save a workflow as a reusable command

After a successful run, press s in the workflow view. The script saves as a command you can invoke with /command-name.

Step 5: Set a size guideline

Open /config and set "Dynamic workflow size" to small (fewer than 5 agents), medium (fewer than 15), large (fewer than 50), or unrestricted (default).

What goes wrong

MistakeHow you notice itThe fix
ultracode keyword not triggeringPrompt runs as normal, no workflow startsThe keyword only works on typed prompts in interactive sessions, not -p mode, not CI, not scheduled tasks. Use "use a workflow" phrasing
Workflow exceeds rate limitsAgents start getting 429 errorsReduce the size guideline in /config, or set --max-budget-usd
Workflow agents all use the expensive modelCost is higher than expectedSet CLAUDE_CODE_SUBAGENT_MODEL to haiku for cheaper agents, or specify model in the task description

Confirm it worked

Launch Claude Code and initiate a small workflow to observe the orchestration in action. Monitor the job via the /workflows interface and wait for the synthesized report to ensure all agents completed their tasks.

bash
# 1. Start Claude Code
claude

# 2. Run a small workflow
# /deep-research What are the key features of Claude Code v2?

# 3. Watch progress with /workflows
# Press Enter on the run to see phases and agents

# 4. When it finishes, you should see a cited report

Next: Agent SDK