◉CLAUDE LABJP
●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…
Articles/Claude Code
⟐ Claude Code/2026-05-30Advanced

Authoring Dynamic Workflows: Building Reusable Research Pipelines with phase / agent / pipeline

A hands-on guide to writing your own Claude Code Dynamic Workflows: the phase / agent / pipeline / parallel primitives, locking outputs with JSON Schema, porting the adversarial-verification pattern, and designing for token cost.

Claude Code264Dynamic Workflowsubagents11orchestration7

✦ Premium Article

Run the built-in /deep-research once and the next question is obvious: can I write the same structure for my own task? In my case, I had been hand-routing two things to subagents every time, background research for four technical blogs and the quality check on the articles I generate. Freezing that into a script is what pushed me into authoring my own.

This guide takes the script you can read via View raw script on /deep-research, breaks down the orchestration primitives one by one, and lands on porting them into a real fact-checking pipeline. I covered how to run and save workflows in what I learned about orchestrating subagents, so here I focus on the writing side.

Why moving the plan into code raises reliability

When you spawn subagents turn by turn, Claude decides the next move on the spot. That's flexible, but it offers no guarantee that running the same task twice takes the same steps. A workflow holds the loop, branching, and intermediate results in the script, so the orchestration itself becomes reproducible.

More importantly, you can have independent agents adversarially review each other's results, or weigh plans drafted from several angles. A more trustworthy result comes not from the number of agents but from having this "cross-check" structure. That verification structure is exactly what I wanted when I decided to turn fact-checking into a workflow.

The five primitives a workflow is built from

The key to reading a script is these five.

  • meta: an export declaring the workflow's name, description, and phase list
  • phase("name"): a marker that segments the progress view, one per /workflows row
  • agent(prompt, options): launches one subagent; pass label, schema, and phase in options
  • pipeline(items, stage1, stage2, ...): staged processing that feeds each stage's output into the next
  • parallel([fn, fn, ...]): runs an array of functions concurrently

The minimal shape looks like this. Script arguments arrive in args, and log() records progress.

export const meta = {
  name: "article-fact-check",
  description: "Extract claims from an article and keep the ones that survive",
  phases: [
    { title: "Extract", detail: "Pull checkable claims from the body" },
    { title: "Verify", detail: "Verify each claim with a 3-vote scheme" },
    { title: "Report", detail: "Synthesize the surviving claims" },
  ],
};
 
phase("Extract");
const ARTICLE = (typeof args === "string" && args.trim()) || "";
if (!ARTICLE) {
  return { error: "Pass the article path via args" };
}

Whatever you list in meta.phases shows up in the pre-launch approval dialog as "how this will run." It's an explanation to the reader (you, approving it), so it's worth writing carefully.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Anyone who was calling subagents by hand can now write a reproducible script with phase / agent / pipeline
✦You'll be able to lock each phase's output with JSON Schema so downstream stages don't break
✦You can port the 3-vote adversarial verification pattern into your own fact-checking or research tasks
✦You'll gain a model-routing rule of thumb that keeps token cost in check even at hundreds of agents
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⟐ Claude Code2026-09-25
The Week Opus 5.5 Became the Default, I Counted the Places I'd Left as Aliases
Claude Code 2.1.280 made Opus 5.5 the default Opus and moved Pro's default from Sonnet to Opus. Before touching a single setting, I checked three things: what the alias resolves to, whether a saved /effort carries over, and what $0.20 cache reads do to a monthly estimate. Scripts included.
⟐ Claude Code2026-09-22
Taking Inventory of Worktrees That Were Supposed to Be Gone
Isolated worktrees my subagents created were never folded away. Here is what I measured in git 2.34.1 about when remove succeeds, the branches that outlive the trees, the 12 MB per-tree difference, and how I decide who owns cleanup.
⟐ Claude Code2026-08-17
Now that forking is the default, review agents are the ones I still call by name
Subagent forking became the default, so delegated work now inherits the parent conversation. Work can inherit context. Judgment cannot. Here is how I declare that boundary in the repository and catch it drifting.