plugins-claude/session/skills/session-orchestrate/SKILL.md
Multi-phase, multi-agent feature workflow: spec → plan → refine → divide → execute → review. Invoke when the user escalates a session-start/session-issue flow to orchestration, or asks to run a non-trivial feature (multiple files, design ambiguity, cross-cutting concerns, correctness-critical paths) through the full multi-agent workflow. For small fixes, prefer session-start.
npx skillsauth add st0nefish/claude-toolkit session-orchestrateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Run a complex feature through a structured multi-agent workflow with explicit model tiering, user gates, and an automated review pass. Use this when work is non-trivial — multiple files, design ambiguity, cross-cutting concerns, or correctness-critical paths. For small fixes, prefer /session:session-start directly.
The workflow has seven phases. Two have hard user gates (Refine and Execute). The build-and-verify half (Execute + Review) runs as a single deterministic Workflow call.
This skill is split across two execution surfaces, and the split is deliberate:
AskUserQuestion and talk to the user.Workflow — the Execute waves and the Review/blocker-auto-fix loop (scripts/orchestrate-build.workflow.js). This is a closed-loop machine — fan out by wave, escalate failures, review, re-dispatch blockers, re-review, cap the loop — with no human decision inside it. Expressing it as JS makes the control flow deterministic instead of something you have to police by hand.CRITICAL: You MUST drive every phase to completion. Do NOT collapse the workflow into a single in-line plan, and do NOT hand-roll the build loop in the main session — Phase 5 dispatches the
Workflowand Phase 6 consumes its structured result. Sub-agent dispatch is the point — the user is paying for parallelism and model tiering, not for you to do everything serially in the main session.
$ARGUMENTS — optional initial description. If empty and no context inherited from /session:session-start, ask the user to describe the feature before starting Phase 1./session:session-start's escalation, the branch is already created and the issue/description is known. Do not re-ask for a description.Before starting Phase 1, check whether prior phases of this workflow have already run on this branch:
Run bash ${CLAUDE_PLUGIN_ROOT}/scripts/catchup to gather branch state.
Inspect the most recent commit messages and any wip-, feat-, enhancement-, chore-, bug- branch names for evidence of prior work — recent commits referencing the spec/plan, or multiple commits since the default branch.
If any signal of prior orchestrate work is present, ask via AskUserQuestion:
Otherwise proceed to Phase 0b with a fresh run.
Orchestrate runs are heavy and long-lived — isolate them in a git worktree by default so the main checkout stays clean and parallel sessions can coexist.
/session:session-start's escalation, or the current branch is not the default), proceed in the current checkout. Do not create another worktree.<type>-<slug> from the issue (no number — that lives in the PR's Closes #N), or wip-<slug> from the description. Before creating, provision dependencies exactly as in /session:session-start Phase 2a (detect heavy gitignored dirs via git check-ignore; offer to write worktree.symlinkDirectories + .worktreeinclude to project config, asking first). Then call EnterWorktree with name: <dash-form-name> (yields branch worktree-<name>, provisions deps, switches the session in). Offer a one-key opt-out (work in place) via AskUserQuestion, but default to the worktree.Then proceed to Phase 1.
Goal: turn the user's description into a richer rough spec by dispatching cheap, parallel research agents.
Identify 2-4 distinct exploration angles based on the description. Common angles:
Dispatch all angles in parallel in a single message, using the Agent tool with:
subagent_type: research (read-only)model: haiku by defaultmodel: sonnet for an angle if: codebase is unfamiliar, the angle requires synthesizing patterns rather than locating code, or the description hints at subtle cross-file relationshipsmodel: opus: rarely; only for deeply tangled architecturesCollect findings into a rough spec the parent session can hold:
Do NOT present this rough spec to the user yet — Phase 2 will refine it into a plan first.
Goal: produce an initial implementation plan plus an explicit list of gaps and open questions.
Dispatch a single planning sub-agent using the Agent tool with:
subagent_type: Plan (architect agent)model: sonnet by defaultmodel: opus if: cross-system design tradeoffs, significant ambiguity in the spec, novel pattern with no clear precedent in the codebase, correctness-critical (security, data integrity, concurrency, migrations)haiku — planning needs reasoning headroomThe plan agent's prompt MUST include:
Receive and hold the plan. Do not yet present to user — Phase 3 is the discussion gate.
Goal: iterate with the user until the spec and plan are agreed.
Present to the user, in the main session output:
Loop with the user in plain conversation:
Gate: when the user signals approval (or after refinements you believe complete), use AskUserQuestion with options:
Do NOT proceed to Phase 4 without explicit approval via this gate.
Goal: break the approved plan into discrete chunks that can be dispatched to execution agents.
Detect test infrastructure — before deciding whether tests are mandatory, run a quick check:
# Probes: test directories, test files, CI test step, manifest test scripts
ls test tests __tests__ 2>/dev/null
git ls-files | grep -E '_test\.(go|py|rs)$|\.test\.(ts|tsx|js|jsx)$' | head -5
git ls-files .github/workflows/ 2>/dev/null | head -5
git ls-files | grep -E '^(package\.json|Cargo\.toml|pyproject\.toml|go\.mod)$' | head -5
If any positive signal — test directories, conventional test files, CI workflows referencing tests, or a test/check script in package manifests — record tests_required=true. Otherwise tests_required=false.
Chunk the plan into discrete tasks. For each chunk record:
c1, c2, …). The Workflow keys execution, review, and re-dispatch on it, so it must be unique and stable across the run.tests_required=true AND the chunk is not purely cosmetic, add a paired test chunk OR include test work in the chunk's scope (set its tests flag, with optional testScope guidance). Skip if cosmetic-only or tests_required=false.opusReview flag on the chunk when it warrants the senior review pass in Phase 6: it was tagged Opus-tier above, its paths match correctness-critical patterns (auth, crypto, payments, transactions, migrations, concurrency primitives), the spec called out correctness/security, or it involves a novel algorithm or non-trivial state machine. Leave it off for trivial chunks.Identify parallelization — group chunks into waves. A wave is a set of chunks with no dependencies on each other (within the wave); they will be dispatched in parallel. Waves run serially, with each later wave allowed to depend on completed earlier waves.
Hold the chunk plan for the Phase 5 gate. Do not present yet — present at the gate.
Goal: get the user's approval, then hand the approved chunk plan to the build-and-verify Workflow.
Present the chunk plan to the user. Use AskUserQuestion with options:
This gate is also the spend gate: approving here is what authorizes the Workflow to spin up a background fleet. Do not dispatch without it — even if this skill was auto-invoked by the model rather than the user.
Construct the Workflow args from the approved chunk plan. Build a JSON object:
{
"description": "<the user's feature description>",
"plan": "<the agreed implementation plan, as markdown>",
"testsRequired": <true|false from Phase 4 step 1>,
"waves": [
[ { "id": "c1", "scope": "...", "files": ["..."], "model": "sonnet", "tests": false, "opusReview": false } ],
[ { "id": "c2", "scope": "...", "files": ["..."], "model": "opus", "tests": true, "testScope": "...", "opusReview": true } ]
]
}
waves is dependency-ordered: each inner array is one wave, dispatched in parallel; waves run serially. Carry every field from the Phase 4 chunk record (id, scope, files, model, tests, optional testScope, opusReview).
Dispatch the Workflow. Call the Workflow tool with:
scriptPath: ${CLAUDE_PLUGIN_ROOT}/scripts/orchestrate-build.workflow.jsargs: <the object from step 2> (pass it as an actual JSON value, not a stringified blob)The Workflow runs headless: it executes the waves with per-chunk failure escalation (attempt 1 = chunk tier; attempt 2 = same tier + failure-refined prompt; attempt 3 = bumped tier), then reviews every executed chunk (one Sonnet reviewer each, plus one Opus reviewer over the opusReview subset), and auto-fixes blockers by re-dispatching affected chunks with the reviewer feedback and re-reviewing only those — capped at 2 review iterations. Concerns and nits are reported, never auto-fixed. It edits the session's working tree (the Phase 0b worktree, if one was created), so no per-agent isolation is needed. You can watch progress via /workflows.
When the Workflow returns, it gives you a structured result — proceed to Phase 6 to consume it:
{
"iterations": 1,
"hitReviewCap": false,
"perChunk": [ { "chunkId": "c1", "ok": true, "attempts": 1, "model": "sonnet", "summary": "...", "testsPassed": true } ],
"filesChanged": ["..."],
"clean": ["c1"],
"unresolvedBlockers": [],
"concerns": [ { "chunkId": "c2", "severity": "concern", "title": "...", "detail": "...", "file": "..." } ],
"nits": [ { "chunkId": "c1", "severity": "nit", "title": "..." } ]
}
Goal: act on the Workflow's structured result. The blocker auto-fix loop already ran headlessly inside the Workflow; this phase handles only the decisions that need a human.
If unresolvedBlockers is non-empty (hitReviewCap is true — the auto-fix loop hit its 2-iteration cap with blockers still standing): surface every remaining blocker to the user with full context (chunk, title, detail, file, and the chunk's perChunk summary). Do not silently retry beyond the cap. Let the user decide — fix manually, re-run a targeted Workflow on those chunks, or accept and move on.
Else if concerns is non-empty: present them via AskUserQuestion:
Else (only nits or fully clean): note any nits for the hand-off summary and proceed to Phase 7.
Carry perChunk, filesChanged, clean, deferred concerns, and nits forward — Phase 7's summary draws on them.
Goal: summarize and route to the appropriate finalization flow.
Produce a final summary for the user covering:
HARD STOP — then wait for the user's free-text response (NO EXCEPTIONS). Do NOT use AskUserQuestion and do NOT commit, push, open or merge a PR, or enable auto-merge — no matter how obvious the next step seems, no matter that the gates were approved, and even if this skill was auto-invoked. The Phase 3/5 approvals authorized building the feature, never publishing it. Finalizing is a separate, explicit, user-initiated act. Let the user decide what's next — they may run /git-tools:ship (commit, push, PR, watch CI), /session:session-end (review-then-PR flow), ask for adjustments, or finalize manually. Just present the summary and wait in the normal chat input.
If this run created a worktree (Phase 0b), note that its teardown is deferred: /session:session-end removes it after the PR merges, or the user can leave it and exit later with ExitWorktree. Do not tear it down here.
/session:session-start instead before kicking off Phase 1.AskUserQuestion, and Phase 5's gate is the spend gate for the Workflow. The Phase 6 concerns step also gates via AskUserQuestion. The blocker auto-fix loop inside the Workflow is the only place work advances without an explicit gate.Workflow, not the main session. Do not re-implement Execute or the review/blocker loop with inline Agent calls — construct the args and dispatch scripts/orchestrate-build.workflow.js. Self-contained prompts (full context per agent), parallel wave dispatch, failure escalation, and review dedupe are all handled inside the script.Agent and the Phase 2 planning Agent must carry enough context to succeed without seeing the parent conversation.Agent calls in a single message so they run concurrently. (Phase 5/6 parallelism is the Workflow's job.)args and the script in sync. If you change the chunk-record shape in Phase 4, update both the Phase 5 args contract and the args documentation at the top of orchestrate-build.workflow.js.development
Start work from your description — explore the codebase and plan
tools
Browse open issues, pick one, and start work on it
tools
Interact with GitHub and Gitea issue trackers and CI systems. List and show issues, file bugs, comment on issues or PRs, list and show pull requests, and fetch CI run logs — all from any repo context without leaving the session.
tools
MUST be used for ALL GitHub/Gitea CLI operations. Never invoke `gh`, `tea`, or their subcommands directly — always go through git-cli. Use for issues, PRs, CI runs, repo, and api calls; auto-detects the platform from the git remote.