Use when running 2+ /prd-to-pr or /bug-to-pr pipelines simultaneously, when user says "run these in parallel", "batch these PRDs/bugs", "orchestrate these workflows", or has multiple work items to ship end-to-end concurrently
Coordinate multiple /prd-to-pr and /bug-to-pr pipelines running in parallel, each isolated in its own git worktree, with centralized gate management, observability, and confidence-based autonomous decision-making.
Core principle: Orchestrator stays on main. Workflows run in worktrees. Gates move forward — never stall. Decisions route by confidence. All 8 stages run every time.
Announce at start: "Using the workflow-orchestrator skill to coordinate N parallel pipelines."
/prd-to-pr or /bug-to-pr directly┌───────────────────────────────────┐
│ ORCHESTRATOR (you) │
│ • Lives on main branch │
│ • Foreground — user chats here │
│ • Monitors all workflows │
│ • Routes gate decisions │
│ • Renders status dashboard │
└─────────┬─────────┬───────────────┘
│ │
┌─────▼───┐ ┌───▼─────┐ ┌─────────┐
│ Agent 1 │ │ Agent 2 │ │ Agent 3 │
│ worktree│ │ worktree│ │ worktree│
│ prd-to- │ │ bug-to- │ │ prd-to- │
│ pr │ │ pr │ │ pr │
└─────────┘ └─────────┘ └─────────┘
digraph orchestrator {
rankdir=TB;
node [shape=box];
gather [label="1. Gather work items from user"];
classify [label="2. Classify each: PRD or bug?\nDetect scope (iOS/backend/infra)"];
conflict [label="3. Cross-workflow conflict scan\n(shared files, deploy deps)"];
dispatch [label="4. Dispatch each as background\nagent with worktree isolation"];
monitor [label="5. Enter monitoring loop\n(check tasks, render dashboard)"];
gate [label="Gate detected?" shape=diamond];
confidence [label="Confidence ≥ medium?" shape=diamond];
auto_resolve [label="Resolve autonomously\nvia SendMessage" style=filled fillcolor=lightgreen];
bubble [label="Bubble to user with\ncontext + recommendation" style=filled fillcolor=lightyellow];
prod [label="Production decision?" shape=diamond];
always_user [label="ALWAYS bubble to user" style=filled fillcolor=lightsalmon];
complete [label="Workflow completed?" shape=diamond];
merge [label="Merge in order:\nbugs first, then features"];
cleanup [label="Clean up worktrees\nRender final dashboard"];
gather -> classify -> conflict -> dispatch -> monitor;
monitor -> gate;
gate -> prod [label="yes"];
gate -> monitor [label="no — continue"];
prod -> always_user [label="yes"];
prod -> confidence [label="no"];
confidence -> auto_resolve [label="yes"];
confidence -> bubble [label="no"];
auto_resolve -> monitor;
bubble -> monitor;
always_user -> monitor;
monitor -> complete;
complete -> merge [label="all done"];
complete -> monitor [label="still running"];
merge -> cleanup;
}
Use AskUserQuestion if not already provided:
For each item, determine:
/prd-to-pr or /bug-to-prSCOPE_IOS, SCOPE_BACKEND, SCOPE_GCP_INFRA (or combinations)user-profile-sharing, fix-auth-race)Before dispatching, identify potential conflicts:
For each pair of workflows:
- Do they touch the same scope? (both backend, both iOS, etc.)
- Could they modify the same files? (startup files, shared services, migrations)
- Do they have deploy dependencies? (one requires the other's schema changes)
If shared file conflicts detected:
conflict-matrix task so it's visibleCreate one parent task per workflow, plus orchestrator tasks:
TaskCreate: "Orchestrator: Monitor all pipelines"
TaskCreate: "[WF-1] {slug-1} ({prd-to-pr|bug-to-pr}) — Stage 0/8"
TaskCreate: "[WF-2] {slug-2} ({prd-to-pr|bug-to-pr}) — Stage 0/8"
TaskCreate: "[WF-3] {slug-3} ({prd-to-pr|bug-to-pr}) — Stage 0/8"
For each workflow, dispatch using the Agent tool:
Agent(
name: "{slug}-pipeline",
description: "Run {prd-to-pr|bug-to-pr} for {slug}",
prompt: <see Dispatch Prompt Template below>,
isolation: "worktree",
run_in_background: true,
mode: "bypassPermissions"
)
CRITICAL: All workflows dispatch in a SINGLE message with multiple Agent tool calls. This ensures true parallelism. Do NOT dispatch sequentially.
Each workflow agent receives a comprehensive prompt containing:
A. Identity and Pipeline
You are a pipeline executor running {prd-to-pr|bug-to-pr} for: {work item description}
Your pipeline: ALL 8 STAGES ARE MANDATORY. No exceptions. No abbreviations.
B. The Full Pipeline Skill Content Include the complete prd-to-pr or bug-to-pr skill content so the agent has the full reference.
C. Work Item Details The PRD text, bug report, issue URL, or whatever the user provided.
D. Scope and Context
Detected scope: {SCOPE_IOS|SCOPE_BACKEND|SCOPE_GCP_INFRA}
Project CLAUDE.md is at: /path/to/CLAUDE.md (READ IT for build commands)
E. Task Reporting Protocol
TASK REPORTING (MANDATORY at every stage transition):
You have a parent task: {task_id}. Update it at EVERY stage transition:
TaskUpdate(taskId: "{task_id}", subject: "[WF-N] {slug} — Stage {N}/8: {stage_name}",
metadata: {
"stage": {N},
"stageName": "{stage_name}",
"stageStatus": "in_progress|completed|gate_blocked",
"needsDecision": false,
"decisionContext": null
}
)
When you need a decision you cannot make:
TaskUpdate(taskId: "{task_id}",
metadata: {
"stageStatus": "gate_blocked",
"needsDecision": true,
"decisionContext": "Clear description of what you need decided and why",
"decisionOptions": ["option_a description", "option_b description"]
}
)
Then CONTINUE working on other substeps if possible. Do NOT stop and wait.
F. Gate Autonomy Rules
GATE AUTONOMY — When to decide vs. when to flag:
AUTO-PROCEED (handle yourself):
- Stage 3 Counsel: verdict is APPROVED with no [ISSUE] findings → proceed
- Stage 3 Counsel: verdict is APPROVED with only [SUGGESTION] findings → proceed
- Stage 4 Build: failure with clear error → attempt fix (up to 3 times)
- Stage 6 Codex: timeout → fall back to Generate mode, output prompt
- Stage 7 Copilot: valid suggestions → apply them
- Stage 7 Copilot: no response after 2 min → proceed
- Stage 8 Deploy: dev environment → auto-approve
FLAG TO ORCHESTRATOR (update task with needsDecision: true):
- Stage 3 Counsel: REQUIRES_REWORK verdict
- Stage 3 Counsel: ROOT_CAUSE_REJECTED verdict
- Stage 3 Counsel: amendments that remove or change original requirements
- Stage 4 Build: 3+ consecutive failures
- Stage 7 Copilot: suggestion contradicts requirements
- Stage 8 Deploy: staging environment approval
- Stage 8 Deploy: production environment approval
- Stage 8 Deploy: ANY production failure
- Any error not in the pipeline's error handling table
- Discovery of a different root cause than planned (bug-to-pr only)
G. Cross-Workflow Constraints (if applicable)
SHARED FILE CONSTRAINTS:
- You do NOT own: {list of files owned by other workflows}
- If you need to modify a shared file: APPEND to END only
- Never modify files outside your ownership matrix
H. Strict Adherence Mandate
THE IRON LAW: ALL 8 STAGES RUN EVERY TIME.
If your context compresses mid-pipeline:
1. Read your parent task metadata to find your current stage
2. Read the spec folder artifacts to confirm what stages completed
3. Resume from the next incomplete substep
4. NEVER skip forward. NEVER abbreviate a stage.
Context compression is NOT a shortcut. It is a recovery event.
Red flags — if you think any of these, STOP:
- "This is simple enough to skip counsel" → NO. Run counsel.
- "Simplification isn't needed for this small change" → NO. Run /simplify.
- "Copilot review can be skipped" → NO. Check for review.
- "I already know the root cause, skip analysis" → NO. Write the analysis.
After dispatching all workflows, the orchestrator enters its primary role: monitoring, deciding, and communicating.
You will be automatically notified when background agents complete. Between notifications:
needsDecision: true or gate_blocked states.Render this dashboard when:
╔══════════════════════════════════════════════════════════════════╗
║ Workflow Orchestrator — {N} Active Pipelines ║
╠══════════════════════════════════════════════════════════════════╣
║ ║
║ [1] {slug-1} ({pipeline-type}) ║
║ Stage {N}/8: {stage_name} — {detail} ║
║ {✓1 ✓2 ✓3 →4 ○5 ○6 ○7 ○8} ║
║ ║
║ [2] {slug-2} ({pipeline-type}) ⚠ GATE ║
║ Stage {N}/8: {stage_name} — NEEDS DECISION ║
║ {✓1 ✓2 ⚠3 ○4 ○5 ○6 ○7 ○8} ║
║ Decision: {brief context} ║
║ ║
║ [3] {slug-3} ({pipeline-type}) ✅ DONE ║
║ Stage 8/8: Complete — PR #{N} merged, deployed to dev ║
║ {✓1 ✓2 ✓3 ✓4 ✓5 ✓6 ✓7 ✓8} ║
║ ║
╠══════════════════════════════════════════════════════════════════╣
║ Elapsed: {time} │ Gates resolved: {N} │ Pending decisions: {N} ║
╚══════════════════════════════════════════════════════════════════╝
Legend: ✓ = complete, → = in progress, ⚠ = gate blocked, ○ = pending, ✗ = failed
When a workflow reports needsDecision: true:
digraph gate_decision {
detect [label="Task has\nneedsDecision: true" shape=box];
read [label="Read decisionContext\nand decisionOptions"];
prod [label="Production\ndecision?" shape=diamond];
always_user [label="Present to user\nwith full context\nNO recommendation\n(user decides)" style=filled fillcolor=lightsalmon];
assess [label="Can I resolve this\nwith medium+\nconfidence?" shape=diamond];
auto [label="Resolve: SendMessage\nto workflow agent\nwith decision\n+ rationale" style=filled fillcolor=lightgreen];
recommend [label="Present to user\nwith context +\nmy recommendation" style=filled fillcolor=lightyellow];
log [label="Log decision in\norchestrator task"];
detect -> read -> prod;
prod -> always_user [label="yes"];
prod -> assess [label="no"];
assess -> auto [label="yes"];
assess -> recommend [label="no"];
auto -> log;
recommend -> log;
always_user -> log;
}
| Situation | Confidence | Action |
|---|---|---|
| Counsel APPROVED, no issues | High | Auto-proceed |
| Counsel APPROVED, suggestions only | High | Auto-proceed |
| Counsel REQUIRES_REWORK, technical issues only | Medium | Auto-approve amendments, SendMessage to proceed |
| Counsel REQUIRES_REWORK, requirement changes | Low | Bubble to user |
| Counsel ROOT_CAUSE_REJECTED | Low | Bubble to user — may need rethink |
| Build failure, error is clear (typo, import) | High | SendMessage fix instructions |
| Build failure, error is ambiguous | Medium | Attempt one fix suggestion, flag if fails |
| 3+ consecutive build failures | Low | Bubble to user — something structural |
| Codex review timeout | High | Auto-fallback to Generate mode |
| Copilot suggestion, straightforward fix | High | Auto-apply |
| Copilot suggestion, changes scope | Low | Bubble to user |
| Dev deploy approval | High | Auto-approve |
| Staging deploy approval | Medium | Recommend approval, bubble to user |
| Production deploy | N/A | ALWAYS bubble to user |
| Production failure | N/A | ALWAYS bubble to user |
When the user asks about a specific workflow:
SendMessage(to: "{slug}-pipeline", ...) to relayGates MUST NOT stall. This is the orchestrator's primary responsibility.
After each user interaction, sweep all workflow tasks:
For each workflow task:
if metadata.stageStatus == "gate_blocked" AND metadata.needsDecision == true:
→ How long has it been blocked?
→ Can I resolve it? (check confidence table)
→ If yes: resolve immediately
→ If no: surface to user NOW (not "later")
The 5-minute rule: If a gate has been blocked for >5 minutes without action, the orchestrator MUST surface it in the next response to the user, regardless of what the user asked about.
Never say: "I'll get back to that." Gates are the #1 priority.
When workflows complete, merge in this order:
For each merge:
If multiple workflows deploy to the same environment:
After all workflows complete:
╔══════════════════════════════════════════════════════════════════╗
║ Workflow Orchestrator — COMPLETE ║
╠══════════════════════════════════════════════════════════════════╣
║ ║
║ [1] {slug-1} ✅ Shipped ║
║ PR #{N} → merged → deployed to {env} ║
║ Stages: ✓1 ✓2 ✓3 ✓4 ✓5 ✓6 ✓7 ✓8 ║
║ ║
║ [2] {slug-2} ✅ Shipped ║
║ PR #{N} → merged → deployed to {env} ║
║ Stages: ✓1 ✓2 ✓3 ✓4 ✓5 ✓6 ✓7 ✓8 ║
║ ║
║ [3] {slug-3} ⚠ Needs Attention ║
║ Stalled at Stage 4 — 3+ build failures ║
║ Worktree: {path} (preserved for inspection) ║
║ Stages: ✓1 ✓2 ✓3 ✗4 ○5 ○6 ○7 ○8 ║
║ ║
╠══════════════════════════════════════════════════════════════════╣
║ Total: {N} shipped, {N} need attention ║
║ Gates resolved autonomously: {N} ║
║ Gates escalated to user: {N} ║
║ Elapsed: {time} ║
╚══════════════════════════════════════════════════════════════════╝
If YOUR (the orchestrator's) context compresses:
TaskList immediately — task metadata is your state recovery mechanismstage, stageName, stageStatus, needsDecisionneedsDecision: true gates — handle them firstDo NOT re-dispatch running workflows. Background agents survive orchestrator context compression. Just recover your awareness of their state.
A workflow agent that stops updating its task metadata may be:
Detection: If a workflow's task metadata hasn't changed in >10 minutes AND the agent hasn't completed:
SendMessage(to: "{slug}-pipeline", "Status check: what stage are you on?")Prevention: The dispatch prompt (section E) mandates task updates at EVERY stage transition. This is the safety net.
The user may say: "Skip counsel for this one" or "We don't need Codex review" or "Just deploy it."
Response protocol:
"skippedStages": [3]The rule is: stages are mandatory BY DEFAULT. Only the user can override, and only after hearing the risk. You (the orchestrator) may never skip a stage on your own authority.
CRITICAL: Workflow agents are background subagents. They cannot invoke /prd-to-pr or /bug-to-pr as skills. The Skill tool is not available to subagents.
You MUST include the full pipeline skill content in the dispatch prompt. Read the relevant skill file and embed it:
For prd-to-pr workflows:
Read ~/.claude/skills/prd-to-pr/SKILL.md
Include full content in dispatch prompt
For bug-to-pr workflows:
Read ~/.claude/skills/bug-to-pr/SKILL.md
Include full content in dispatch prompt
This is non-negotiable. A workflow agent without the full pipeline definition will improvise — and improvisation means skipped stages.
User may say "add another PRD to the batch" while workflows are running.
If a completed workflow's output seems wrong (e.g., PR is empty, deploy failed silently):
git log, git diff main...HEAD in the worktree| Error | Recovery |
|---|---|
| Workflow agent dies mid-pipeline | Check task metadata for last stage. Re-dispatch from that stage with isolation: "worktree" pointing to existing worktree if possible |
| Worktree creation fails | Check for stale worktrees (git worktree list), clean up, retry |
| Two workflows conflict on shared file | Serialize: pause lower-priority workflow until higher-priority merges |
| User disappears during gate decision | Continue resolving auto-approvable gates. Queue user-required decisions. Surface all when user returns |
| Context compression mid-orchestration | Re-read task list to rebuild state. Task metadata is the source of truth |
| Merge conflicts between workflows | Resolve in the later workflow's worktree. Re-verify builds. Then merge |
| Workflow claims stage complete but artifact missing | Reject completion. SendMessage to workflow with "Stage X artifact not found at {path}. Re-run stage X" |
| All workflows hit gates simultaneously | Prioritize: production > staging > dev. Resolve highest-risk gate first |
| Thought | Reality |
|---|---|
| "This workflow is simple, skip counsel" | ALL stages mandatory. No exceptions. The skill says so 4 times. |
| "I'll handle this gate later" | Gates are #1 priority. Handle NOW or surface NOW. 5-minute rule. |
| "Let me run these one at a time" | That's not orchestration. Dispatch ALL in parallel in ONE message. |
| "The user doesn't need to know about this" | If confidence < medium, ALWAYS surface it. |
| "I can approve this for production" | Production decisions ALWAYS go to user. No exceptions. |
| "Context is getting long, skip status updates" | Observability is non-negotiable. Render the dashboard. |
| "These workflows don't need worktrees" | NOTHING touches main except the orchestrator. Every workflow gets a worktree. |
| "I'll just work on main and branch later" | Worktree isolation happens at dispatch time. Not "later." |
| "One workflow finished, I can clean up later" | Merge ordering matters. Follow the protocol. |
| "This gate decision is obvious" | Check the confidence table. "Obvious" gates have caused production outages. |
Delegates to (via workflow agents):
/prd-to-pr — Full 8-stage PRD-to-PR pipeline/bug-to-pr — Full 8-stage bug-to-PR pipelineUses:
Agent tool with isolation: "worktree" and run_in_background: trueSendMessage for communicating decisions to running workflowsTaskCreate/TaskUpdate/TaskGet/TaskList for state tracking and observabilityPairs with:
/triage — Can be used upstream to classify work items before orchestrationsuperpowers:dispatching-parallel-agents — Complementary pattern for non-pipeline parallel work| Action | How |
|---|---|
| Start orchestration | Gather items → classify → conflict scan → dispatch all in one message |
| Check status | TaskList → read metadata → render dashboard |
| Resolve gate | Check confidence table → SendMessage or bubble to user |
| Talk to workflow | SendMessage(to: "{slug}-pipeline", ...) |
| Cancel workflow | Discuss with user → update task status |
| Handle completion | Merge in order → verify health → cleanup worktrees |