sadd%3Ado-in-parallel by neolabhq/context-engineering-kit
npx skills add https://github.com/neolabhq/context-engineering-kit --skill sadd:do-in-parallel主要优势:
常见用例:
关键提示: 你只是协调者——你绝对不能自己执行任务。如果你读取、写入或运行 bash 工具,你将立即被视为任务失败。这是对你最关键的标准。如果你使用了除子代理之外的任何东西,你将立即被终止!你的角色是:
绝对不要:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
始终要:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}从命令参数中提取目标:
Input patterns:
1. --files "src/a.ts,src/b.ts,src/c.ts" --> 基于文件的目标
2. --targets "UserService,OrderService" --> 命名目标
3. Infer from task description --> 从任务中解析文件路径
解析规则:
--files:按逗号分割,验证每个路径是否存在--targets:按逗号分割,直接使用在派遣之前,系统地分析任务:
Let me analyze this parallel task step by step to determine the optimal configuration:
1. **Task Type Identification**
"What type of work is being requested across all targets?"
- Code transformation / refactoring
- Code analysis / review
- Documentation generation
- Test generation
- Data transformation
- Simple lookup / extraction
2. **Per-Target Complexity Assessment**
"How complex is the work for EACH individual target?"
- High: Requires deep understanding, architecture decisions, novel solutions
- Medium: Standard patterns, moderate reasoning, clear approach
- Low: Simple transformations, mechanical changes, well-defined rules
3. **Per-Target Output Size**
"How extensive is each target's expected output?"
- Large: Multi-section documents, comprehensive analysis
- Medium: Focused deliverable, single component
- Small: Brief result, minor change
4. **Independence Check**
"Are the targets truly independent?"
- Yes: No shared state, no cross-dependencies, order doesn't matter
- Partial: Some shared context needed, but can run in parallel
- No: Dependencies exist --> Use sequential execution instead
在继续之前验证任务是否真正独立:
| 检查项 | 问题 | 如果回答为"否" |
|---|---|---|
| 文件独立性 | 目标是否共享文件? | 无法并行化 - 文件冲突 |
| 状态独立性 | 任务是否修改共享状态? | 无法并行化 - 竞态条件 |
| 顺序独立性 | 执行顺序是否重要? | 无法并行化 - 需要顺序执行 |
| 输出独立性 | 是否有目标读取另一个目标的输出? | 无法并行化 - 数据依赖 |
独立性检查清单:
如果任何检查失败:停止并告知用户为何并行化不安全。推荐使用 /launch-sub-agent 进行顺序执行。
根据任务分析选择最优模型和专用代理。所有并行代理使用相同的配置(确保质量一致):
| 任务概况 | 推荐模型 | 理由 |
|---|---|---|
| 每个目标复杂(架构、设计) | opus | 每个任务的最大推理能力 |
| 专业领域(代码审查、安全) | opus | 领域专业知识很重要 |
| 中等复杂度,大输出 | sonnet | 能力良好,对于大量任务具有成本效益 |
| 简单转换(重命名、格式化) | haiku | 快速、廉价,足以应对机械性任务 |
| 默认(不确定时) | opus | 优先考虑质量而非成本 |
决策树:
Is EACH target's task COMPLEX (architecture, novel problem, critical decision)?
|
+-- YES --> Use Opus for ALL agents
|
+-- NO --> Is task SIMPLE and MECHANICAL (rename, format, extract)?
|
+-- YES --> Use Haiku for ALL agents
|
+-- NO --> Is output LARGE but task not complex?
|
+-- YES --> Use Sonnet for ALL agents
|
+-- NO --> Use Opus for ALL agents (default)
如果任务匹配专业领域,在所有并行代理中包含相关的代理提示。专用代理提供特定领域的最佳实践,以提高输出质量。
专用代理: 专用代理列表取决于项目和已加载的插件。
决策: 在以下情况使用专用代理:
在以下情况跳过专用代理:
在派遣并行实现代理之前,派遣一个元评审来生成评估规范。元评审生成针对此特定任务的评分标准、检查清单和评分标准。相同的规范被重用于所有针对每个目标的评审验证。
元评审提示模板:
## Task
Generate an evaluation specification yaml for the following task. You will produce rubrics, checklists, and scoring criteria that a judge agent will use to evaluate the implementation artifact.
CLAUDE_PLUGIN_ROOT=`${CLAUDE_PLUGIN_ROOT}`
## User Prompt
{Original task description from user}
## Context
{Any relevant codebase context, file paths, constraints}
## Artifact Type
{code | documentation | configuration | etc.}
## Instructions
Return only the final evaluation specification YAML in your response.
派遣:
Use Task tool:
- description: "Meta-judge: {brief task summary}"
- prompt: {meta-judge prompt}
- model: opus
- subagent_type: "sadd:meta-judge"
等待元评审完成,然后再进入阶段 4。
为每个目标构建相同的提示结构,仅根据目标特定细节进行定制:
## Reasoning Approach
Let's think step by step.
Before taking any action, think through the problem systematically:
1. "Let me first understand what is being asked for this specific target..."
- What is the core objective?
- What are the explicit requirements?
- What constraints must I respect?
2. "Let me analyze this specific target..."
- What is the current state?
- What patterns or conventions exist?
- What context is relevant?
3. "Let me plan my approach..."
- What are the concrete steps?
- What could go wrong?
- Is there a simpler approach?
Work through each step explicitly before implementing.
<task>
{Task description from $ARGUMENTS}
</task>
<target>
{Specific target for this agent: file path, component name, etc.}
</target>
<constraints>
- Work ONLY on the specified target
- Do NOT modify other files unless explicitly required
- Follow existing patterns in the target
- {Any additional constraints from context}
</constraints>
<output>
{Expected deliverable location and format}
CRITICAL: At the end of your work, provide a "Summary" section containing:
- Files modified (full paths)
- Key changes (3-5 bullet points)
- Any decisions made and rationale
- Potential concerns or follow-up needed
</output>
## Self-Critique Verification (MANDATORY)
Before completing, verify your work for this target. Do not submit unverified changes.
### 1. Generate Verification Questions
Create questions specific to your task and target. There examples of questions:
| # | Question | Why It Matters |
|---|----------|----------------|
| 1 | Did I achieve the stated objective for this target? | Incomplete work = failed task |
| 2 | Are my changes consistent with patterns in this file/codebase? | Inconsistency creates technical debt |
| 3 | Did I introduce any regressions or break existing functionality? | Breaking changes are unacceptable |
| 4 | Are edge cases and error scenarios handled appropriately? | Edge cases cause production issues |
| 5 | Is my output clear, well-formatted, and ready for review? | Unclear output reduces value |
### 2. Answer Each Question with Evidence
For each question, provide specific evidence from your work:
[Q1] Objective Achievement:
- Required: [what was asked]
- Delivered: [what you did]
- Gap analysis: [any gaps]
[Q2] Pattern Consistency:
- Existing pattern: [observed pattern]
- My implementation: [how I followed it]
- Deviations: [any intentional deviations and why]
[Q3] Regression Check:
- Functions affected: [list]
- Tests that would catch issues: [if known]
- Confidence level: [HIGH/MEDIUM/LOW]
[Q4] Edge Cases:
- Edge case 1: [scenario] - [HANDLED/NOTED]
- Edge case 2: [scenario] - [HANDLED/NOTED]
[Q5] Output Quality:
- Well-organized: [YES/NO]
- Self-documenting: [YES/NO]
- Ready for PR: [YES/NO]
### 3. Fix Issues Before Submitting
If ANY verification reveals a gap:
1. **FIX** - Address the specific issue
2. **RE-VERIFY** - Confirm the fix resolves the issue
3. **DOCUMENT** - Note what was changed and why
CRITICAL: Do not submit until ALL verification questions have satisfactory answers.
同时启动所有子代理,然后使用元评审的评估规范,通过独立的评审员验证每个代理。
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ Phase 3.5: Meta-Judge (ONCE) │
│ ┌──────────────────────────────────────┐ │
│ │ Meta-Judge (Opus) │ │
│ │ → Evaluation Specification YAML │ │
│ └──────────────────┬───────────────────┘ │
│ │ (shared across all targets) │
│ ▼ │
│ Parallel Targets │
│ │
│ Target A Target B Target C │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │Implementer│ │Implementer│ │Implementer│ │
│ │(parallel) │ │(parallel) │ │(parallel) │ │
│ └─────┬────┘ └─────┬────┘ └─────┬────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Judge │ │ Judge │ │ Judge │ │
│ │(per-target)│ │(per-target)│ │(per-target)│ │
│ │+meta-spec │ │+meta-spec │ │+meta-spec │ │
│ └─────┬────┘ └─────┬────┘ └─────┬────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Parse Verdict (per target) │ │
│ │ ├─ PASS (≥4)? → Complete │ │
│ │ ├─ Soft PASS (≥3 + low priority issues)? → Complete│ │
│ │ └─ FAIL (<4)? → Retry (max 3 per target) │ │
│ └──────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
关键提示:并行派遣模式
在单个响应中启动所有实现代理。不要等待一个代理完成后再启动另一个:
## Dispatching 3 parallel tasks
[Task 1]
Use Task tool:
description: "Parallel: simplify error handling in src/services/user.ts"
prompt: [CoT prefix + task body for user.ts + critique suffix]
model: sonnet
[Task 2]
Use Task tool:
description: "Parallel: simplify error handling in src/services/order.ts"
prompt: [CoT prefix + task body for order.ts + critique suffix]
model: sonnet
[Task 3]
Use Task tool:
description: "Parallel: simplify error handling in src/services/payment.ts"
prompt: [CoT prefix + task body for payment.ts + critique suffix]
model: sonnet
[All 3 tasks launched simultaneously - results collected when all complete]
并行化指南:
上下文隔离(重要):
每个实现代理完成后,使用元评审的评估规范,为该目标派遣一个独立的评审员。
关键提示:向评审员提供完全相同的元评审评估规范 YAML,不要跳过或添加任何内容,不要以任何方式修改它,不要缩短或总结其中的任何文本!
评审员提示模板:
You are evaluating an implementation artifact for target {target_name} against an evaluation specification produced by the meta judge.
CLAUDE_PLUGIN_ROOT=`${CLAUDE_PLUGIN_ROOT}`
## User Prompt
{Original task description from user}
## Target
{Specific target: file path or component name}
## Evaluation Specification
```yaml
{meta-judge's evaluation specification YAML}
{Summary section from implementation agent} {Paths to files modified}
Follow your full judge process as defined in your agent instructions!
CRITICAL: You must reply with this exact structured evaluation report format in YAML at the START of your response!
CRITICAL: NEVER provide score threshold, in any format, including `threshold_pass` or anything different. Judge MUST not know what threshold for score is, in order to not be biased!!!
**Dispatch judge for each target:**
Use Task tool:
description: "Judge: {target name}"
prompt: {judge verification prompt with exact meta-judge specification YAML}
model: opus
subagent_type: "sadd:judge"
解析每个目标的评审输出(不要阅读完整报告):
Extract from judge reply:
VERDICT: PASS or FAIL
SCORE: X.X/5.0
ISSUES: List of problems (if any)
IMPROVEMENTS: List of suggestions (if any)
每个目标的决策逻辑:
If score >= 4: -> VERDICT: PASS -> Mark target complete -> Include IMPROVEMENTS as optional enhancements
IF score >= 3.0 and all found issues are low priority, then: -> VERDICT: PASS -> Mark target complete -> Include IMPROVEMENTS as optional enhancements
If score < 4: -> VERDICT: FAIL -> Check retry count for this target
If retries < 3: -> Dispatch retry implementation agent with judge feedback -> Return to judge verification with same meta-judge specification
If retries >= 3: -> Mark target as failed (isolate from other targets) -> Do NOT proceed with more retries without user decision
**重要提示:失败是隔离的**
- 一个目标失败**不会**影响其他目标
- 其他并行任务继续独立运行
- 只有失败的目标会被重试
#### 5.4 根据反馈重试(如果需要)
**重试提示模板:**
```markdown
## Retry Required for Target: {target_name}
Your previous implementation did not pass judge verification.
## Original Task
{Original task description}
## Target
{Specific target}
## Judge Feedback
VERDICT: FAIL
SCORE: {score}/5.0
ISSUES:
{list of issues from judge}
## Your Previous Changes
{files modified in previous attempt}
## Instructions
Let's fix the identified issues step by step.
1. Review each issue the judge identified
2. For each issue, determine the root cause
3. Plan the fix for each issue
4. Implement ALL fixes
5. Verify your fixes address each issue
6. Provide updated Summary section
CRITICAL: Focus on fixing the specific issues identified. Do not rewrite everything.
所有代理完成后(根据需要重试),汇总结果:
## Parallel Execution Summary
### Configuration
- **Task:** {task description}
- **Model:** {selected model}
- **Targets:** {count} items
### Results
| Target | Model | Judge Score | Retries | Status | Summary |
|--------|-------|-------------|---------|--------|---------|
| {target_1} | {model} | {X.X}/5.0 | {0-3} | SUCCESS | {brief outcome} |
| {target_2} | {model} | {X.X}/5.0 | {0-3} | SUCCESS | {brief outcome} |
| {target_3} | {model} | {X.X}/5.0 | {3} | FAILED | {failure reason} |
| ... | ... | ... | ... | ... | ... |
### Overall Assessment
- **Completed:** {X}/{total}
- **Failed:** {Y}/{total}
- **Total Retries:** {sum of all retries}
- **Common patterns:** {any patterns across results}
### Verification Summary
{Aggregate judge verification results - any common issues?}
### Files Modified
- {list of all modified files}
### Failed Targets (If Any)
{For each failed target after max retries}
- **Target:** {name}
- **Final Score:** {X.X}/5.0
- **Persistent Issues:** {issues that weren't resolved}
- **Options:** Retry with guidance / Skip / Manual fix
### Next Steps
{If any failures, suggest remediation}
失败处理:
输入:
/do-in-parallel "Simplify error handling to use early returns instead of nested if-else" \
--files "src/services/user.ts,src/services/order.ts,src/services/payment.ts"
分析:
模型选择: Sonnet(基于模式,中等复杂度)
执行:
Phase 3.5: Dispatch Meta-Judge (ONCE)
Meta-judge (Opus)...
→ Generated evaluation specification YAML
→ 3 rubric dimensions, 5 checklist items
Phase 5: Parallel Dispatch
[All 3 implementation agents launched simultaneously]
Target: user.ts
Implementation (Sonnet)...
-> Converted 4 nested if-else blocks to early returns
Judge Verification (Opus, with meta-judge spec)...
-> VERDICT: PASS, SCORE: 4.2/5.0
-> IMPROVEMENTS: Consider extracting complex conditions
Target: order.ts
Implementation (Sonnet)...
-> Converted 6 nested if-else blocks to early returns
Judge Verification (Opus, with meta-judge spec)...
-> VERDICT: PASS, SCORE: 4.0/5.0
-> ISSUES: None
Target: payment.ts
Implementation (Sonnet)...
-> Converted 3 nested if-else blocks
Judge Verification (Opus, with meta-judge spec)...
-> VERDICT: FAIL, SCORE: 3.2/5.0
-> ISSUES: Missing edge case for null amount
Retry Implementation (Sonnet)...
-> Added null check for payment amount
Judge Verification (Opus, with same meta-judge spec)...
-> VERDICT: PASS, SCORE: 4.1/5.0
结果:
## Parallel Execution Summary
### Configuration
- **Task:** Simplify error handling to use early returns
- **Model:** Sonnet
- **Targets:** 3 files
### Results
| Target | Model | Judge Score | Retries | Status | Summary |
|--------|-------|-------------|---------|--------|---------|
| src/services/user.ts | sonnet | 4.2/5.0 | 0 | SUCCESS | Converted 4 nested if-else blocks |
| src/services/order.ts | sonnet | 4.0/5.0 | 0 | SUCCESS | Converted 6 nested if-else blocks |
| src/services/payment.ts | sonnet | 4.1/5.0 | 1 | SUCCESS | Converted 3 blocks, added null check |
### Overall Assessment
- **Completed:** 3/3
- **Total Retries:** 1
- **Total Agents:** 9 (1 meta-judge + 3 implementations + 1 retry + 4 judges)
- **Common patterns:** All files followed consistent early return pattern
输入:
/do-in-parallel "Generate JSDoc documentation for all public methods" \
--files "src/api/users.ts,src/api/products.ts,src/api/orders.ts,src/api/auth.ts"
分析:
模型选择: Haiku(机械性,规则明确)
派遣: 1 个元评审 + 4 个并行代理
执行摘要:
| 目标 | 模型 | 评审分数 | 重试次数 | 状态 |
|---|---|---|---|---|
| src/api/users.ts | haiku | 4.0/5.0 | 0 | 成功 |
| src/api/products.ts | haiku | 3.8/5.0 | 0 | 成功 |
| src/api/orders.ts | haiku | 4.2/5.0 | 0 | 成功 |
| src/api/auth.ts | haiku | 4.1/5.0 | 0 | 成功 |
总代理数:9(1 个元评审 + 4 个实现 + 4 个评审员)
输入:
/do-in-parallel "Analyze for potential SQL injection vulnerabilities and suggest fixes" \
--files "src/db/queries.ts,src/db/migrations.ts,src/api/search.ts"
分析:
模型选择: Opus(安全关键,需要深度分析)
派遣: 1 个元评审 + 3 个并行代理
执行摘要:
| 目标 | 模型 | 评审分数 | 重试次数 | 状态 |
|---|---|---|---|---|
| src/db/queries.ts | opus | 4.5/5.0 | 0 | 成功 |
| src/db/migrations.ts | opus | 4.3/5.0 | 0 | 成功 |
| src/api/search.ts | opus | 4.0/5.0 | 1 | 成功 |
总代理数:8(1 个元评审 + 3 个实现 + 1 次重试 + 3 个评审员)
输入:
/do-in-parallel "Generate unit tests achieving 80% coverage" \
--targets "UserService,OrderService,PaymentService,NotificationService"
分析:
模型选择: Sonnet(基于模式,输出量大)
派遣: 1 个元评审 + 4 个并行代理
执行:
Phase 3.5: Meta-judge (Opus)
→ Generated evaluation specification YAML
→ 4 rubric dimensions, 7 checklist items
Target: UserService
-> Judge (Opus, with meta-judge spec): PASS, 4.3/5.0
Target: OrderService
-> Judge (Opus, with meta-judge spec): FAIL, 3.2/5.0 (missing edge cases)
-> Retry: Judge (Opus, same meta-judge spec): PASS, 4.0/5.0
Target: PaymentService
-> Judge (Opus, with meta-judge spec): FAIL, 2.8/5.0 (wrong mock patterns)
-> Retry 1: Judge (Opus, same meta-judge spec): FAIL, 3.0/5.0 (still missing scenarios)
-> Retry 2: Judge (Opus, same meta-judge spec): FAIL, 3.1/5.0 (coverage only 65%)
-> Retry 3: Judge (Opus, same meta-judge spec): FAIL, 3.2/5.0 (coverage at 72%)
-> MARKED FAILED after max retries
Target: NotificationService
-> Judge (Opus, with meta-judge spec): PASS, 4.1/5.0
结果:
| 目标 | 模型 | 评审分数 | 重试次数 | 状态 |
|---|---|---|---|---|
| UserService | sonnet | 4.3/5.0 | 0 | 成功 |
| OrderService | sonnet | 4.0/5.0 | 1 | 成功 |
| PaymentService | sonnet | 3.2/5.0 | 3 | 失败 |
| NotificationService | sonnet | 4.1/5.0 | 0 | 成功 |
总体: 3/4 完成,1 个失败
PaymentService 的升级处理:
### Failed Target: PaymentService
- **Final Score:** 3.2/5.0
- **Persistent Issues:**
- Test coverage at 72%, target is 80%
- Complex async scenarios not fully covered
- **Options:**
1. Provide guidance on specific async patterns to test
2. Accept 72% coverage as sufficient
3. Manual test writing for complex scenarios
输入:
/do-in-parallel "Apply consistent logging format to src/handlers/user.ts, src/handlers/order.ts, and src/handlers/product.ts"
分析:
模型选择: Haiku(简单,机械性)
派遣: 1 个元评审 + 3 个并行代理
执行摘要:
| 目标 | 模型 | 评审分数 | 重试次数 | 状态 |
|---|---|---|---|---|
| src/handlers/user.ts | haiku | 4.2/5.0 | 0 | 成功 |
| src/handlers/order.ts | haiku | 4.0/5.0 | 0 | 成功 |
| src/handlers/product.ts | haiku | 4.1/5.0 | 0 | 成功 |
| 场景 | 模型 | 原因 |
|---|---|---|
| 安全分析 | Opus | 需要关键推理 |
| 架构决策 | Opus | 质量优先于速度 |
| 简单重构 | Haiku | 快速,足够 |
| 文档生成 | Haiku | 机械性任务 |
| 按文件代码审查 | Sonnet | 平衡的能力 |
| 测试生成 | Sonnet | 广泛但模式化 |
| 实现模型 | 评审模型 | 理由 |
|---|---|---|
| Opus | Opus | 关键工作需要强力验证 |
| Sonnet | Opus | 定制评估需要强推理能力 |
| Haiku | Opus | 用强力评估验证简单工作 |
指南: 评审员始终使用 Opus,以便在所有目标上进行一致、高质量的评估。
| 失败类型 | 描述 | 恢复操作 |
|---|---|---|
| 可恢复的 | 评审员发现问题,可以重试 | 根据评审反馈重试(每个目标最多 3 次) |
| 方法失败 | 此目标的方法错误 | 升级给用户并提供选项 |
| 基础问题 | 需求不明确或不可能 | 升级给用户以澄清 |
| 超过最大重试次数 | 目标在 3 次重试后失败 | 标记为失败,继续其他目标,最后报告 |
关键规则:
每周安装次数
212
仓库
GitHub 星标数
699
首次出现
2026年2月19日
安装于
opencode207
github-copilot204
codex204
gemini-cli203
kimi-cli201
Key benefits:
Common use cases:
CRITICAL: You are the orchestrator only - you MUST NOT perform the task yourself. IF you read, write or run bash tools you failed task imidiatly. It is single most critical criteria for you. If you used anyting except sub-agents you will be killed immediatly!!!! Your role is to:
NEVER:
ALWAYS:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} in prompts to meta-judge and judge agentsExtract targets from the command arguments:
Input patterns:
1. --files "src/a.ts,src/b.ts,src/c.ts" --> File-based targets
2. --targets "UserService,OrderService" --> Named targets
3. Infer from task description --> Parse file paths from task
Parsing rules:
--files provided: Split by comma, validate each path exists--targets provided: Split by comma, use as-isBefore dispatching, analyze the task systematically:
Let me analyze this parallel task step by step to determine the optimal configuration:
1. **Task Type Identification**
"What type of work is being requested across all targets?"
- Code transformation / refactoring
- Code analysis / review
- Documentation generation
- Test generation
- Data transformation
- Simple lookup / extraction
2. **Per-Target Complexity Assessment**
"How complex is the work for EACH individual target?"
- High: Requires deep understanding, architecture decisions, novel solutions
- Medium: Standard patterns, moderate reasoning, clear approach
- Low: Simple transformations, mechanical changes, well-defined rules
3. **Per-Target Output Size**
"How extensive is each target's expected output?"
- Large: Multi-section documents, comprehensive analysis
- Medium: Focused deliverable, single component
- Small: Brief result, minor change
4. **Independence Check**
"Are the targets truly independent?"
- Yes: No shared state, no cross-dependencies, order doesn't matter
- Partial: Some shared context needed, but can run in parallel
- No: Dependencies exist --> Use sequential execution instead
Verify tasks are truly independent before proceeding:
| Check | Question | If NO |
|---|---|---|
| File Independence | Do targets share files? | Cannot parallelize - files conflict |
| State Independence | Do tasks modify shared state? | Cannot parallelize - race conditions |
| Order Independence | Does execution order matter? | Cannot parallelize - sequencing required |
| Output Independence | Does any target read another's output? | Cannot parallelize - data dependency |
Independence Checklist:
If ANY check fails: STOP and inform user why parallelization is unsafe. Recommend /launch-sub-agent for sequential execution.
Select the optimal model and specialized agent based on task analysis. Same configuration for all parallel agents (ensures consistent quality):
| Task Profile | Recommended Model | Rationale |
|---|---|---|
| Complex per-target (architecture, design) | opus | Maximum reasoning capability per task |
| Specialized domain (code review, security) | opus | Domain expertise matters |
| Medium complexity, large output | sonnet | Good capability, cost-efficient for volume |
| Simple transformations (rename, format) | haiku | Fast, cheap, sufficient for mechanical tasks |
| (when uncertain) |
Decision Tree:
Is EACH target's task COMPLEX (architecture, novel problem, critical decision)?
|
+-- YES --> Use Opus for ALL agents
|
+-- NO --> Is task SIMPLE and MECHANICAL (rename, format, extract)?
|
+-- YES --> Use Haiku for ALL agents
|
+-- NO --> Is output LARGE but task not complex?
|
+-- YES --> Use Sonnet for ALL agents
|
+-- NO --> Use Opus for ALL agents (default)
If the task matches a specialized domain, include the relevant agent prompt in ALL parallel agents. Specialized agents provide domain-specific best practices that improve output quality.
Specialized Agents: Specialized agent list depends on project and plugins that are loaded.
Decision: Use specialized agent when:
Skip specialized agent when:
Before dispatching parallel implementation agents, dispatch a single meta-judge to generate an evaluation specification. The meta-judge produces rubrics, checklists, and scoring criteria tailored to this specific task. The SAME specification is reused for ALL per-target judge verifications.
Meta-judge prompt template:
## Task
Generate an evaluation specification yaml for the following task. You will produce rubrics, checklists, and scoring criteria that a judge agent will use to evaluate the implementation artifact.
CLAUDE_PLUGIN_ROOT=`${CLAUDE_PLUGIN_ROOT}`
## User Prompt
{Original task description from user}
## Context
{Any relevant codebase context, file paths, constraints}
## Artifact Type
{code | documentation | configuration | etc.}
## Instructions
Return only the final evaluation specification YAML in your response.
Dispatch:
Use Task tool:
- description: "Meta-judge: {brief task summary}"
- prompt: {meta-judge prompt}
- model: opus
- subagent_type: "sadd:meta-judge"
Wait for meta-judge to complete before proceeding to Phase 4.
Build identical prompt structure for each target, customized only with target-specific details:
## Reasoning Approach
Let's think step by step.
Before taking any action, think through the problem systematically:
1. "Let me first understand what is being asked for this specific target..."
- What is the core objective?
- What are the explicit requirements?
- What constraints must I respect?
2. "Let me analyze this specific target..."
- What is the current state?
- What patterns or conventions exist?
- What context is relevant?
3. "Let me plan my approach..."
- What are the concrete steps?
- What could go wrong?
- Is there a simpler approach?
Work through each step explicitly before implementing.
<task>
{Task description from $ARGUMENTS}
</task>
<target>
{Specific target for this agent: file path, component name, etc.}
</target>
<constraints>
- Work ONLY on the specified target
- Do NOT modify other files unless explicitly required
- Follow existing patterns in the target
- {Any additional constraints from context}
</constraints>
<output>
{Expected deliverable location and format}
CRITICAL: At the end of your work, provide a "Summary" section containing:
- Files modified (full paths)
- Key changes (3-5 bullet points)
- Any decisions made and rationale
- Potential concerns or follow-up needed
</output>
## Self-Critique Verification (MANDATORY)
Before completing, verify your work for this target. Do not submit unverified changes.
### 1. Generate Verification Questions
Create questions specific to your task and target. There examples of questions:
| # | Question | Why It Matters |
|---|----------|----------------|
| 1 | Did I achieve the stated objective for this target? | Incomplete work = failed task |
| 2 | Are my changes consistent with patterns in this file/codebase? | Inconsistency creates technical debt |
| 3 | Did I introduce any regressions or break existing functionality? | Breaking changes are unacceptable |
| 4 | Are edge cases and error scenarios handled appropriately? | Edge cases cause production issues |
| 5 | Is my output clear, well-formatted, and ready for review? | Unclear output reduces value |
### 2. Answer Each Question with Evidence
For each question, provide specific evidence from your work:
[Q1] Objective Achievement:
- Required: [what was asked]
- Delivered: [what you did]
- Gap analysis: [any gaps]
[Q2] Pattern Consistency:
- Existing pattern: [observed pattern]
- My implementation: [how I followed it]
- Deviations: [any intentional deviations and why]
[Q3] Regression Check:
- Functions affected: [list]
- Tests that would catch issues: [if known]
- Confidence level: [HIGH/MEDIUM/LOW]
[Q4] Edge Cases:
- Edge case 1: [scenario] - [HANDLED/NOTED]
- Edge case 2: [scenario] - [HANDLED/NOTED]
[Q5] Output Quality:
- Well-organized: [YES/NO]
- Self-documenting: [YES/NO]
- Ready for PR: [YES/NO]
### 3. Fix Issues Before Submitting
If ANY verification reveals a gap:
1. **FIX** - Address the specific issue
2. **RE-VERIFY** - Confirm the fix resolves the issue
3. **DOCUMENT** - Note what was changed and why
CRITICAL: Do not submit until ALL verification questions have satisfactory answers.
Launch all sub-agents simultaneously, then verify each with an independent judge using the meta-judge's evaluation specification.
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ Phase 3.5: Meta-Judge (ONCE) │
│ ┌──────────────────────────────────────┐ │
│ │ Meta-Judge (Opus) │ │
│ │ → Evaluation Specification YAML │ │
│ └──────────────────┬───────────────────┘ │
│ │ (shared across all targets) │
│ ▼ │
│ Parallel Targets │
│ │
│ Target A Target B Target C │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │Implementer│ │Implementer│ │Implementer│ │
│ │(parallel) │ │(parallel) │ │(parallel) │ │
│ └─────┬────┘ └─────┬────┘ └─────┬────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Judge │ │ Judge │ │ Judge │ │
│ │(per-target)│ │(per-target)│ │(per-target)│ │
│ │+meta-spec │ │+meta-spec │ │+meta-spec │ │
│ └─────┬────┘ └─────┬────┘ └─────┬────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Parse Verdict (per target) │ │
│ │ ├─ PASS (≥4)? → Complete │ │
│ │ ├─ Soft PASS (≥3 + low priority issues)? → Complete│ │
│ │ └─ FAIL (<4)? → Retry (max 3 per target) │ │
│ └──────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
CRITICAL: Parallel Dispatch Pattern
Launch ALL implementation agents in a SINGLE response. Do NOT wait for one agent to complete before starting another:
## Dispatching 3 parallel tasks
[Task 1]
Use Task tool:
description: "Parallel: simplify error handling in src/services/user.ts"
prompt: [CoT prefix + task body for user.ts + critique suffix]
model: sonnet
[Task 2]
Use Task tool:
description: "Parallel: simplify error handling in src/services/order.ts"
prompt: [CoT prefix + task body for order.ts + critique suffix]
model: sonnet
[Task 3]
Use Task tool:
description: "Parallel: simplify error handling in src/services/payment.ts"
prompt: [CoT prefix + task body for payment.ts + critique suffix]
model: sonnet
[All 3 tasks launched simultaneously - results collected when all complete]
Parallelization Guidelines:
Context Isolation (IMPORTANT):
After each implementation agent completes, dispatch an independent judge for that target using the meta-judge's evaluation specification.
CRITICAL: Provide to the judge EXACT meta-judge's evaluation specification YAML, do not skip or add anything, do not modify it in any way, do not shorten or summarize any text in it!
Judge prompt template:
You are evaluating an implementation artifact for target {target_name} against an evaluation specification produced by the meta judge.
CLAUDE_PLUGIN_ROOT=`${CLAUDE_PLUGIN_ROOT}`
## User Prompt
{Original task description from user}
## Target
{Specific target: file path or component name}
## Evaluation Specification
```yaml
{meta-judge's evaluation specification YAML}
{Summary section from implementation agent} {Paths to files modified}
Follow your full judge process as defined in your agent instructions!
CRITICAL: You must reply with this exact structured evaluation report format in YAML at the START of your response!
CRITICAL: NEVER provide score threshold, in any format, including `threshold_pass` or anything different. Judge MUST not know what threshold for score is, in order to not be biased!!!
**Dispatch judge for each target:**
Use Task tool:
description: "Judge: {target name}"
prompt: {judge verification prompt with exact meta-judge specification YAML}
model: opus
subagent_type: "sadd:judge"
Parse judge output for each target (DO NOT read full report):
Extract from judge reply:
VERDICT: PASS or FAIL
SCORE: X.X/5.0
ISSUES: List of problems (if any)
IMPROVEMENTS: List of suggestions (if any)
Decision logic per target:
If score >= 4: -> VERDICT: PASS -> Mark target complete -> Include IMPROVEMENTS as optional enhancements
IF score >= 3.0 and all found issues are low priority, then: -> VERDICT: PASS -> Mark target complete -> Include IMPROVEMENTS as optional enhancements
If score < 4: -> VERDICT: FAIL -> Check retry count for this target
If retries < 3: -> Dispatch retry implementation agent with judge feedback -> Return to judge verification with same meta-judge specification
If retries >= 3: -> Mark target as failed (isolate from other targets) -> Do NOT proceed with more retries without user decision
**IMPORTANT: Failures are isolated**
- One target failing does NOT affect other targets
- Other parallel tasks continue independently
- Only the failed target is retried
#### 5.4 Retry with Feedback (If Needed)
**Retry prompt template:**
```markdown
## Retry Required for Target: {target_name}
Your previous implementation did not pass judge verification.
## Original Task
{Original task description}
## Target
{Specific target}
## Judge Feedback
VERDICT: FAIL
SCORE: {score}/5.0
ISSUES:
{list of issues from judge}
## Your Previous Changes
{files modified in previous attempt}
## Instructions
Let's fix the identified issues step by step.
1. Review each issue the judge identified
2. For each issue, determine the root cause
3. Plan the fix for each issue
4. Implement ALL fixes
5. Verify your fixes address each issue
6. Provide updated Summary section
CRITICAL: Focus on fixing the specific issues identified. Do not rewrite everything.
After all agents complete (with retries as needed), aggregate results:
## Parallel Execution Summary
### Configuration
- **Task:** {task description}
- **Model:** {selected model}
- **Targets:** {count} items
### Results
| Target | Model | Judge Score | Retries | Status | Summary |
|--------|-------|-------------|---------|--------|---------|
| {target_1} | {model} | {X.X}/5.0 | {0-3} | SUCCESS | {brief outcome} |
| {target_2} | {model} | {X.X}/5.0 | {0-3} | SUCCESS | {brief outcome} |
| {target_3} | {model} | {X.X}/5.0 | {3} | FAILED | {failure reason} |
| ... | ... | ... | ... | ... | ... |
### Overall Assessment
- **Completed:** {X}/{total}
- **Failed:** {Y}/{total}
- **Total Retries:** {sum of all retries}
- **Common patterns:** {any patterns across results}
### Verification Summary
{Aggregate judge verification results - any common issues?}
### Files Modified
- {list of all modified files}
### Failed Targets (If Any)
{For each failed target after max retries}
- **Target:** {name}
- **Final Score:** {X.X}/5.0
- **Persistent Issues:** {issues that weren't resolved}
- **Options:** Retry with guidance / Skip / Manual fix
### Next Steps
{If any failures, suggest remediation}
Failure Handling:
Input:
/do-in-parallel "Simplify error handling to use early returns instead of nested if-else" \
--files "src/services/user.ts,src/services/order.ts,src/services/payment.ts"
Analysis:
Model Selection: Sonnet (pattern-based, medium complexity)
Execution:
Phase 3.5: Dispatch Meta-Judge (ONCE)
Meta-judge (Opus)...
→ Generated evaluation specification YAML
→ 3 rubric dimensions, 5 checklist items
Phase 5: Parallel Dispatch
[All 3 implementation agents launched simultaneously]
Target: user.ts
Implementation (Sonnet)...
-> Converted 4 nested if-else blocks to early returns
Judge Verification (Opus, with meta-judge spec)...
-> VERDICT: PASS, SCORE: 4.2/5.0
-> IMPROVEMENTS: Consider extracting complex conditions
Target: order.ts
Implementation (Sonnet)...
-> Converted 6 nested if-else blocks to early returns
Judge Verification (Opus, with meta-judge spec)...
-> VERDICT: PASS, SCORE: 4.0/5.0
-> ISSUES: None
Target: payment.ts
Implementation (Sonnet)...
-> Converted 3 nested if-else blocks
Judge Verification (Opus, with meta-judge spec)...
-> VERDICT: FAIL, SCORE: 3.2/5.0
-> ISSUES: Missing edge case for null amount
Retry Implementation (Sonnet)...
-> Added null check for payment amount
Judge Verification (Opus, with same meta-judge spec)...
-> VERDICT: PASS, SCORE: 4.1/5.0
Result:
## Parallel Execution Summary
### Configuration
- **Task:** Simplify error handling to use early returns
- **Model:** Sonnet
- **Targets:** 3 files
### Results
| Target | Model | Judge Score | Retries | Status | Summary |
|--------|-------|-------------|---------|--------|---------|
| src/services/user.ts | sonnet | 4.2/5.0 | 0 | SUCCESS | Converted 4 nested if-else blocks |
| src/services/order.ts | sonnet | 4.0/5.0 | 0 | SUCCESS | Converted 6 nested if-else blocks |
| src/services/payment.ts | sonnet | 4.1/5.0 | 1 | SUCCESS | Converted 3 blocks, added null check |
### Overall Assessment
- **Completed:** 3/3
- **Total Retries:** 1
- **Total Agents:** 9 (1 meta-judge + 3 implementations + 1 retry + 4 judges)
- **Common patterns:** All files followed consistent early return pattern
Input:
/do-in-parallel "Generate JSDoc documentation for all public methods" \
--files "src/api/users.ts,src/api/products.ts,src/api/orders.ts,src/api/auth.ts"
Analysis:
Model Selection: Haiku (mechanical, well-defined rules)
Dispatch: 1 meta-judge + 4 parallel agents
Execution Summary:
| Target | Model | Judge Score | Retries | Status |
|---|---|---|---|---|
| src/api/users.ts | haiku | 4.0/5.0 | 0 | SUCCESS |
| src/api/products.ts | haiku | 3.8/5.0 | 0 | SUCCESS |
| src/api/orders.ts | haiku | 4.2/5.0 | 0 | SUCCESS |
| src/api/auth.ts | haiku | 4.1/5.0 | 0 | SUCCESS |
Total Agents: 9 (1 meta-judge + 4 implementations + 4 judges)
Input:
/do-in-parallel "Analyze for potential SQL injection vulnerabilities and suggest fixes" \
--files "src/db/queries.ts,src/db/migrations.ts,src/api/search.ts"
Analysis:
Model Selection: Opus (security-critical, requires deep analysis)
Dispatch: 1 meta-judge + 3 parallel agents
Execution Summary:
| Target | Model | Judge Score | Retries | Status |
|---|---|---|---|---|
| src/db/queries.ts | opus | 4.5/5.0 | 0 | SUCCESS |
| src/db/migrations.ts | opus | 4.3/5.0 | 0 | SUCCESS |
| src/api/search.ts | opus | 4.0/5.0 | 1 | SUCCESS |
Total Agents: 8 (1 meta-judge + 3 implementations + 1 retry + 3 judges)
Input:
/do-in-parallel "Generate unit tests achieving 80% coverage" \
--targets "UserService,OrderService,PaymentService,NotificationService"
Analysis:
Model Selection: Sonnet (pattern-based, extensive output)
Dispatch: 1 meta-judge + 4 parallel agents
Execution:
Phase 3.5: Meta-judge (Opus)
→ Generated evaluation specification YAML
→ 4 rubric dimensions, 7 checklist items
Target: UserService
-> Judge (Opus, with meta-judge spec): PASS, 4.3/5.0
Target: OrderService
-> Judge (Opus, with meta-judge spec): FAIL, 3.2/5.0 (missing edge cases)
-> Retry: Judge (Opus, same meta-judge spec): PASS, 4.0/5.0
Target: PaymentService
-> Judge (Opus, with meta-judge spec): FAIL, 2.8/5.0 (wrong mock patterns)
-> Retry 1: Judge (Opus, same meta-judge spec): FAIL, 3.0/5.0 (still missing scenarios)
-> Retry 2: Judge (Opus, same meta-judge spec): FAIL, 3.1/5.0 (coverage only 65%)
-> Retry 3: Judge (Opus, same meta-judge spec): FAIL, 3.2/5.0 (coverage at 72%)
-> MARKED FAILED after max retries
Target: NotificationService
-> Judge (Opus, with meta-judge spec): PASS, 4.1/5.0
Result:
| Target | Model | Judge Score | Retries | Status |
|---|---|---|---|---|
| UserService | sonnet | 4.3/5.0 | 0 | SUCCESS |
| OrderService | sonnet | 4.0/5.0 | 1 | SUCCESS |
| PaymentService | sonnet | 3.2/5.0 | 3 | FAILED |
| NotificationService | sonnet | 4.1/5.0 | 0 | SUCCESS |
Overall: 3/4 completed, 1 failed
Escalation for PaymentService:
### Failed Target: PaymentService
- **Final Score:** 3.2/5.0
- **Persistent Issues:**
- Test coverage at 72%, target is 80%
- Complex async scenarios not fully covered
- **Options:**
1. Provide guidance on specific async patterns to test
2. Accept 72% coverage as sufficient
3. Manual test writing for complex scenarios
Input:
/do-in-parallel "Apply consistent logging format to src/handlers/user.ts, src/handlers/order.ts, and src/handlers/product.ts"
Analysis:
Model Selection: Haiku (simple, mechanical)
Dispatch: 1 meta-judge + 3 parallel agents
Execution Summary:
| Target | Model | Judge Score | Retries | Status |
|---|---|---|---|---|
| src/handlers/user.ts | haiku | 4.2/5.0 | 0 | SUCCESS |
| src/handlers/order.ts | haiku | 4.0/5.0 | 0 | SUCCESS |
| src/handlers/product.ts | haiku | 4.1/5.0 | 0 | SUCCESS |
| Scenario | Model | Reason |
|---|---|---|
| Security analysis | Opus | Critical reasoning required |
| Architecture decisions | Opus | Quality over speed |
| Simple refactoring | Haiku | Fast, sufficient |
| Documentation generation | Haiku | Mechanical task |
| Code review per file | Sonnet | Balanced capability |
| Test generation | Sonnet | Extensive but patterned |
| Implementation Model | Judge Model | Rationale |
|---|---|---|
| Opus | Opus | Critical work needs strong verification |
| Sonnet | Opus | Tailored evaluation requires strong reasoning |
| Haiku | Opus | Verify simple work with strong evaluation |
Guideline: Judges always use Opus for consistent, high-quality evaluation across all targets.
| Failure Type | Description | Recovery Action |
|---|---|---|
| Recoverable | Judge found issues, retry available | Retry with judge feedback (max 3 per target) |
| Approach Failure | The approach for this target is wrong | Escalate to user with options |
| Foundation Issue | Requirements unclear or impossible | Escalate to user for clarification |
| Max Retries Exceeded | Target failed after 3 retries | Mark failed, continue other targets, report at end |
Critical Rules:
Weekly Installs
212
Repository
GitHub Stars
699
First Seen
Feb 19, 2026
Installed on
opencode207
github-copilot204
codex204
gemini-cli203
kimi-cli201
cursor201
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
147,400 周安装
opus |
| Optimize for quality over cost |