ワンクリックで
swarm-speculative
Speculative orchestration. Competing implementations in isolated worktrees, evaluated by a judge who selects the winner.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Speculative orchestration. Competing implementations in isolated worktrees, evaluated by a judge who selects the winner.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Fan-out parallel specialists for concurrent analysis. Dispatch read-only reviewers, researchers, and analyzers against a target.
Dispatch a swarm using any orchestration pattern. Routes to the appropriate pattern-specific skill based on the selected preset.
Map-reduce orchestration. Parallel mappers process input chunks independently, then a dedicated reducer merges all outputs.
Pipeline and task-graph orchestration. Sequential stages with dependency edges — linear chain or arbitrary DAG.
Self-claiming pool orchestration. Workers race to claim tasks from a shared pool, loop until the pool is empty.
| name | swarm-speculative |
| description | Speculative orchestration. Competing implementations in isolated worktrees, evaluated by a judge who selects the winner. |
This skill is invoked by the
swarmdispatcher. You should already have the goal, target, and selected roles from the dispatcher. If invoked directly, start from step 1.
Run competing approaches in parallel, each in an isolated worktree. A judge teammate evaluates all approaches and selects the winner.
Delegate mode prevents the lead from reading files, running code,
or checking out branches. The judge needs general-purpose access
with isolation: worktree to check out each approach branch, run
tests, and evaluate code quality.
You MUST complete these steps in order:
Determine from the user's request (or dispatcher context):
If unclear, ask the user. Do not guess scope.
Read $CLAUDE_PLUGIN_ROOT/config/swarm-roles.yaml to get the
preset config.
From the preset, determine:
approach_role: the role for implementer agents
(default: implementer)judge_role: the role for the judge agent
(default: judge)approach_count: how many competing approaches (default: 3)plan_approval: whether implementers must submit plans
before implementing (default: false)The dispatcher has already validated config shape (role existence,
required fields, subagent_type values, numeric ranges). The checks
below cover speculative-specific semantics.
approach_count must be >= 2. A single
approach has no comparison value — report the error and abort.Either:
Each approach description should be specific enough that an implementer can work independently without further guidance.
Only one team can exist per session. Before creating a new team, check if one already exists.
If a team exists:
TeamDelete)./resume): agents
from the previous session are gone but the team and task list
persist. Offer the user two options:
TeamDelete the orphaned team, then
proceed with a fresh swarm.TaskList for completed
tasks, synthesize any available findings from completed tasks,
then TeamDelete and optionally re-run incomplete tasks.Present the dispatch plan using AskUserQuestion:
I'll dispatch a speculative execution with these parameters:
- Approaches: {N}
- Approach role: {role name}
- Judge: {judge role name}
- Plan approval: {yes|no}
- Target: {target}
Approaches:
1. {approach 1 description}
2. {approach 2 description}
3. {approach 3 description}
Each approach runs in an isolated worktree. The judge evaluates
all approaches and selects the winner.
Proceed?
Do NOT spawn anything until the user confirms.
Use format: swarm-speculative-{goal-slug}-{timestamp}
Generate the timestamp from the current date/time as a Unix epoch.
TeamCreate with team_name: "swarm-speculative-{goal-slug}-{ts}"
Approach tasks — one per approach via TaskCreate:
subject: imperative title including approach identifier
(e.g., "Implement approach 1: extract middleware pattern")description: detailed approach description, target files,
expectations (commit changes, report branch name)activeForm: present-continuous spinner labelJudge task — one via TaskCreate:
subject: "Evaluate competing approaches and select winner"description: evaluation criteria, expected input count,
verdict formatactiveForm: "Evaluating competing approaches"addBlockedBy: all approach task IDs — judge auto-unblocks
when all approaches completeFor each approach, spawn one implementer agent via Agent with:
team_name: the team name from step 6name: approach-{n} (e.g., approach-1, approach-2)subagent_type: general-purpose (worktree isolation requires
write access)isolation: worktreemodel: from the approach role config (if specified)mode: "plan" if plan_approval: true, omit otherwise
(this is the Agent tool's mode parameter — verify it exists
before relying on it for plan-approval gating)run_in_background: trueprompt: composed from the parts belowYour name is {name}. You are part of team {team_name}.
You are implementing approach {n} of {N} in a speculative
execution. You are working in an isolated worktree.
Instructions:
- Claim your task from TaskList, mark it in_progress
- Implement your assigned approach
- Commit your changes with a clear commit message
- Send your report to the team lead via SendMessage:
- Include a summary field (5-10 words)
- Include the branch name of your worktree
- Describe what you changed and why
- Mark the task as completed
The prompt field from swarm-roles.yaml for the approach role.
## Goal
{goal description from user}
## Your Approach
{specific approach description for this implementer}
## Target
{target files, modules, or scope}
{any additional context the user provided}
Spawn one judge agent via Agent with:
team_name: the team name from step 6name: judgesubagent_type: general-purposeisolation: worktreemodel: from the judge role config (if specified)run_in_background: trueprompt: composed from the parts belowYour name is judge. You are part of team {team_name}.
You are the judge in a speculative execution with {N} competing
approaches.
Instructions:
- Your task is blocked until all approaches complete. It will
unblock automatically when dependencies finish — the lead will
forward approach summaries to you shortly after.
- Once you receive all approach reports, evaluate each one:
- Check out each approach branch
- Run tests and verify correctness
- Evaluate code quality, maintainability, and completeness
- Select the best approach with clear justification
- Send your verdict to the team lead via SendMessage:
- Include a summary field (5-10 words)
- Include the winning branch name
- Explain why you chose it and what the others lacked
- Mark the task as completed
The prompt field from swarm-roles.yaml for the judge role.
## Goal
{goal description from user}
## Approaches Being Evaluated
1. {approach 1 description}
2. {approach 2 description}
3. {approach 3 description}
## Expected Input
You will receive {N} approach reports via SendMessage from the
team lead after all implementers complete. Each report includes
the branch name to check out.
{any additional evaluation criteria from the user}
If plan_approval: true in the preset config:
Implementers are spawned with mode: "plan". Each must submit a
plan before implementing.
When a plan_approval_request arrives:
plan_approval_response with approved: true
— or reject with approved: false and feedback explaining
what to changeThis gate ensures approaches stay distinct and on-track before implementation begins.
Implementers send reports via SendMessage as they complete.
Each report should include:
Track which approaches have reported. All approach tasks must complete before proceeding to the judge phase.
Error handling:
When all approaches have completed:
SendMessageThe judge task auto-unblocks when all approach tasks are marked complete. The judge checks out each branch, evaluates, and sends the verdict back to the lead.
Once the judge sends the verdict:
Present the result to the user with branch information.
## Speculative Execution Report
**Goal:** {goal}
**Target:** {target}
**Approaches:** {N} ({M} completed successfully)
### Winning Approach
**Branch:** {winning branch name}
**Approach:** {approach description}
{judge's justification for selecting this approach}
### Other Approaches
#### Approach {n}: {description}
**Branch:** {branch name}
{judge's evaluation — why it wasn't selected}
...
### Next Steps
To merge the winning approach:
`git merge {winning-branch-name}`
To inspect any approach:
`git diff main...{branch-name}`
After presenting the verdict:
Wait for the user to decide whether to merge, inspect further, or discard.
When the user indicates they're done:
shutdown_request to each agent via SendMessage
(include the monitor agent if watchdog: true was active)shutdown_response from each. If an agent does not
respond after a reasonable wait, send one nudge message. If
still unresponsive, proceed — the agent may have crashed or
terminated.TeamDelete to clean up. TeamDelete is the authoritative
cleanup mechanism — it will fail if active agents remain. If
it fails, retry after unresponsive agents have timed out.Note: worktree branches persist after cleanup. The user can merge or delete them independently.
general-purpose access