From rune
Decomposes complex tasks spanning 5+ files or 3+ modules into up to 3 parallel workstreams using git worktrees, assigns to isolated agents, coordinates merging, and verifies with integration tests.
npx claudepluginhub rune-kit/rune --plugin @rune/analyticsThis skill uses the workspace's default tool permissions.
Meta-orchestrator for complex tasks requiring parallel workstreams. Team decomposes large features into independent subtasks, assigns each to an isolated cook instance (using git worktrees), coordinates progress, and merges results. Uses opus for strategic decomposition and conflict resolution.
Spawns parallel agent implementers in tmux split panes to execute implementation plans, orchestrated by team lead with spec compliance and code quality review gates. For 3+ independent tasks across files.
Orchestrates N parallel tasks: generates plans with cross-task file conflict analysis, deploys implementation swarms in waves using Agent Teams. Requires CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1.
Orchestrates multi-agent teams to decompose complex tasks, select optimal sub-agents like Explore or Plan, and execute parallel work across domains such as frontend and backend.
Share bugs, ideas, or general feedback.
Meta-orchestrator for complex tasks requiring parallel workstreams. Team decomposes large features into independent subtasks, assigns each to an isolated cook instance (using git worktrees), coordinates progress, and merges results. Uses opus for strategic decomposition and conflict resolution.
- MAX 3 PARALLEL AGENTS: Never launch more than 3 Task calls simultaneously. If more than 3 streams exist, batch them. - No merge without conflict resolution complete (Phase 3 clean). - Full integration tests MUST run before reporting success./rune team <task> — manual invocation for large featuresIF streams ≤ 2 AND total files ≤ 5:
→ LITE MODE (lightweight parallel, no worktrees)
ELSE:
→ FULL MODE (worktree isolation, opus coordination)
For small parallel tasks that don't warrant full worktree isolation:
Lite Mode Rules:
- Max 2 parallel agents (haiku coordination, sonnet workers)
- NO worktree creation — agents work on same branch
- File ownership still enforced (disjoint file sets)
- Simplified merge: sequential git add (no merge conflicts possible with disjoint files)
- Skip Phase 3 (COORDINATE) — no conflicts with disjoint files
- Skip integrity-check — small scope, direct output review
- Coordinator model: haiku (not opus) — saves cost
Lite Mode Phases:
Phase 1: DECOMPOSE (haiku) — identify 2 streams with disjoint files
Phase 2: ASSIGN — launch 2 parallel Task agents (sonnet, no worktree)
Phase 4: MERGE — sequential git add (no merge needed)
Phase 5: VERIFY — integration tests on result
Announce mode: "Team lite mode: 2 streams, ≤5 files, no worktrees needed." Override: User can say "full mode" to force worktree isolation.
Standard team workflow with worktree isolation (Phases 1-5 as documented below).
Before decomposing, classify the task into a complexity tier. Each tier defines a different DAG (directed acyclic graph) of stages, ensuring the right amount of process for the task's complexity.
| Tier | Signals | DAG Stages | Context Windows |
|---|---|---|---|
| Trivial | ≤3 files, single module, no shared contracts | impl → test | 1 (single cook) |
| Medium | 4-10 files, 2-3 modules, shared interfaces | research → plan → impl → test → review → fix | 3 (plan, impl+test, review+fix) |
| Large | 10+ files, 3+ modules, breaking changes or RFC | research → plan → impl → test → review₁ → fix → review₂ → final merge | 4+ (plan, impl+test, review₁+fix, review₂+merge) |
Key principle — reviewer isolation: The agent that writes code MUST NOT review its own code. Each review stage uses a separate context window (separate Task invocation) that has never seen the implementation reasoning. This prevents author bias from contaminating the review.
Stage → Context Window mapping:
research + plan = Context Window 1 (opus — architectural reasoning)impl + test = Context Window 2 (sonnet — code writing)review₁ + fix = Context Window 3 (sonnet — fresh eyes, no impl context)review₂ + merge = Context Window 4 (sonnet — final verification, Large tier only)Merge queue: When multiple streams complete at different times, use dependency order for merging. If a later stream's merge creates conflicts with an already-merged stream, provide the conflicting stream's cook report as conflict context to the resolution agent — never resolve blindly.
plan (L2): high-level task decomposition into independent workstreamsscout (L2): understand full project scope and module boundariescook (L1): delegate feature tasks to parallel instances (worktree isolation)launch (L1): delegate deployment/marketing when build is completerescue (L1): delegate legacy refactoring when rescue work detectedintegrity-check (L3): verify cook report integrity before mergecompletion-gate (L3): validate workstream completion claims against evidenceconstraint-check (L3): audit HARD-GATE compliance across parallel streamsscope-guard (L3): pre-merge scope verification — validate each stream's actual file changes against declared ownershipworktree (L3): create isolated worktrees for parallel cook instancescontext-pack (L3): create structured handoff briefings before spawning subagentsscaffold (L1): decompose scaffolding into parallel workstreams/rune team <task> direct invocation onlyTodoWrite([
{ content: "DECOMPOSE: Scout modules and plan workstreams", status: "pending", activeForm: "Decomposing task into workstreams" },
{ content: "ASSIGN: Launch parallel cook agents in worktrees", status: "pending", activeForm: "Assigning streams to cook agents" },
{ content: "COORDINATE: Monitor streams, resolve conflicts", status: "pending", activeForm: "Coordinating parallel streams" },
{ content: "MERGE: Merge worktrees back to main", status: "pending", activeForm: "Merging worktrees to main" },
{ content: "VERIFY: Run integration tests on merged result", status: "pending", activeForm: "Verifying integration" }
])
Mark todo[0] in_progress.
1a. Map module boundaries.
REQUIRED SUB-SKILL: rune:scout
→ Invoke `scout` with the full task description.
→ Scout returns: module list, file ownership map, dependency graph.
→ Capture: which modules are independent vs. coupled.
1b. Break into workstreams.
REQUIRED SUB-SKILL: rune:plan
→ Invoke `plan` with scout output + task description.
→ Plan returns: ordered list of workstreams, each with:
- stream_id: "A" | "B" | "C" (max 3)
- task: specific sub-task description
- files: list of files this stream owns
- depends_on: [] | ["B"] (empty = parallel-safe)
1c. Validate decomposition.
GATE CHECK — before proceeding:
[ ] Each stream owns disjoint file sets (no overlap)
[ ] No coupled modules across streams:
→ Use Grep to find import/require statements in each stream's owned files
→ If stream A files import from stream B files → flag as COUPLED
→ COUPLED modules MUST be moved to same stream OR stream B added to A's depends_on
[ ] Dependent streams have explicit depends_on declared
[ ] Total streams ≤ 3
[ ] Change Stacking check: no file appears in touches[] of 2+ parallel streams
[ ] Every stream's requires[] is satisfied by a prior stream's provides[] or existing code
If any check fails → re-invoke plan with conflict notes.
1d. Question Gate (non-trivial tasks only).
From superpowers (obra/superpowers, 84k★): "Subagents that start work without asking questions produce the wrong thing 40% of the time."
Before dispatching streams, include in each NEXUS Handoff: "Before starting, ask up to 3 clarifying questions if anything is unclear about scope, conventions, or expected output."
Mark todo[0] completed.
Mark todo[1] in_progress.
2a. Launch parallel streams.
Launch independent streams (depends_on: []) in parallel using Task tool with worktree isolation.
From agency-agents (msitarzewski/agency-agents, 50.8k★): "Structured handoff docs prevent the #1 multi-agent failure: context loss between agents."
Each stream receives a NEXUS Handoff Template — not a bare prompt:
For each stream where depends_on == []:
Task(
subagent_type: "general-purpose",
model: "sonnet",
isolation: "worktree",
prompt: <NEXUS Handoff below>
)
NEXUS Handoff Template (sent to each cook instance):
## NEXUS Handoff: Stream [id]
### Metadata
- Stream: [id] of [total]
- Depends on: [none | stream ids]
- File ownership: [list — ONLY these files may be modified]
- Model: sonnet
### Context
- Project: [project name and type]
- Overall goal: [1-line feature description]
- This stream's goal: [specific sub-task]
- Conventions: [key patterns from scout — naming, file structure, test framework]
### Deliverable
- [ ] [specific outcome 1 — e.g., "AuthService with login/register/reset methods"]
- [ ] [specific outcome 2 — e.g., "Unit tests covering happy path + 3 error cases"]
- [ ] [specific outcome 3 — e.g., "Types exported for Phase 2 consumers"]
### Quality Expectations
- Tests: must pass with evidence (stdout captured)
- Types: no `any`, strict mode
- Security: no hardcoded secrets, parameterized queries
- Conventions: [project-specific — from scout output]
### Evidence Required
Return a Cook Report with:
- Exact files modified (git diff --stat)
- Test output (stdout — not just "tests pass")
- Any CONCERNS discovered during implementation
2b. Launch dependent streams sequentially.
For each stream where depends_on != []:
WAIT for all depends_on streams to complete.
Then launch with NEXUS Handoff that includes:
- Completed stream's deliverables as "Available Context"
- Exported interfaces/types from prior streams in "Code Contracts" section
- Any CONCERNS from prior streams in "Known Issues" section
2b.5. Pre-merge scope verification.
After each stream completes (before collecting final report):
Bash: git diff --name-only main...[worktree-branch]
→ Compare actual modified files vs stream's planned file ownership list.
→ If agent modified files OUTSIDE its declared scope:
FLAG: "Stream [id] modified [file] outside its scope."
Present to user for approval before proceeding to merge.
→ If all files within scope: proceed normally.
This catches scope creep BEFORE merge — much cheaper to fix than after.
2c. Collect cook reports.
Wait for all Task calls to return. Store each cook report keyed by stream_id.
Error recovery:
If a Task fails or returns error report:
→ Log failure: "Stream [id] failed: [error]"
→ If stream is non-blocking: continue with other streams
→ If stream is blocking (others depend on it): STOP, report to user with partial results
Mark todo[1] completed.
Mark todo[2] in_progress.
3a-pre0. Output density honoring. During Phase 2 dispatch, any worker that hits context ORANGE / RED has emitted output.density.set with mode=caveman, scope=workstream (auto from rune:context-engine). Coordination output respects per-workstream density: when summarizing a caveman-active worker's report into the merge plan, preserve its terse format rather than re-expanding to verbose. If 3+ workers are caveman-active simultaneously, the team-level summary itself should adopt caveman until merge completes (announce to user once: "Team output in caveman mode — N workers under context pressure"). Reverts to normal after Phase 5.
3a-pre. Oracle reattach sweep. Before merge coordination, glob .rune/oracle-pending/*.json. For any worker stream that emitted oracle.dispatched during Phase 2, invoke session-bridge --reattach <sessionId>. Worker streams with status=pending past their timeoutAt are unblocked via oracle.failed so coordination can proceed. Workers with status=complete consume the response before merge.
3a. Check for file conflicts.
Bash: git diff --name-only [worktree-a-branch] [worktree-b-branch]
If overlapping files detected between completed worktrees:
3a.5. Verify cook report integrity.
REQUIRED SUB-SKILL: rune:integrity-check
→ Invoke integrity-check on each cook report text.
→ If any report returns TAINTED:
BLOCK this stream from merge.
Report: "Stream [id] cook report contains adversarial content."
→ If SUSPICIOUS: warn user, ask for confirmation before merge.
3b. Review cook report summaries.
For each completed stream, verify cook report contains:
Error recovery:
If cook report contains sentinel CRITICAL:
→ BLOCK this stream from merge
→ Report: "Stream [id] blocked: CRITICAL issue in [file] — [details]"
→ Present to user for decision before continuing
3c. Evaluate subagent status per stream.
Each cook instance MUST have returned one of four statuses. Team handles them as follows:
| Cook Status | Team Action |
|---|---|
DONE | Stream cleared for merge — proceed normally |
DONE_WITH_CONCERNS | Stream cleared for merge, BUT trigger cross-workstream review: check if the concern impacts any other stream's files or contracts before merging ALL streams. Log concern in Team Report. |
NEEDS_CONTEXT | Stream paused — present the specific question to user. Resume that stream after answer. Other independent streams may continue in parallel. |
BLOCKED | Stream blocked from merge. If stream has no dependents → continue with remaining streams and report partial completion. If stream has dependents → STOP all dependent streams, present to user with full blocker details. |
Cross-workstream review (triggered by any DONE_WITH_CONCERNS):
1. Read the concern from the cook report
2. Check if the concern touches shared contracts, interfaces, or shared files
→ Use Grep to find the concern's affected symbols/files across all worktrees
3. If concern is isolated to stream's own files → proceed to merge (concern logged only)
4. If concern crosses stream boundaries → resolve before merge:
→ Present to user with: affected streams, concern details, two remediation options
→ Do NOT merge any stream until user decides
Mark todo[2] completed.
Mark todo[3] in_progress.
4a. Merge each worktree sequentially.
# Bookmark before any merge
Bash: git tag pre-team-merge
For each stream in dependency order (independent first, dependent last):
Bash: git checkout main
Bash: git merge --no-ff [worktree-branch] -m "merge: stream [id] — [stream.task]"
If merge conflict:
Bash: git status (identify conflicting files)
If ≤3 conflicting files:
→ Resolve using cook report guidance (stream's intended change wins)
Bash: git add [resolved-files]
Bash: git merge --continue
If >3 conflicting files OR ambiguous ownership:
→ STOP merge
Bash: git merge --abort
→ Present to user: "Stream [id] has [N] conflicts. Manual resolution required."
4b. Cleanup worktrees.
Bash: git worktree remove [worktree-path] --force
(Repeat for each worktree after its branch is merged.)
Mark todo[3] completed.
Mark todo[4] in_progress.
REQUIRED SUB-SKILL: rune:verification
→ Invoke `verification` on the merged main branch.
→ verification runs: type check, lint, unit tests, integration tests.
→ Capture: passed count, failed count, coverage %.
Error recovery:
If verification fails after merge:
→ Rollback all merges:
Bash: git reset --hard pre-team-merge
Bash: git tag -d pre-team-merge
Report: "Integration tests failed. All merges reverted to pre-team-merge state."
→ Present fix options to user
Mark todo[4] completed.
| Gate | Requires | If Missing |
|---|---|---|
| Scope Gate | Each agent has explicit file ownership list | Define boundaries before dispatch |
| Conflict Gate | Zero merge conflicts after integration | Resolve all conflicts, re-verify |
| Verification Gate | All tests pass after merge | Fix regressions before completion |
## Team Report: [Task Name]
- **Streams**: [count]
- **Status**: complete | partial | blocked
- **Duration**: [time across streams]
### Streams
| Stream | Task | Status | Deliverables | Concerns |
|--------|------|--------|-------------|----------|
| A | [task] | DONE | 3/3 delivered | None |
| B | [task] | DONE_WITH_CONCERNS | 2/2 delivered | Perf regression on large input |
| C | [task] | DONE | 2/2 delivered | None |
### Acceptance Criteria
| # | Criterion | Stream | Evidence | Verdict |
|---|-----------|--------|----------|---------|
| 1 | Auth endpoints return JWT | A | Test stdout: "3 passed" | PASS |
| 2 | No SQL injection | A | Sentinel: PASS | PASS |
| 3 | Dashboard loads < 2s | B | No perf test run | UNVERIFIED |
### Integration
- Merge conflicts: [count]
- Integration tests: [passed]/[total]
- Coverage: [%]
- Unresolved concerns: [count — from DONE_WITH_CONCERNS streams]
Independent streams → PARALLEL (max 3 sonnet agents)
Dependent streams → SEQUENTIAL (respecting dependency order)
All streams done → MERGE sequentially (avoid conflicts)
| Artifact | Format | Location |
|---|---|---|
| Workstream assignments | Markdown (inline) | NEXUS Handoff Templates emitted per stream |
| Cook Reports (per stream) | Markdown (inline) | Collected from each parallel cook instance |
| Merged implementation | Source files | main branch after Phase 4 merge |
| Integration test results | Inline stdout | Captured in Phase 5 verify |
| Team Report | Markdown (inline) | Emitted at end of session |
| Scope | Access | Files |
|---|---|---|
| Owns (read + write) | .rune/team-report-*.md, worktree branches, merge commits | |
| Reads (never writes) | .rune/plan-*.md, .rune/contract.md, CLAUDE.md, cook reports from sub-agents | |
| Never modifies | Source files directly (delegates to cook instances), SKILL.md files, compiler/** |
Each cook instance owns its declared file set (disjoint). Team owns coordination artifacts only — never touches source code directly.
When the project is a monorepo (signals: pnpm-workspace.yaml, turbo.json, nx.json, or packages/ directory with multiple package.json):
Stream assignment rules for monorepos:
packages/api, Stream B = packages/web)packages/core consumed by both api + web) must be in a dependency stream that completes before consumer streams startturbo run test --filter=...[HEAD^1] in Phase 5 (VERIFY) to test only affected packages — do NOT run the full test suite when only 1 package changedDependency stream pattern for cross-package changes:
Stream A (depends_on: []): packages/core — shared types + utilities
Stream B (depends_on: ["A"]): packages/api — consumes updated core types
Stream C (depends_on: ["A"]): packages/web — consumes updated core types
B and C run in parallel after A completes.
Common multi-agent orchestration failures. These cause the most expensive rework in team workflows.
| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
| Overlapping file ownership — two agents write to the same file | Merge conflicts, lost work, non-deterministic output | Enforce disjoint touches[] per stream. Move shared files to a single owner |
| Blind merge — merging cook reports without reviewing them | Poisoned output propagates. One bad stream corrupts the whole feature | integrity-check + completion-gate on every cook report before merge |
| Over-parallelization — launching 5+ agents for a 3-file task | Context fragmentation, coordination overhead > implementation time | Auto-detect: ≤5 files → lite mode (max 2 agents). Full mode caps at 3 |
| Cross-domain implementation — one agent implements both frontend and backend | Domain expertise diluted. Agent makes shallow choices in unfamiliar territory | Split by domain. Frontend agent ≠ backend agent. Each gets domain context |
| Missing handoff context — bare prompt to cook instance without scope/conventions | Agent guesses project conventions, uses wrong patterns, produces inconsistent code | NEXUS Handoff Template: always include metadata, deliverables, conventions, quality expectations |
| Sequential when parallel is safe — running independent streams one by one | Wastes time. 3 independent streams × 5min = 15min sequential vs 5min parallel | Check dependency graph. Independent streams → parallel. Dependent → sequential |
Known failure modes for this skill. Check these before declaring done.
| Failure Mode | Severity | Mitigation |
|---|---|---|
| Launching more than 3 parallel agents (full mode) / 2 (lite mode) | CRITICAL | HARD-GATE blocks this — batch into ≤3 streams (full) or ≤2 (lite) |
| Using full mode with worktrees for ≤2 streams, ≤5 files | MEDIUM | Auto-detect triggers lite mode — saves opus cost and worktree overhead |
| Agents with overlapping file ownership | HIGH | Scope Gate: define disjoint file sets before dispatch — never leave overlap unresolved |
| Merging without running integration tests | HIGH | Verification Gate: integration tests on merged result are mandatory |
| Ignoring sentinel CRITICAL flag in agent cook report | HIGH | Stream blocked from merge — present to user before any merge action |
| Launching dependent streams before their dependencies complete | MEDIUM | Respect depends_on ordering — sequential after parallel, not parallel throughout |
| Coupled modules split across streams | HIGH | Dependency graph check in Phase 1c — move coupled files to same stream or add depends_on |
| Agent modified files outside declared scope | HIGH | Pre-merge scope verification in Phase 2b.5 — flag before merge, not after |
| Merge failure with no rollback path | HIGH | pre-team-merge tag created before merges — git reset --hard on failure |
| Poisoned cook report merged blindly | HIGH | Phase 3a.5 integrity-check on all cook reports before merge |
| Bare prompt to cook instance — no context, conventions, or scope boundary | HIGH | NEXUS Handoff Template: structured handoff with metadata, deliverables, quality expectations, and evidence requirements |
| Cook returns "done" with no acceptance criteria tracking | MEDIUM | Team Report includes Acceptance Criteria table with per-criterion evidence and PASS/FAIL/UNVERIFIED verdict |
| Subagent builds wrong thing due to ambiguous scope | HIGH | Question Gate (Step 1d): invite questions before work starts. Cost of answering 3 questions << cost of rebuilding 500 LOC |
| Parallel streams touch same files causing merge conflicts | HIGH | Change Stacking check in Step 1c: validate disjoint touches[] across all parallel streams |
~$0.20-0.50 per session. Opus for coordination. Most expensive orchestrator but handles largest tasks.
Scope guardrail: Do not invoke launch, rescue, or scaffold autonomously unless explicitly delegated by the parent agent.