192 192
193Claude 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.193Claude 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.
194 194
195## Example workflow prompts
196
197A 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.
198
199### Audit many files for the same issue
200
201Fan out one agent per file, then collect and verify the findings.
202
203```text theme={null}
204> use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it
205```
206
207### Keep fixing until a check passes
208
209Run a checker, fix what failed, and repeat until it passes or stops making progress.
210
211```text theme={null}
212> 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
213```
214
215### Migrate many files in parallel
216
217Discover the files to migrate, transform each one in an isolated copy so edits don't conflict, and verify each result.
218
219```text theme={null}
220> use a workflow to migrate every component under src/components/ from styled-components to Tailwind, working on each file in its own isolated copy
221```
222
223### Review every changed file and write one summary
224
225Run a reviewer per file, then hand all the findings to one agent that ranks and deduplicates them.
226
227```text theme={null}
228> use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary
229```
230
231### Research a topic across many sources
232
233Fan out readers across changelogs, issues, and docs, then synthesize. The bundled `/deep-research` workflow does this; you can also describe a narrower version.
234
235```text theme={null}
236> 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
237```
238
239### Find issues until the list stops growing
240
241Keep searching in rounds and stop when new rounds turn up nothing new.
242
243```text theme={null}
244> 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
245```
246
247### What the saved script looks like
248
249When you [save a workflow](#save-the-workflow-for-reuse), 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:
250
251```javascript theme={null}
252export const meta = {
253 name: 'audit-routes',
254 description: 'Audit every route handler for missing auth checks',
255}
256
257const found = await agent('List every .ts file under src/routes/.', {
258 schema: { type: 'object', required: ['files'], properties: { files: { type: 'array', items: { type: 'string' } } } },
259})
260
261const audits = await pipeline(found.files, file =>
262 agent(`Audit ${file} for missing authentication checks.`, { label: file }),
263)
264
265return audits.filter(Boolean)
266```
267
268The 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](/en/agent-sdk/typescript) for the full set of options.
269
195## How a workflow runs270## How a workflow runs
196 271
197The 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.272The 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.