Communitygithub.com

SamuelChien/mega-skills-collection

透過檔案系統協調 Claude Code 代理團隊。用於協調多個 Claude 代理執行平行任務、管理任務依賴、進行多代理程式碼審查或實作。不適用於單一代理可完成的工作或不可平行化的任務。

mega-skills-collection 是什麼?

此技能提供了一個基於檔案系統的協定,讓多個 Claude CLI 程序能夠協作處理共享工作。每個團隊成員在獨立的 tmux 窗格中執行,透過使用 `fcntl` 鎖保護的 JSON 檔案進行通訊,無需資料庫、守護行程或網路層。它支援平行實作、多代理程式碼審查以及大型重構等需要自然平行性的任務。技能涵蓋團隊建立、成員生成、任務依賴管理、訊息傳遞協定、健康監控以及與 Conjure 委派模型的整合。需要注意的是,此技能不適用於單一檔案變更或需要緊密順序推理的任務,因為維護多個代理的開銷可能超過其效益。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/agent-teams

在你喜歡的 AI 中提問

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

說明文件

目錄

代理團隊協調

概述

Claude Code 代理團隊能讓多個 Claude CLI 程序透過基於檔案系統的協定協作處理共享工作。每個團隊成員以獨立的 claude 程序在 tmux 窗格中執行,透過由 fcntl 鎖保護的 JSON 檔案進行通訊。無需資料庫、無需守護行程、無需網路層。

此技能提供有效協調代理團隊的範本。

使用時機

  • 跨多個檔案或模組的平行實作
  • 多代理程式碼審查(一個代理審查,另一個代理實作修正)
  • 需要跨子系統協調變更的大型重構
  • 受益於並行代理的自然平行任務

何時不應使用

  • 單一檔案變更或小型任務(開銷超過效益)
  • 需要緊密順序推理的任務(代理之間協調鬆散)
  • 當無法使用 claude CLI 或未安裝 tmux 時

先決條件

# 驗證 Claude Code CLI
claude --version

# 驗證 tmux(分割窗格模式需要)
tmux -V

# 啟用實驗性功能(生成器會自動設定)
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

協定架構

~/.claude/
  teams/<團隊名稱>/
    config.json            # 團隊元資料 + 成員名冊
    inboxes/
      <代理名稱>.json    # 每個代理的訊息佇列
      .lock                # fcntl 獨佔鎖
  tasks/<團隊名稱>/
    1.json ... N.json      # 自動遞增的任務檔案
    .lock                  # fcntl 獨佔鎖

設計原則:

  • 檔案系統即資料庫:JSON 檔案,透過 tempfile + os.replace 進行原子寫入
  • fcntl 鎖定:防止對收件匣和任務的並發讀寫損壞
  • 編號任務:使用自動遞增 ID 與連續檔案命名
  • 鬆散耦合:代理輪詢自己的收件匣;無推送通知

快速開始

1. 建立團隊

# 程式化團隊設定(透過 MCP 或直接 API)
# 團隊設定寫入至 ~/.claude/teams/<團隊名稱>/config.json

團隊設定包含:

  • name、description、created_at(毫秒時間戳)
  • lead_agent_id、lead_session_id
  • members[] — LeadMember 和 TeammateMember 物件的陣列

2. 生成團隊成員

每個團隊成員都是一個獨立的 claude CLI 程序,並使用身分識別旗標啟動:

claude --agent-id "backend@my-team" \
       --agent-name "backend" \
       --team-name "my-team" \
       --agent-color "#FF6B6B" \
       --parent-session-id "$SESSION_ID" \
       --agent-type "general-purpose" \
       --model sonnet

請參閱 modules/spawning-patterns.md 了解 tmux 窗格管理和顏色指派。

3. 建立具有依賴關係的任務

{
  "id": "1",
  "subject": "實作 API 端點",
  "description": "為使用者管理建立 REST 端點",
  "status": "pending",
  "owner": null,
  "blocks": ["3"],
  "blocked_by": [],
  "metadata": {}
}

請參閱 modules/task-coordination.md 了解狀態機和依賴管理。

4. 透過訊息進行協調

{
  "from": "team-lead",
  "text": "API 端點已準備好進行整合測試",
  "timestamp": "2026-02-07T22:00:00Z",
  "read": false,
  "summary": "API 已就緒"
}

請參閱 modules/messaging-protocol.md 了解訊息類型和收件匣操作。

協調工作流程

  1. agent-teams:team-created — 初始化團隊設定和目錄
  2. agent-teams:teammates-spawned — 在 tmux 窗格中啟動代理
  3. agent-teams:tasks-assigned — 建立具有依賴關係的任務,指派擁有者
  4. agent-teams:coordination-active — 代理認領任務、交換訊息、標記完成
  5. agent-teams:team-shutdown — 透過核准協定優雅關閉

團隊角色

每個團隊成員都有一個 role,決定其能力和任務相容性。定義了五種角色:implementer(實作者,預設)、researcher(研究員)、tester(測試員)、reviewer(審查員)和 architect(架構師)。角色限制了代理可以處理的風險等級 — 請參閱 modules/crew-roles.md 了解完整能力矩陣和角色風險相容性表格。

健康監控

團隊成員的健康狀況可透過心跳訊息和認領到期進行監控。負責人每 60 秒輪詢團隊健康狀態,採用 2 階段停滯檢測協定(health_check 探測 + 30 秒等待)。停滯代理的任務會被釋放,並按照「替換而非等待」的原則重啟或更換。請參閱 modules/health-monitoring.md 了解完整的協定和狀態機。

模組參考

  • team-management.md:團隊生命週期、設定格式、成員管理
  • messaging-protocol.md:訊息類型、收件匣操作、鎖定模式
  • task-coordination.md:任務 CRUD、狀態機、依賴循環檢測
  • spawning-patterns.md:tmux 生成、CLI 旗標、窗格管理
  • crew-roles.md:角色分類、能力矩陣、角色風險相容性
  • health-monitoring.md:心跳協定、停滯檢測、自動復原

與 Conjure 整合

代理團隊擴展了 conjure 委派模型:

Conjure 模式代理團隊等效模式
delegation-core:task-assessedagent-teams:team-created
delegation-core:handoff-plannedagent-teams:tasks-assigned
delegation-core:results-integratedagent-teams:team-shutdown
外部 LLM 執行團隊成員代理執行

首先使用 Skill(conjure:delegation-core) 來判斷任務是否受益於多代理協調而非單一服務委派。

工作樹隔離替代方案(Claude Code 2.1.49+)

對於修改檔案的平行代理,isolation: worktree 提供了基於檔案系統協調的輕量級替代方案。每個代理在其自己的臨時 git 工作樹中執行,無需 fcntl 鎖定或基於收件匣的衝突避免機制來處理共享檔案。

  • 何時偏好工作樹而非代理團隊訊息:代理處理重疊檔案但不需要中執行通訊
  • 何時偏好代理團隊訊息:代理需要協調發現或根據彼此的進度調整計畫
  • 兩者結合使用:使用代理團隊進行協調,同時為每個團隊成員使用 isolation: worktree 以確保檔案系統安全

疑難排解

常見問題

找不到 tmux 透過套件管理器安裝:brew install tmux / apt install tmux

過時的鎖定檔案 如果代理在中途崩潰,鎖定檔案可能會持續存在。手動從 ~/.claude/teams/<團隊>/inboxes/ 或 ~/.claude/tasks/<團隊>/ 中移除 .lock 檔案。

孤兒任務 由崩潰代理認領的任務會無限期保持 in_progress 狀態。使用 modules/health-monitoring.md 進行基於心跳的停滯檢測和自動任務釋放。健康監控協定可在 60 秒 + 30 秒探測視窗內檢測到無回應的代理,並釋放其任務以供重新指派。

訊息順序 檔案系統時間戳解析度各不相同(HFS+ 為 1 秒)。使用編號檔案名稱或 UUID 排序名稱,以避免在快速訊息突發時發生衝突。

Bedrock/Vertex/Foundry 上的模型錯誤(2.1.39 之前版本) 團隊成員代理可能在企業供應商上使用錯誤的模型識別碼,導致 400 錯誤。請升級至 Claude Code 2.1.39+ 以在所有供應商上獲得正確的模型 ID 限定。

巢狀會話防護(2.1.39+) 如果 claude 拒絕在現有會話內啟動,請確保您使用的是 tmux 窗格分割(而非子 shell 調用)。此防護是有意的 — 請參閱 modules/spawning-patterns.md 了解詳細資訊。

完成條件

  • 已建立團隊,包含設定和目錄
  • 團隊成員已生成並在設定中註冊
  • 已建立任務,包含依賴關係圖(無循環)
  • 代理正在透過收件匣訊息進行協調
  • 已完成優雅關閉

Individual skills in this repo

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

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

相關技能