alirezarezvani/claude-skills / engineering/workflow-builder/skills/workflow-builder
workflow-builder
VerifiedUse when writing or running a Claude Code Workflow-tool script (.js in .claude/workflows/) for fan-out, pipeline, loop or judge-panel sub-agents. Gathers intent with workflow_intake.py, scaffolds with scaffold_workflow.py and validates with validate_workflow.py.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 1.4 KB |
| SKILL.md | skill md | 5.2 KB |
| assets/examples/pr-triage.js | script | 3.5 KB |
| assets/templates/fan-out.js | script | 1.1 KB |
| assets/templates/loop-until-budget.js | script | 1.2 KB |
| assets/templates/pipeline.js | script | 1.2 KB |
| expected_outputs/intake_pr_review.json | config | 1.2 KB |
| expected_outputs/scaffold_pipeline.js | script | 1.2 KB |
| expected_outputs/validate_sample.txt | markdown | 555 B |
| references/api_reference.md | markdown | 6.3 KB |
| references/decision_and_intake_guide.md | markdown | 5.8 KB |
| references/orchestration_patterns.md | markdown | 5.4 KB |
| scripts/scaffold_workflow.py | script | 6.7 KB |
| scripts/validate_workflow.py | script | 10.7 KB |
| scripts/workflow_intake.py | script | 10.2 KB |
references/orchestration_patterns.md
View on GitHub# Orchestration Patterns
Copy-paste shapes for the common multi-agent topologies. Pick by answering the topology questions in [decision_and_intake_guide.md](decision_and_intake_guide.md), then adapt one of these.
## 1. Fan-out then synthesize
**When:** a known list of independent items, one pass each, and you need one combined answer at the end.
```js
const findings = await parallel(
questions.map((q, i) => () =>
agent(`Research and report verified facts:\n\n${q}`,
{ label: `q${i + 1}`, schema: RESEARCH_SCHEMA }))
)
const report = await agent(
`Synthesize these findings into one report:\n${JSON.stringify(findings.filter(Boolean))}`,
{ model: 'opus' }
)
```
## 2. Pipeline: stage then stage (no barrier)
**When:** items progress through ordered stages and each item should advance the instant it's ready, not wait for siblings.
```js
const results = await pipeline(
DIMENSIONS,
d => agent(d.prompt, { label: `review:${d.key}`, phase: 'Review', schema: FINDINGS_SCHEMA }),
review => parallel((review?.findings ?? []).map(f => () =>
agent(`Adversarially verify: ${f.title}`, { schema: VERDICT_SCHEMA })))
)
```
## 3. Barrier when you must dedup / merge first
**When:** the next stage needs the *entire* previous result set in hand — to dedup, merge, or early-exit on a count.
```js
const all = await parallel(DIMENSIONS.map(d => () => agent(d.prompt, { schema: FINDINGS_SCHEMA })))
const deduped = dedupeByFileAndLine(all.filter(Boolean).flatMap(r => r.findings))
const summary = await agent(`Summarize ${deduped.length} unique findings:\n${JSON.stringify(deduped)}`)
```
## 4. Loop until target count
**When:** discovery with a fixed goal ("find 10 bugs"). Always bound it.
```js
const bugs = []
while (bugs.length < 10 && bugs.length < 100 /* hard cap guard */) {
const r = await agent(
`Find bugs NOT already listed:\n${JSON.stringify(bugs)}`,
{ schema: BUGS_SCHEMA }
)
if (!r?.bugs?.length) break
bugs.push(...r.bugs)
}
```
## 5. Loop until budget runs low
**When:** depth should scale to the user's token target. The `budget` guard is essential.
```js
const issues = []
while (budget.total && budget.remaining() > 50_000) {
const r = await agent('Find one more issue not yet reported...', { schema: ISSUE_SCHEMA })
if (!r?.issues?.length) break
issues.push(...r.issues)
}
```
## 6. Adversarial verification (skeptic vote)
**When:** a finding will be acted on and a plausible-but-wrong one is costly. Findings survive on majority vote.
```js
const votes = await parallel(Array.from({ length: 3 }, (_, i) => () =>
agent(`Try hard to REFUTE this claim, return { refuted: boolean }:\n${claim}`,
{ label: `skeptic:${i + 1}`, schema: VERDICT_SCHEMA })))
const survives = votes.filter(v => v && !v.refuted).length >= 2
```
## 7. Judge panel
**When:** a wide solution space benefits from several independent attempts, scored and synthesized.
```js
const drafts = await parallel(ANGLES.map(a => () =>
agent(`Produce a plan. Take a strictly ${a} approach.`)))
const scored = await parallel(drafts.map((d, i) => () =>
agent(`Score this plan 1-10 with reasons:\n${d}`, { label: `judge:${i + 1}`, schema: SCORE_SCHEMA })))
const winner = drafts[scored.indexOf(scored.reduce((a, b) => (a?.score ?? 0) >= (b?.score ?? 0) ? a : b))]
const final = await agent(`Refine the winning plan:\n${winner}`, { model: 'opus' })
```
## 8. Loop until dry
**When:** unknown-size discovery that stops after K consecutive rounds with no new findings.
```js
const found = []
const seen = new Set()
let dryRounds = 0
while (dryRounds < 2 && found.length < 100) {
const r = await agent(`Find items not in:\n${JSON.stringify([...seen])}`, { schema: ITEMS_SCHEMA })
const fresh = (r?.items ?? []).filter(x => !seen.has(x.id))
fresh.forEach(x => seen.add(x.id))
found.push(...fresh)
dryRounds = fresh.length === 0 ? dryRounds + 1 : 0
}
```
## 9. Nested workflow
**When:** a self-contained sub-job lives inside a larger one (one level deep maximum).
```js
const research = await workflow('research-fanout', ['question one', 'question two'])
```
## Schema declarations
Schemas are plain JSON Schema objects defined as top-level `const`s and passed via `{ schema }`:
```js
const FINDINGS_SCHEMA = {
type: 'object',
properties: {
findings: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
severity: { type: 'string', enum: ['low', 'medium', 'high'] },
file: { type: 'string' }
},
required: ['title', 'severity']
}
}
},
required: ['findings']
}
```
Between stages, stringify structured data into the next prompt (`JSON.stringify(...)`); the schema only shapes what comes *back* from a single `agent()` call.
---
## Sources
1. Ray Amjad — `claude-code-workflow-creator`, `references/patterns.md` (fan-out, pipeline, judge-panel, loop shapes).
2. Anthropic — Claude Code Workflow tool documentation (`pipeline`/`parallel` semantics).
3. Anthropic — sub-agent orchestration patterns (Agent tool, fresh-context isolation).
4. Karpathy — LLM agent loop / file-optimization patterns (loop-until-dry analogue).
5. Google SRE Workbook — error budgets (loop-until-budget guard).
6. "LLM-as-a-judge" evaluation literature (judge-panel + scored synthesis).
7. Ensemble / majority-vote methods in ML (skeptic-vote verification).
8. JSON Schema specification — structured-output contract for the `schema` option.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |