/claude-code-capability-primer:claude-code-dynamic-workflowsfrom claude-code-capability-primer
Use when a task is too big for one context — broad audits, multi-file migrations, multi-source research, or parallel multi-dimension review — and you want to fan out and orchestrate many subagents deterministically with the Workflow tool (requires ultracode / explicit opt-in).
Ships in claude-code-capability-primer. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The Workflow tool runs a deterministic JavaScript orchestration script that fans out subagents. You write the control flow (loops, conditionals, fan-out); the script spawns agents, collects structured results, and returns a synthesis. It runs in the background and notifies you on completion.
Reach for this when the structure of the work — not just its size — needs to be encoded: cover a wide surface in parallel, get independent perspectives before committing, or take on a job one context can't hold.
If it fits in one focused pass, don't reach for a workflow — use a single subagent or just do it.
The Workflow tool only fires when the user has explicitly opted into multi-agent orchestration: the ultracode effort/keyword is on, the user asked for a workflow / fan-out in their own words, or a skill's instructions tell you to call it. It can spawn dozens of agents and spend a lot of tokens, so do not invoke it for tasks the user didn't scope to that scale. When unsure, describe the workflow and rough cost and ask first.
Every script starts with a pure-literal meta block, then a body using the hooks:
export const meta = {
name: 'review-changes',
description: 'Review changed files across dimensions, verify each finding',
phases: [{ title: 'Review' }, { title: 'Verify' }],
}
const DIMENSIONS = [{ key: 'bugs', prompt: '...' }, { key: 'perf', prompt: '...' }]
const results = await pipeline(
DIMENSIONS,
d => agent(d.prompt, { label: `review:${d.key}`, phase: 'Review', schema: FINDINGS }),
review => parallel(review.findings.map(f => () =>
agent(`Adversarially verify: ${f.title}`, { phase: 'Verify', schema: VERDICT })
.then(v => ({ ...f, verdict: v })))),
)
return { confirmed: results.flat().filter(Boolean).filter(f => f.verdict?.isReal) }
agent(prompt, opts?) — spawn one subagent. With schema (JSON Schema) it returns a validated object (the agent is forced to emit structured output); without, it returns its final text. Opts: label, phase, schema, model, isolation: 'worktree', agentType (e.g. 'Explore', 'claude-code-guide', a custom agent). Returns null if the agent dies/skips — .filter(Boolean).pipeline(items, stage1, stage2, ...) — the default. Each item flows through all stages independently, NO barrier between stages (item A can be in stage 3 while B is still in stage 1). Wall-clock = slowest single chain. Each stage gets (prevResult, originalItem, index).parallel(thunks) — run thunks concurrently and await all (a barrier). Use only when stage N genuinely needs ALL of stage N-1 (dedup/merge across the full set, early-exit on zero, cross-item comparison). A thunk that throws resolves to null.phase(title) / log(msg) — progress grouping + a narrator line for the user.workflow(name|{scriptPath}, args) — run another workflow inline (nesting is one level only).budget — { total, spent(), remaining() }: the turn's token target (or total: null). Gate dynamic loops on budget.total && budget.remaining() > N.args — the value you passed as the tool's args (pass real JSON, not a stringified blob).Default to pipeline(). A parallel() barrier between stages is justified ONLY when stage N needs cross-item context from all of N-1. "I need to flatten/map/filter first" is NOT a reason — do that inside a stage: pipeline(items, stageA, r => transform([r]).flat(), stageB). A barrier where the slowest item is 3x the fastest wastes the fast items' idle time.
log() what was dropped.min(16, cores - 2) per workflow; excess queues. Lifetime cap 1000 agents; ≤4096 items per parallel/pipeline call.Date.now() / Math.random() / argless new Date() are unavailable (they break resume) — pass timestamps via args, vary by index for randomness.schema for anything structured.{scriptPath}. Resume a paused/edited run with {scriptPath, resumeFromRunId} — unchanged agent() calls return cached results instantly.model to inherit the session model (usually correct); only override when a different tier clearly fits.For the orchestration primitive (one subagent at a time, model-driven control flow), see claude-code-subagents. For long-running async single tasks, see claude-code-background-agents.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
12 skills in this plugin
/claude-code-agent-sdkUse when building custom AI agents headlessly, embedding Claude Code tools in an app, or running scripted/cron agents—need SDK package names, setup, core API entry points, supported languages, and relation to Claude Code CLI and Messages.../claude-code-background-agentsUse when needing to understand or manage background agents, long-running tasks, polling, scheduling, or async work in Claude Code without blocking the session./claude-code-capabilitiesUse when unsure which Claude Code capability fits a task, when about to single-thread large/cross-cutting/repetitive work, or when you or the user ask what Claude Code can do — loads the full capability map (signal → capability) and points to the deep-dive skills./claude-code-checkpointingUse when you need to undo code edits, explore alternatives without losing a starting point, recover from a bad edit path, or restore previous conversation state — press Esc Esc or run /rewind to open checkpoints menu./claude-code-effort-modelsUse when deciding how to work on a task - choosing effort level, model, or fast mode to balance reasoning depth, speed, and token cost./claude-code-github-actionsUse when setting up or debugging Claude Code GitHub Actions automation, or deciding whether to route CI/CD tasks to GitHub Actions vs local session.npx claudepluginhub ucsandman/claude-code-capability-primer --plugin claude-code-capability-primer