Community程式設計與開發github.com

平行派送代理任務

當面臨兩個以上彼此獨立、無共享狀態或順序相依性的工作時,可平行派送多個專精代理任務,同時處理,節省時間。

平行派送代理任務 是什麼?

此技能「平行派送代理任務」專為需要同時處理多個獨立問題的場景設計。它的核心價值在於讓你在同一則回應中發出多個子代理的派送指令,這些代理便會平行執行,避免逐一調查的耗時浪費。技能會引導你將不相關的失敗(例如不同測試檔案、不同子系統)分組為獨立的問題領域,然後為每個領域建立一個專注、自包含的任務提示(prompt),給予明確的範圍、目標和限制。此技能廣泛適用於支援平行代理架構的平台(如 Claude Code、Cursor 等),尤其適合測試修復、子系統除錯或任何不需共享狀態的多人協作場景。關鍵在於確保不會讓代理繼承你目前的對話上下文,而是為它們構造精確所需的資訊,最終透過檢視摘要與整合變更來完成工作。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/obra/superpowers/tree/main/skills/dispatching-parallel-agents

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

平行派送代理任務 是做什麼的?

總覽

你將任務委派給擁有隔離上下文的專精代理。透過精準建構它們的指令與上下文,你確保它們能保持專注並成功完成任務。它們永遠不應繼承你工作階段的上下文或歷史記錄——你只為它們建構所需的一切。這同時也保留了你自己用於協調工作的上下文。

當你遇到多個彼此不相關的失敗(不同的測試檔案、不同的子系統、不同的錯誤)時,循序調查會浪費時間。每個調查都是獨立的,可以同時進行。

核心原則: 為每個獨立的問題領域派送一個代理,讓它們並行工作。

使用時機

digraph when_to_use {
    "多個失敗?" [shape=diamond];
    "它們彼此獨立嗎?" [shape=diamond];
    "單一代理調查所有" [shape=box];
    "每個問題領域一個代理" [shape=box];
    "它們可以平行進行嗎?" [shape=diamond];
    "循序代理" [shape=box];
    "平行派送" [shape=box];

    "多個失敗?" -> "它們彼此獨立嗎?" [label="是"];
    "它們彼此獨立嗎?" -> "單一代理調查所有" [label="否 - 相關"];
    "它們彼此獨立嗎?" -> "它們可以平行進行嗎?" [label="是"];
    "它們可以平行進行嗎?" -> "平行派送" [label="是"];
    "它們可以平行進行嗎?" -> "循序代理" [label="否 - 共享狀態"];
}

使用時機:

  • 3 個以上的測試檔案因不同根本原因而失敗
  • 多個子系統各自獨立受損
  • 每個問題不需倚賴其他問題的上下文即可理解
  • 調查之間沒有共享狀態

不應使用時機:

  • 失敗彼此相關(修正一個可能連帶修正其他)
  • 需要了解完整的系統狀態
  • 代理之間會互相干擾

模式

1. 識別獨立領域

根據什麼東西壞了來將失敗分組:

  • 檔案 A 測試:工具核准流程
  • 檔案 B 測試:批次完成行為
  • 檔案 C 測試:中止功能

每個領域都是獨立的——修正工具核准不會影響中止測試。

2. 建立專注的代理任務

每個代理獲得:

  • 特定範圍: 一個測試檔案或子系統
  • 明確目標: 讓這些測試通過
  • 限制條件: 不要變更其他程式碼
  • 預期輸出: 你發現了什麼以及修正了什麼的摘要

3. 平行派送

在同一則回應中發出所有子代理的派送——它們會平行執行:

子代理(通用用途):「修正 agent-tool-abort.test.ts 中的失敗」
子代理(通用用途):「修正 batch-completion-behavior.test.ts 中的失敗」
子代理(通用用途):「修正 tool-approval-race-conditions.test.ts 中的失敗」
# 三個會同時執行。

在一則回應中發出多個派送呼叫 = 平行執行。每則回應一個 = 循序執行。

4. 檢視與整合

當代理回傳時:

  • 閱讀每個摘要
  • 驗證修正內容沒有衝突
  • 執行完整測試套件
  • 整合所有變更

代理提示結構

好的代理提示具有以下特點:

  1. 專注 - 一個清晰的問題領域
  2. 自包含 - 理解問題所需的全部上下文
  3. 明確指定輸出 - 代理應回傳什麼?
修正 src/agents/agent-tool-abort.test.ts 中失敗的 3 個測試:

1. "should abort tool with partial output capture" - 預期在訊息中看到 'interrupted at'
2. "should handle mixed completed and aborted tools" - 快速工具被中止而非完成
3. "should properly track pendingToolCount" - 預期 3 個結果但得到 0

這些是時序/競態條件問題。你的任務:

1. 閱讀測試檔案並理解每個測試驗證什麼
2. 找出根本原因 - 是時序問題還是真正的錯誤?
3. 透過以下方式修正:
   - 將任意逾時取代為基於事件的等待
   - 若發現中止實作中的錯誤則修正
   - 若測試是在測試已變更的行為,則調整測試預期

不要只是增加逾時時間——找出真正的問題。

回傳:你發現了什麼以及修正了什麼的摘要。

常見錯誤

❌ 範圍太廣:「修正所有測試」- 代理會迷失方向 ✅ 明確指定:「修正 agent-tool-abort.test.ts」- 範圍專注

❌ 沒有上下文:「修正競態條件」- 代理不知道在哪裡 **✅ 提供上下文:**貼上錯誤訊息和測試名稱

❌ 沒有限制: 代理可能會重構所有東西 ✅ 設定限制:「不要變更正式環境程式碼」或「只修正測試」

❌ 輸出模糊:「修正它」- 你不知道改變了什麼 ✅ 明確指定:「回傳根本原因與變更的摘要」

何時不應使用

相關失敗: 修正一個可能連帶修正其他——先一起調查 需要完整上下文: 理解需要看到整個系統 探索性除錯: 你還不知道什麼東西壞了 共享狀態: 代理會互相干擾(編輯同一檔案、使用相同資源)

實際工作階段範例

情境: 大型重構後有 6 個測試失敗,分佈在 3 個檔案中

失敗:

  • agent-tool-abort.test.ts:3 個失敗(時序問題)
  • batch-completion-behavior.test.ts:2 個失敗(工具未執行)
  • tool-approval-race-conditions.test.ts:1 個失敗(執行計數 = 0)

決策: 獨立領域——中止邏輯、批次完成、競態條件各自獨立

派送:

代理 1 → 修正 agent-tool-abort.test.ts
代理 2 → 修正 batch-completion-behavior.test.ts
代理 3 → 修正 tool-approval-race-conditions.test.ts

結果:

  • 代理 1:將逾時取代為基於事件的等待
  • 代理 2:修正事件結構錯誤(threadId 放錯位置)
  • 代理 3:加入等待非同步工具執行完成

整合: 所有修正彼此獨立,無衝突,完整測試套件全數通過

驗證

在代理回傳之後:

  1. 檢視每個摘要 - 了解變更了什麼
  2. 檢查衝突 - 代理是否編輯了同一段程式碼?
  3. 執行完整套件 - 驗證所有修正能一起運作
  4. 抽樣檢查 - 代理可能犯系統性錯誤

Individual skills in this repo

This repo contains 14 individual skills — each has its own dedicated page.

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

diagnosing-superpowers

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

executing-plans

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

finishing-a-development-branch

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

receiving-code-review

Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation

requesting-code-review

Use when completing tasks, implementing major features, or before merging to verify work meets requirements

subagent-driven-development

Use when executing implementation plans with independent tasks in the current session

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

test-driven-development

Use when implementing any feature or bugfix, before writing implementation code

using-git-worktrees

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback

using-superpowers

Use when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions

verification-before-completion

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

writing-plans

Use when you have a spec or requirements for a multi-step task, before touching code

writing-skills

Use when creating new skills, editing existing skills, or verifying skills work before deployment

相關技能