Skip to main content
Back

pi-subagents Lets Developers Orchestrate AI Coding Agents With Plain JavaScript

pi-subagents adds a code mode that lets you orchestrate Pi child agents with plain JavaScript — loops, fan-out, branching, and git worktree isolation all in one script

Repo, Full Access
  • Code mode launched: pi-subagents now lets you orchestrate Pi child agents with plain JavaScript — loops, fan-out, and branching on real child output.
  • Git worktree isolation: Each parallel child agent gets its own git worktree, preventing file conflicts when multiple agents write code simultaneously.
  • 8 built-in agents: scout, researcher, planner, worker, reviewer, context-builder, oracle, and delegate — each with its own tool allowlist and model defaults.
  • Model tiering: Route agents to different models by task shape — cheap models for recon, reasoning models for planning, intent-focused models for ambiguous work.
  • Opt-in watchdog: An adversarial reviewer that checks every repo edit at turn boundaries, flags scope drift, and runs TypeScript language-server diagnostics automatically.
  • Free and open source: MIT license, ~188K downloads/month, installs with pi install npm:pi-subagents, works with any Pi-supported model provider.

pi-subagents, the most popular multi-agent extension for the Pi coding agent, just shipped code mode: write plain JavaScript to orchestrate subagents, loop, fan out, await results, and branch on real child output, all in one script. Author Nico Bailon summarized it directly: "Orchestrate subagents with plain JavaScript: loop, fan out, await, branch on real child output."

What Pi is

Pi is a minimal, hackable terminal harness for building AI coding agent workflows. You customize it with extensions, skills, prompt templates, and themes. Features like subagents and plan mode are deliberately left to the package ecosystem. The repo is written entirely in TypeScript and ships as npm packages. Pi normalizes across OpenAI, Anthropic, Google, and other providers at the API layer, so you can switch models without re-learning the tool. pi-subagents fills the multi-agent gap and has grown to nearly 3,000 GitHub stars.

The problem with single-agent workflows

A single AI prompt rarely captures the full complexity of a large feature. The agent juggles high-level planning and granular code edits in one context window, which leads to regression errors, lost context, and architectural drift across turns. pi-subagents addresses this by turning Pi into an orchestrator of specialized child sessions, each with a narrow job and its own context. Code mode adds programmatic control over that orchestration flow.

JavaScript as the orchestration layer

The existing natural-language and slash-command interface still works as before. Code mode is an additive layer for when you need dynamic, data-driven orchestration that a static chain file cannot express. The existing .chain.md format is declarative and fixed; code mode lets you mix parallel and sequential phases, loop until a condition is met, and branch on what a child agent actually returns: