You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: claude-code-docs/workflows.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,6 +180,81 @@ The following prompt runs a saved workflow with a list of issue numbers:
180
180
181
181
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.
182
182
183
+
## Example workflow prompts
184
+
185
+
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.
186
+
187
+
### Audit many files for the same issue
188
+
189
+
Fan out one agent per file, then collect and verify the findings.
190
+
191
+
```text
192
+
> use a workflow to audit every route handler under src/routes/ for missing authentication checks, and adversarially verify each finding before reporting it
193
+
```
194
+
195
+
### Keep fixing until a check passes
196
+
197
+
Run a checker, fix what failed, and repeat until it passes or stops making progress.
198
+
199
+
```text
200
+
> 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
201
+
```
202
+
203
+
### Migrate many files in parallel
204
+
205
+
Discover the files to migrate, transform each one in an isolated copy so edits don't conflict, and verify each result.
206
+
207
+
```text
208
+
> use a workflow to migrate every component under src/components/ from styled-components to Tailwind, working on each file in its own isolated copy
209
+
```
210
+
211
+
### Review every changed file and write one summary
212
+
213
+
Run a reviewer per file, then hand all the findings to one agent that ranks and deduplicates them.
214
+
215
+
```text
216
+
> use a workflow to review every file changed in this PR for correctness issues, then merge the per-file findings into one ranked summary
217
+
```
218
+
219
+
### Research a topic across many sources
220
+
221
+
Fan out readers across changelogs, issues, and docs, then synthesize. The bundled `/deep-research` workflow does this; you can also describe a narrower version.
222
+
223
+
```text
224
+
> 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
225
+
```
226
+
227
+
### Find issues until the list stops growing
228
+
229
+
Keep searching in rounds and stop when new rounds turn up nothing new.
230
+
231
+
```text
232
+
> 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
233
+
```
234
+
235
+
### What the saved script looks like
236
+
237
+
When 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:
238
+
239
+
```javascript
240
+
exportconstmeta= {
241
+
name:'audit-routes',
242
+
description:'Audit every route handler for missing auth checks',
243
+
}
244
+
245
+
constfound=awaitagent('List every .ts file under src/routes/.', {
agent(`Audit ${file} for missing authentication checks.`, { label: file }),
251
+
)
252
+
253
+
returnaudits.filter(Boolean)
254
+
```
255
+
256
+
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](/en/agent-sdk/typescript) for the full set of options.
257
+
183
258
## How a workflow runs
184
259
185
260
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.
0 commit comments