---
name: orchid
description: "Modular orchestration pipeline — 9-phase workflow for multi-agent development. Investigate → Decompose → Launch → Converge → Review → Cleanup. Each phase is a composable sub-skill with its own agents, Ralph loops, and dependencies. Triggers on 'pipeline', 'orchestration', 'orchid', 'decompose and launch', 'run the pipeline', 'start a sprint', 'run the orchid'. Always run orchid-doctor first."
---

# orchid — Orchestration Identification Pipeline

**Version**: 2.0.0 (modular — sub-skills)
**Role**: Orchestrator/PM meta-skill
**Depends on**: See DEPENDENCIES section below.

## ⛔ Orchestrator Identity (Non-Negotiable)

```
You DO NOT implement. You DO NOT edit code files.
You investigate, document, decompose, delegate, and review.
```

| ✅ Your Job | ❌ NOT Your Job |
|------------|----------------|
| Read code, understand architecture | Write `.rs`, `.ts`, `.py` files |
| Create GH EPIC + sub-issues | Debug compiler errors yourself |
| Author `.ralph/` task files for lanes | Refactor code yourself |
| Launch lane agents via `subagent()` dispatch | Fix failing tests yourself |
| Wire `lib.rs` module declarations at convergence | Implement features yourself |
| Run `cargo check && cargo test` to verify convergence | Write unit tests yourself |
| Review lane output, request revisions | Make code changes beyond wiring |

**Exception**: 1-2 line config edits (`lib.rs` module declarations, `Cargo.toml` dep additions) are allowed when wiring convergence.

## ⛔ Delegation Rules (Non-Negotiable)

### subagent() — Internal Work (USE THIS)

For ALL coding, investigation, review, and testing delegation:

```javascript
subagent({
  agent: "worker",
  task: "Implement X...",
  async: true,
  skill: "ms-rust"        // project-specific skills injected here
})
```

### interactive_shell — External Eval ONLY (DO NOT USE for work)

`interactive_shell` is PROHIBITED for any implementation, debugging, review, or testing task.
It is EXCLUSIVELY for launching external coding agent CLIs for evaluation/benchmarking:

```javascript
interactive_shell({ command: 'claude "Review the diffs"', mode: "dispatch" })
```

| Dimension | subagent() | interactive_shell |
|-----------|-----------|-------------------|
| Token cost | One agent | Two agents (you + child) |
| Model control | Explicit per-task | Whatever pi launches with |
| Context | Clean fork | TUI overlay burns context |
| Progress | Structured output | Must poll/parse terminal |
| Parallelism | Unlimited async | One per terminal tab |
| Chaining | chain/parallel support | Manual glue |
| Skills | Inject per-task | Inherit from parent |

## Model Policy

1. **Default**: Omit `model` param → subagent inherits orchestrator's model
2. **User-specified**: Use exactly what the user requested
3. **Ask if needed**: If user wants cost optimization, ask which model for workers
4. **Agent-defined**: `.agents/*.md` files already declare model preferences — respect those

**NEVER hardcode a model.** The model decision belongs to the user or the agent definition.

## Pipeline Phases

```
PHASE 1-2: INVESTIGATE + DOCUMENT  →  orchid-investigate
     ↓
PHASE 3-5: ISSUES + DECOMPOSE + .ralph/ FILES  →  orchid-decompose
     ↓
PHASE 6: LAUNCH LANES  →  orchid-launch
     ↓
PHASE 7-8: CONVERGE + REVIEW  →  orchid-converge
     ↓
PHASE 9: GAP CLOSURE + CLEANUP  →  orchid-cleanup
```

**Before starting ANY phase — run orchid-doctor.**

## Decision Trees

### Which phase to load when?

```
User says "start pipeline" or "orchestrate X"
  │
  ├─→ Is this the first time? → orchid-doctor → orchid-investigate
  │
  ├─→ Do you have an investigation doc but no lanes? → orchid-decompose
  │
  ├─→ Do you have .ralph/ lane files but no running agents? → orchid-launch
  │
  ├─→ Are lanes running but reporting done? → orchid-converge
  │
  └─→ Is convergence done but review found issues? → orchid-cleanup
```

### What to do when a phase fails?

```
Phase fails
  │
  ├─→ Doctor fails → Fix missing deps. Do NOT proceed.
  │
  ├─→ Investigate fails → Likely permission or access issue. Check git/gh.
  │
  ├─→ Decompose fails → Lane overlap detected. Re-do ownership matrix.
  │
  ├─→ Launch fails → Subagent API down. Retry after 2 min. If persistent, implement directly as last resort.
  │
  ├─→ Converge fails → Build broken after merge. Identify which lane caused it. Send back to that lane's worker.
  │
  └─→ Cleanup fails → Gaps too large for single pass. Write additional lane file, re-launch.
```

### When to abort vs recover?

| Situation | Action |
|-----------|--------|
| 1-2 lanes failed, rest green | Re-launch failed lanes only |
| Build broken at convergence | Send specific fix task to offending lane's worker |
| All lanes failed | Abort. Re-investigate. Root cause is likely in decomposition. |
| Subagent API down >10 min | Abort. Queue for retry when API recovers. |
| User requests stop | Abort gracefully. Archive .ralph/ state for resume. |
| Reviewer finds critical issues | Do NOT proceed. Send fix task, re-review. |
| Reviewer finds minor issues | Proceed to cleanup, include fixes in gap-closure. |

## Sub-Skills

| Sub-Skill | Phases | Primary Agent | Ralph Loop | Input | Output |
|-----------|--------|---------------|------------|-------|--------|
| `orchid-doctor` | Pre-flight | (orchestrator) | No | Project directory | ✅/⚠️/❌ health report |
| `orchid-investigate` | 1-2 | scout, researcher | No (one-shot) | Project directory, GH repo | Architecture map, tracking doc, gap list |
| `orchid-decompose` | 3-5 | planner | No (one-shot) | Tracking doc, gap list | EPIC + issues, .ralph/ lane files |
| `orchid-launch` | 6 | worker, dev-1 | Yes (per lane) | .ralph/ lane files | Running subagents, commit SHAs |
| `orchid-converge` | 7-8 | reviewer, tester | No | Commit SHAs, changed files | Green build, review report |
| `orchid-cleanup` | 9 | worker | Yes (gap closure) | Review report, gap list | Clean repo, closed EPIC |

## Dependencies

### Required Agents

| Agent | Role | Used By | Model Default |
|-------|------|---------|---------------|
| scout | Codebase recon | orchid-investigate | (inherit) |
| researcher | Web research | orchid-investigate | (inherit) |
| planner | Implementation planning | orchid-decompose | (inherit) |
| worker | Implementation execution | orchid-launch, orchid-cleanup | (inherit) |
| dev-1 | Focused coding | orchid-launch | (inherit) |
| reviewer | Code review | orchid-converge | (inherit) |
| tester | Test verification | orchid-converge | (inherit) |
| brain | Architecture reasoning | Escalation | (inherit) |
| delegate | Lightweight passthrough | Simple tasks | (inherit) |

### Required Skills

| Skill | Source | Version | Used By |
|-------|--------|---------|---------|
| pi-ralph-wiggum | npm (@tmustier) | ≥0.2.0 | orchid-launch, orchid-cleanup |
| pi-subagents | npm | ≥0.25.0 | orchid-launch (all delegation) |
| create-taskplane-task | npm (taskplane) | ≥0.30.0 | orchid-decompose |
| multi-lane-orchestration | local | — | orchid-decompose, orchid-launch |

### Project-Specific Skills (auto-detected)

| Skill | When | Detection | Source |
|-------|------|-----------|--------|
| ms-rust | Rust projects | `Cargo.toml` present | ~/.pi/agent/skills/ms-rust-guidelines |
| rustic-prompt | Rust projects | `Cargo.toml` present | ~/.pi/agent/skills/rustic-prompt |

### Required Tools

| Tool | Check | Required By | Fallback |
|------|-------|-------------|----------|
| git | `git --version` | All phases | None — mandatory |
| gh | `gh auth status` | orchid-decompose | Create issues manually |
| cargo | `cargo --version` | Rust projects | None — mandatory for Rust |
| Telepathine bus | `agent_memory_telepath_list()` | orchid-launch, orchid-converge | Coordinate via git commits |

## Quick-Start

```
1. /skill orchid-doctor        ← Verify all deps
2. /skill orchid-investigate   ← Scout the codebase
3. /skill orchid-decompose     ← Plan lanes + write .ralph/ files
4. /skill orchid-launch        ← Fire lane agents
5. /skill orchid-converge      ← Merge + review
6. /skill orchid-cleanup       ← Close gaps + archive
```

## Real-World Example: RustAPI Pilot (May 2026)

The patterns in OrchID were proven on the RustAPI project — a Go→Rust API gateway rewrite:

- **3 parallel lanes** closed 26 issues in a single session
- Lane 1: Clippy cleanup + E2E tests (12 tests)
- Lane 2: Provider auth hardening
- Lane 3: Claude SSE format conversion
- Full reviewer gate with clippy verification and Go→Rust fidelity audits
- Build was green at convergence with zero conflicts (file ownership matrix worked)

**What worked**: Parallel dispatch with zero file overlap, Telepath coordination, reviewer gates.
**What failed**: Initial attempt without ownership matrix caused merge conflicts; re-do with matrix resolved it.
**Key lesson**: The file ownership matrix is not optional. It is the law.
