Session-orchestrator wave-executor
git clone https://github.com/Kanevry/session-orchestrator
T=$(mktemp -d) && git clone --depth=1 https://github.com/Kanevry/session-orchestrator "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/wave-executor" ~/.claude/skills/kanevry-session-orchestrator-wave-executor && rm -rf "$T"
skills/wave-executor/SKILL.mdWave Executor Skill
Execution Model
You are the coordinator. You do NOT implement — you orchestrate. Your job:
- Dispatch subagents for each wave
- Wait for ALL agents in a wave to complete
- Review their outputs
- Adapt the plan if needed
- Dispatch the next wave
- Repeat until all waves complete
Design Philosophy
This harness exists to enable multi-agent coordination at scale — not by removing friction, but by making it visible, classifiable, and recoverable.
The wave-executor is process scaffolding around LLM agents. It handles task breakdown, scope enforcement, circuit breaker guards, and recovery patterns. Unlike direct chat with an agent, it trades flexibility for safety and repeatability across a bounded execution envelope.
Every harness creates friction. The goal is not minimum friction — it is useful friction that prevents higher-cost problems downstream.
Friction we accept:
- Wave planning overhead and
pre-dispatch setupwave-scope.json - Per-wave quality gates before proceeding
- Worktree isolation costs for parallel agents
- Turn-limit constraints that stop runaway agents early
Friction we prevent:
- Agent scope violations (PreToolUse hooks block out-of-scope file edits)
- Cascading failures (circuit breaker + spiral detection halt broken agents before they propagate damage)
- Silent partial completion (STATUS line requirement forces explicit reporting)
- Untracked carryover work (session-end plan verification catches unresolved tasks)
The harness does not hope agents self-correct. It detects stagnation patterns — pagination-spiral, turn-key-repetition, error-echo — classifies them into the Error-Class Taxonomy defined in
circuit-breaker.md, and re-scopes mechanically. Review logic lives in wave-loop.md § "Review Agent Outputs".
Platform Note
State files live in the platform's native directory:
for Claude Code,.claude/for Codex CLI,.codex/for Cursor IDE. All references to.cursor/below should use the platform's state directory. Shared metrics (sessions.jsonl, learnings.jsonl) live in.claude/— both platforms read and write there. See.orchestrator/metrics/for tool mappings.skills/_shared/platform-tools.md
Phase 0: Bootstrap Gate
Read
skills/_shared/bootstrap-gate.md and execute the gate check. If the gate is CLOSED, invoke skills/bootstrap/SKILL.md and wait for completion before proceeding. If the gate is OPEN, continue to the Pre-Execution Check.
<HARD-GATE> Do NOT proceed past Phase 0 if GATE_CLOSED. There is no bypass. Refer to `skills/_shared/bootstrap-gate.md` for the full HARD-GATE constraints. </HARD-GATE>Session-start only: This gate check runs ONCE at the start of
execution — before the first wave. It does NOT run before each wave step. Repeating the check per wave would add latency with no safety benefit, since/gois immutable within a session.bootstrap.lock
Pre-Execution Check
Before starting the first wave (Discovery role):
-
— ensure clean working directory (commit or stash if needed)git status --short -
Verify no parallel session conflicts (unexpected modified files)
-
Confirm the agreed plan is still valid (no new critical issues since planning)
-
Verify
is installed — runjq
. If not found, warn the user: "⚠ jq is not installed. Scope and command enforcement hooks will be DISABLED. Install jq (command -v jq
/brew install jq
) to enable security enforcement." Do NOT proceed with waves until user acknowledges.apt install jq -
Read Session Config: Parse Session Config per
. Store result asskills/_shared/config-reading.md
. Extract these fields:$CONFIG
(default: true),persistence
(default: warn),enforcement
(default: auto)isolation
(default: 6),agents-per-wave
(default: auto),max-turns
(default: null)pencil
Execution Config shortcut: If the session-plan output contains an
section, its execution-level fields (waves, agents-per-wave, isolation, enforcement, max-turns) take precedence over### Execution Config
. Session-level fields (persistence, pencil) always come from$CONFIG
. If the Execution Config section is missing, use$CONFIG
alone.$CONFIG -
Initialize session metrics (if
enabled): Prepare a metrics tracking object for this session:persistence
:session_id
(HHmm from<branch>-<YYYY-MM-DD>-<HHmm>
— ensures uniqueness across multiple sessions per day)started_at
: from Session Configsession_type
: ISO 8601 timestampstarted_at
: empty array (populated after each wave) This object lives in memory during execution — it is written to disk by session-end.waves
Pre-Execution: User Instructions
If the user provided additional instructions with
/go (e.g., /go focus on API endpoints), apply them as a priority modifier:
- Incorporate into agent prompts: Add a "Priority Focus:" section to each agent's prompt that includes the user's instructions verbatim
- Do NOT override the plan: User instructions adjust emphasis within the existing plan, they do not replace it. If the instructions conflict with the plan, note the conflict and follow the plan.
Example: If user said
/go focus on API endpoints, each agent prompt includes:
**Priority Focus (from user):** focus on API endpoints
Pre-Wave 1a: Capture Session Start Ref
Before dispatching Wave 1, capture the current commit as the session baseline:
SESSION_START_REF=$(git rev-parse HEAD)
Store this value for use throughout the session — it is needed by the simplification pass (Quality wave) and session-reviewer dispatch to determine which files changed during this session. Include it in the coordinator's context, NOT in individual agent prompts.
Pre-Wave 1b: Initialize STATE.md
Skip this section entirely if
.persistence: false
Before dispatching Wave 1, write
<state-dir>/STATE.md with YAML frontmatter and Markdown body:
--- schema-version: 1 session-type: feature|deep|housekeeping branch: <current branch> issues: [<issue numbers from plan>] started_at: <ISO 8601 timestamp with timezone> status: active current-wave: 0 total-waves: <from session plan> ---
## Current Wave Wave 0 — Initializing ## Wave History (none yet) ## Deviations (none yet)
Create the
<state-dir> directory if needed (mkdir -p <state-dir>) before writing. This file is the persistent state record — other skills and resumed sessions read it.
Ownership: STATE.md is owned by the wave-executor. Only the wave-executor writes to it (initialization + post-wave updates). session-end reads it for metrics extraction and sets
. session-start reads it only for continuity checks (Phase 0.5). No other skill should write to STATE.md.status: completed
Wave Execution Loop
Read and follow
wave-loop.md in this skill directory for the complete wave execution loop, including agent dispatch, output review, plan adaptation, progress updates, and scope manifest creation.
Circuit Breaker & Worktree Isolation
Reference: See
in this skill directory for MaxTurns enforcement, spiral detection, recovery protocol, and worktree isolation configuration. Apply those rules during every wave dispatch and post-wave review.circuit-breaker.md
Agent Prompt Best Practices
Each agent prompt MUST include:
- Clear scope boundary: "You are working on [X]. Do NOT modify files outside [paths]."
- Full context: file paths, current code structure, issue description
- Acceptance criteria: measurable definition of done
- Rule references: "Follow patterns in <state-dir>/rules/[relevant].md"
- Testing expectation: "Write tests for your changes" or "Run existing tests"
- Commit instruction: "Do NOT commit. The coordinator handles commits."
- Turn limit: Include the maxTurns instruction from
circuit-breaker.md
Each agent prompt MUST NOT include:
- References to other agents' tasks (isolation)
- Vague instructions like "improve" or "optimize" without specifics
- Assumptions about code state — provide the actual state
Session Type Behavior
Housekeeping Sessions
Housekeeping sessions use a simplified single-wave execution model instead of the multi-wave role-based dispatch:
- Initialize STATE.md as normal (
,session-type: housekeeping
)total-waves: 1 - Do NOT create
— scope enforcement is not needed for low-risk housekeeping taskswave-scope.json - Dispatch tasks serially with 1-2 agents per task
- Run Baseline quality checks after all tasks complete (not between tasks)
- Skip session-reviewer dispatch — housekeeping changes are low-risk
- Update STATE.md to
when donestatus: completed - Proceed directly to session-end (
)/close
Focus: git cleanup, SSOT refresh, CI fixes, branch merges, documentation. End with a single commit summarizing all housekeeping work.
Feature Sessions
- Full wave execution (5 roles mapped to configured wave count)
- 4-6 agents per wave (read from Session Config)
- Balance between implementation speed and quality
Deep Sessions
- Full wave execution (5 roles mapped to configured wave count)
- Up to 10-18 agents per wave (read from Session Config)
- Extra emphasis on Discovery role and Quality role
- May include security audits, performance profiling, architecture refactoring
Error Recovery
| Situation | Action |
|---|---|
| Agent times out | Re-dispatch with smaller scope |
| Agent produces broken code | Add fix task to next wave |
| Tests fail after wave | Diagnose in next wave, don't skip |
| Merge conflict between agents | Resolve manually, document |
| TypeScript errors introduced | Track count, run Full Gate per quality-gates by Quality wave |
| New critical issue discovered | Inform user, add to Impl-Polish+ roles if fits scope |
| Agent edits wrong files | Revert via git, re-dispatch with stricter scope |
Completion
After the Finalization wave completes successfully:
- Report final status to the user
- Suggest invoking
to finalize the session/close - Do NOT auto-commit —
handles that with proper verification/close
Anti-Patterns
- NEVER run
during waves — you lose coordination abilityrun_in_background: true - NEVER skip inter-wave review — quality degrades exponentially
- NEVER let agents commit independently — coordinator commits at session end
- NEVER continue to next wave if previous wave has unresolved failures
- NEVER dispatch more agents than configured in
agents-per-wave - NEVER let wave execution run without reporting progress to the user