Back to Skills

coordinate-swarm

pjt222
Updated Yesterday
3 views
17
2
17
View on GitHub
Metaautomationdesign

About

This skill provides patterns for decentralized coordination in distributed systems using swarm intelligence concepts like stigmergy and local rules. It helps developers design systems where autonomous agents self-organize through environmental signals rather than central control. Use it when building resilient, event-driven architectures or replacing fragile orchestration with emergent coordination.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/coordinate-swarm

Copy and paste this command in Claude Code to install this skill

Documentation

協調群體

以共遺(stigmergy,藉環境之改動行間接通訊)、局部互動規則與法定感測,立分散代理間之協調——令連貫之集體行為無需中央控制者而生。

適用時機

  • 設計分散系統,無單一節點可為協調瓶頸者
  • 組織團隊或工作流,須自協調而不賴管理者常督
  • 建事件驅動架構,組件以共享狀態通訊而非直接傳訊
  • 擴展一法:三代理尚可,三十則崩
  • 為新群體式領域啟動協調模式(見 forage-resourcesbuild-consensus
  • 以韌之湧協調取脆之中央編排

輸入

  • 必要:須協調之代理(工者、服務、團員)之述
  • 必要:集體目標或所欲之湧行為
  • 選擇性:當前協調機制及其敗模
  • 選擇性:代理之數(影響模式擇——小群與大殖民之別)
  • 選擇性:延遲容忍(即時與終局協調)
  • 選擇性:環境約束(共享狀態之得、通訊頻寬)

步驟

步驟一:辨協調問題之類

分協調挑戰之類以擇當之模式。

  1. 繪當前態:代理為誰、其獨行何事、協調於何崩
  2. 分問題:
    • 探尋(Foraging) — 代理搜並利散佈之資源(見 forage-resources
    • 共識(Consensus) — 代理須同一集體決定(見 build-consensus
    • 建造(Construction) — 代理漸建或維持共享結構
    • 防禦(Defense) — 代理集體偵威而應(見 defend-colony
    • 分工 — 代理須自組織為專門之角色
  3. 辨當前協調之敗模:
    • 單點之敗(中央控制者)
    • 通訊瓶頸(直接傳訊過多)
    • 連貫之失(代理無回饋而漸離)
    • 僵(不能應變之條件)

預期: 協調問題類與待處之具體敗模之明分類。此定何群體模式可施。

失敗時: 若問題不合單類,或為複合。分為子問題而各以當之模式處之。若代理異質甚、不合單一協調模型,考慮分層協調——同質之群以跨群之共遺協調。

步驟二:設共遺信號

建間接通訊之道,藉之代理互影響行為。

  1. 定共享環境(資料庫、訊息佇列、檔案系統、實體空間、共享板)
  2. 設代理存入環境之信號:
    • 徑信號:沿成功路積之標記(如蟻之費洛蒙)
    • 閾信號:計數器,越閾則觸行為變
    • 抑制信號:標記,斥代理離已竭之域
  3. 定信號之性:
    • 衰減率:信號消之速(防陳舊狀態主導)
    • 增強:成功之果如何強信號
    • 可見半徑:信號傳之遠
  4. 映信號於代理行為:
    • 代理偵得信號 X 過閾 T 則行動作 A
    • 代理成完動作 A 則存信號 Y
    • 偵無信號時,代理循其預設之探尋行為
Signal Design Template:
┌──────────────┬───────────────────┬──────────────┬────────────────────┐
│ Signal Name  │ Deposited When    │ Decay Rate   │ Agent Response     │
├──────────────┼───────────────────┼──────────────┼────────────────────┤
│ success-trail│ Task completed OK │ 50% per hour │ Follow toward      │
│ busy-marker  │ Agent starts task │ On completion│ Avoid / pick other │
│ help-signal  │ Agent stuck >5min │ 25% per hour │ Assist if nearby   │
│ danger-flag  │ Error detected    │ 10% per hour │ Retreat & report   │
└──────────────┴───────────────────┴──────────────┴────────────────────┘

預期: 信號表,映環境標記於代理存置之條件、衰減率、應對行為。信號當簡、可組、且各自有義。

失敗時: 若信號設計覺過繁,減為二:一正(成功徑)一負(危旗)。多數協調問題可以吸斥動力啟動。唯於基本系統行後乃加微妙。

步驟三:定局部互動規則

列各代理所循之簡規,唯用局部資訊(己之狀態加附近信號)。

  1. 定代理之感知半徑(其能感何者?)
  2. 按優先序寫三至七局部規則:
    • 規則一(安全):偵危旗則避
    • 規則二(應):偵求援信號且閒則趨
    • 規則三(利用):偵成功徑則趨最強信號
    • 規則四(探):無信號則隨機移,偏未探之域
    • 規則五(存):完任務則於該位存成功徑
  3. 各規則必:
    • 局部:唯賴該代理可直接感知者
    • :可以單一 if-then 述之
    • 無狀態(佳):不需代理憶往態
  4. 心中測之:若每代理皆循此規則,所欲之集體行為是否湧現?

預期: 優先序之規則集,各代理獨立執之。施於群體,此局部規則產目標集體行為(探尋、建造、防禦等)。

失敗時: 若心中模擬不產所欲之湧行為,規則或缺回饋環——代理須能觀其集體行動之果。加一信號以表集體狀態(如「任務完成率」),加一規則以其調行為。

步驟四:校準法定感測

設閾,足代理同意時觸集體狀態之變。

  1. 辨需集體同意之決定(非單獨應):
    • 由探切至利用模式
    • 定新工位或棄舊者
    • 由常態升至應急應對
  2. 各集體決定定:
    • 法定閾:同意之代理數或百分比
    • 感測窗:計信號之時段
    • 遲滯:激活與去活之閾不同(防振盪)
  3. 實作法定為信號積累:
    • 偏此決定之各代理存投票信號
    • 積票於感測窗內過法定閾,決定激活
    • 票降過去活閾,決定逆轉

預期: 法定閾令群體無領袖而能作集體決定。遲滯之差防狀態間之疾振。

失敗時: 若群體於狀態間振盪,增遲滯之差(如:激活於 70%、去活於 30%)。若群體不達法定,降閾或增感測窗。若決定過遲,縮感測窗——然須防早熟共識。

步驟五:測並調湧行為

驗局部規則產所欲之集體行為,繼之調參。

  1. 以小數代理(5-10)行模擬或試點
  2. 觀:
    • 群體是否收斂於所欲之行為?
    • 收斂需時幾何?
    • 任務中條件變時何如?
    • 代理敗或增時何如?
  3. 調參:
    • 信號衰減率:過速則無協調記憶;過緩則陳舊信號主導
    • 法定閾:過低則早熟集體決定;過高則癱瘓
    • 探-利之衡:探過則低效;利過則困於局部最優
  4. 壓力測:
    • 驟移 30% 代理——群體可復乎?
    • 倍代理數——群體仍能協調乎?
    • 引入矛盾信號——群體解之或死鎖?

預期: 調好之參集,令群體自組織向目標行為、擾後復原、優雅擴展。

失敗時: 若群體壓力測敗,信號設計或耦合過緊。簡之:減信號、增衰減率(新鮮資訊)、確保代理於無信號時有韌之預設行為。無信號時仍行合理之群體勝於賴信號可得之群體。

驗證

  • 協調問題已分為可辨之模式(探尋、共識、建造、防禦、分工)
  • 共遺信號表已定,含存置條件、衰減率、代理應對
  • 局部互動規則簡、局部、有優先序(3-7 則)
  • 法定閾已設遲滯以防振盪
  • 小規模測顯湧行為合集體目標
  • 壓力測(代理移、增、信號擾)顯優雅之退化

常見陷阱

  • 過工程化信號:始以過多信號類生惑。始於二信號(吸/斥),證必要乃加
  • 偽裝之中央思維:若「局部規則」需代理知全局狀態,非局部。重構至各規則僅賴代理直接可感之者
  • 忽衰減:永不衰之信號生化石化之協調狀態。各信號皆需合任務時尺之半衰期
  • 無遲滯:法定閾於激活與去活間無差生疾振。去活恒低於激活
  • 假同質:若代理能力異,單規則集或不行。考慮分角色之規則(見 scale-colony

相關技能

  • forage-resources — 施群體協調於資源搜與探-利取捨
  • build-consensus — 深入分散同意機制,延此技能之法定感測
  • defend-colony — 集體防禦模式,建於此信號與規則架構上
  • scale-colony — 群體超初協調設計時之擴展策略
  • adapt-architecture — 變系統架構之變形技能,群體協調觸結構變時互補
  • deploy-to-kubernetes — 實用之分散系統部署,群體協調模式適用
  • plan-capacity — 依群體擴展動力之容量計劃
  • coordinate-reasoning — AI 自我適用之變體;映共遺信號於脈絡管理,含資訊衰減率與局部協議

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-lite/skills/coordinate-swarm
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

polymarket

Meta

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

View skill

creating-opencode-plugins

Meta

This skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill