Claude Code–style dynamic workflows for Pi

Turn one prompt into a fleet of subagents.

A Pi extension that writes a JavaScript orchestration script on the fly, fans your task across many isolated subagents in parallel, has them cross-check each other, and hands back one synthesized answer.

pi install npm:@quintinshaw/pi-dynamic-workflows

Journaled resume · real per-agent cost accounting · git-worktree isolation

Get started Star on GitHub v2.0.0 · MIT

Also on npm · Pi package

A workflow fanning a task out across subagents in Pi and streaming live progress
Plain-language ask → generated workflow → live, streaming fan-out across subagents, all in the background.

Quickstart

Three steps from install to your first fan-out.

  1. Install & reload.
    pi install npm:@quintinshaw/pi-dynamic-workflows
    # then in Pi:
    /reload
  2. Ask for a workflow in plain language. Pi writes the script and runs it in the background; a live panel tracks progress.
    Run a workflow to audit every route under src/routes/ for missing auth checks.
  3. Or write one yourself. A workflow is plain JavaScript — orchestrate subagents with agent(), parallel(), phase():
    export const meta = {
      name: 'auth_audit',
      description: 'Find routes missing auth checks and verify the findings',
      phases: [{ title: 'Scan' }, { title: 'Review' }, { title: 'Verify' }],
    }
    
    phase('Scan')
    const files = await agent('List every route file under src/routes/.', { tier: 'small' })
    
    phase('Review')
    const findings = await parallel(
      files.split('\n').filter(Boolean).map((file) =>
        () => agent(`Audit ${file} for missing auth checks.`, { tier: 'medium', isolation: 'worktree' }),
      ),
    )
    
    phase('Verify')
    return await agent('Synthesize and double-check:\n' + findings.join('\n\n'), { tier: 'big' })

What you get

Code-mode subagents — plus the parts a real run needs: journaled resume, git-worktree isolation, real cost accounting, and per-agent model routing.

Fan-out orchestration

agent(), parallel(), pipeline(), phase() in a sandboxed script. Up to 16 concurrent / 1000 total subagents; results stay in variables, not the chat.

Real model routing

small / medium / big tiers (or an exact model) per agent. It actually switches the subagent's model — cheap work light, hard synthesis big.

Journaled resume

An interrupted run replays finished agents from a journal (no re-run, no tokens) and runs only what's left or what you changed. Survives restarts.

Git worktree isolation

isolation: "worktree" gives an agent its own branch, so parallel agents edit the same files without clobbering each other.

Real cost accounting

Token and dollar cost read from each subagent's session, not estimated. budget gates on the real total; /workflows shows the spend.

Background by default

The turn ends immediately; a live task panel tracks each run and the result auto-continues the conversation when it lands.

Interactive /workflows TUI

Drill runs → phases → agents → detail. Pause, stop, restart, and save runs from the keyboard; each agent shows the model it ran on.

Quality-pattern stdlib

Built-in verify(), judgePanel(), loopUntilDry(), and completenessCheck() for adversarial review, best-of-N, and exhaustive discovery.

Ultracode

/ultracode is a standing opt-in that auto-arms an exhaustive workflow for every substantive message.

Deep research, built in

/deep-research and /adversarial-review: real web search, source cross-checking, skeptic-vetted findings, and cited reports.

Ultracode

A standing, maximal-effort opt-in: turn it on once and every substantive message fans out.

Each message you send auto-arms an exhaustive multi-agent workflow: wide fan-out, more reviewers and judges, deeper discovery loops, a completeness check at the end, and big-tier synthesis. No need to type "workflow" each time.

/ultracode          # on — auto-arm an exhaustive workflow for every substantive message
/ultracode off      # back to normal
/effort high|ultra  # finer control (high = thorough, ultra = ultracode)

Each tier maps to real, runtime-enforced ceilings — token budget and agent caps — plus guidance that widens fan-out, so a higher tier actually does more work.

Commands

Installed alongside the workflow tool after /reload.

/workflows
Open the interactive navigator (plain list in print mode).
/workflows status <id>
Watch a run live; print its result when it finishes.
/workflows save <name>
Save the latest run's script as a reusable /<name> command.
/workflows pause|resume|stop|rm <id>
Manage a run.
/workflows-models
Map the small / medium / big tiers to real models.
/ultracode [off]
Ultracode: auto-arm an exhaustive workflow for every substantive message.
/effort off|high|ultra
Finer control over the standing opt-in.
/deep-research <question>
Web-researched, source-cross-checked report.
/adversarial-review <task>
Findings vetted by skeptical reviewers.

How it maps to Claude Code dynamic workflows

The same model — on Pi, with any provider you're authenticated for.

Claude Code dynamic workflowspi-dynamic-workflows (on Pi)
Code-mode orchestration — the model writes a script that drives subagentsA JS workflow tool running agent() / parallel() / pipeline() / phase() in a vm sandbox
Subagents with isolated contextFresh in-memory Pi sessions; results held in script variables, not the chat
Structured outputsJSON-Schema schema → a validated object, with bounded repair if the model misses
Background runsNon-blocking by default, a live task panel, and auto-continue delivery
ResumeJournaled + replayable — survives restarts and replays the unchanged prefix
Ultracode/ultracode (or /effort ultra) — auto-arms an exhaustive workflow per substantive message
Model selectionPer-agent / per-phase routing across any provider Pi can reach
Git worktree isolation, real cost accounting, /deep-research, and a quality-pattern stdlib

FAQ

What is pi-dynamic-workflows?

A Pi extension that brings Claude Code–style dynamic workflows to Pi. Instead of one model working step by step, Pi writes a JavaScript orchestration script that fans a task out across many isolated subagents in parallel, holds the intermediate work in script variables, and returns only the synthesized result.

Does it work with any model?

Yes. It runs on whatever providers and models Pi is authenticated for, and routes each subagent to a small, medium, or big tier (or an exact model) so cheap work goes to a light model and hard synthesis to a big one.

What is ultracode?

Ultracode is a standing opt-in: type /ultracode and every substantive message auto-arms an exhaustive multi-agent workflow, the way Claude Code's ultracode does. /effort high is the lighter tier, and /ultracode off turns it back off.

Can an interrupted run resume?

Yes. Runs are journaled. A resumed run replays the completed, unchanged agents from the journal (no re-run, no tokens) and only runs what's left or what you changed. The journal survives restarts.

How is it different from running subagents by hand?

The orchestration is code, not chat: fan-out, ordering, and synthesis live in a deterministic script, intermediate results stay out of your context window, and the whole run is journaled so it can resume, show real cost, and be saved as a reusable command.

How do I install it?

Run pi install npm:@quintinshaw/pi-dynamic-workflows and then /reload in Pi. You get the workflow tool plus the /workflows, /ultracode, /deep-research, and /adversarial-review commands.