In the last lesson you chose a pattern. If the task needs many agents, double-checked findings or reruns, that is a .
What it is
A workflow is a JavaScript script that Claude writes for your task. The script runs in the background, and your session stays responsive. It launches itself and keeps their results in its own variables, and only the final result reaches the conversation. The script holds the plan, not Claude.
Since the plan is code, you can:
- read it before it runs;
- make independent agents verify each other’s findings;
- save it and run it again as a
/<name>command.
On the Pro plan, workflows are off until you turn on the Dynamic workflows row in /config.
How to ask
Just say the word “workflow” in your request:
use a workflow to audit every file under src/ for errors that are caught and then ignored, and adversarially verify each finding before reporting it
There is also a built-in workflow, /deep-research — research with web search.
Before running, Claude Code shows the plan’s phases and asks: Yes, run it, View raw script or No. Choose View raw script or press Ctrl+G to open the script in your editor. In manual mode, Claude Code asks before every run — so you see every plan before it starts.
What a script looks like
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)
agent()launches one subagent;pipeline()launches one agent per item in a list;parallel()launches a set of agents at once;argsis the input you pass to a saved workflow.
The first statement is always export const meta: a plain object literal with name and description. If a variable, a function call or a spread gets in there, the /<name> command disappears from autocomplete.
The /workflows panel
While a workflow is running, type /workflows and pick the run:
| Key | What it does |
|---|---|
↑ ↓ | select a phase or an agent |
Enter | open a phase, then an agent: prompt, calls, result |
Esc | back |
p | pause and resume |
x | stop the run |
s | save the script |
When saving, Tab switches the location: .claude/workflows/ in the project is shared with everyone who clones the repository once you commit it; ~/.claude/workflows/ is yours alone, but in every project. From the next session, the saved script runs as /<name> and takes input, for example: Run /todo-audit on src.
The size of a run
/config workflowSizeGuideline=small
small asks Claude to plan as few agents as possible. The setting is stored in ~/.claude.json, not in the repository, and applies from the next request. It is guidance, not a limit. If a run grows large, a Large workflow warning appears in the progress line, but it neither pauses nor limits the run. To save money, start the session with --model sonnet: unless something else sets the model, workflow agents run on the session’s model.
A run stopped with x does not resume with p: ask Claude to rerun the same script.
Quick check
Claude offers to run a workflow it has just written. What do you do first?
Careful
In auto mode, Claude Code asks only before the very first workflow run: any “Yes” records consent in your user settings, and later runs start without a question. Workflow agents follow your permission rules, and in accept-edits, auto and bypass modes they run in the same mode. Read every script before approving it, and stay in manual for a workflow you have not read yet. A run can cost noticeably more than the same task in a conversation — try it on one small folder first.
Practice in the terminal