跳到主要內容

Claude Code Agent Teams (Complete Guide) and how to

Claude Code’s Agent Teams feature marks a shift from sequential tasking to parallel, collaborative orchestration. While community tools like OpenClaw pioneered this "swarm" approach, Anthropic has now integrated it natively into the Claude Code research preview.


1. Prerequisites for Installation

Before enabling the feature, ensure you have the correct environment:

  • Claude Code Version: You should be on version 2.1.32 or higher.

  • Terminal Multiplexer (Optional but Recommended): For "split-pane mode," you’ll need tmux (Linux/macOS) or iTerm2 (macOS).

  • CLAUDE.md: Every teammate loads this file automatically. Use it to define global project standards so you don't waste tokens re-explaining rules to every new teammate.


2. How to Enable Agent Teams

Agent teams are experimental and disabled by default. You can activate them in 30 seconds:

Option A: Persistent (Recommended)

Add the following to your ~/.claude/settings.json file:

JSON
{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
  }
}

Option B: Session-Based

Export the variable directly in your terminal before running Claude:

  • macOS/Linux: export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

  • Windows (PowerShell): $env:CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS="1"


3. Starting Your First Team

Once enabled, you don't need a specific command like /start-team. You simply prompt the lead agent to create one.

Example Prompt:

"I need to refactor the authentication module. Create an agent team: one teammate to rewrite the API routes, one to update the frontend hooks, and one to write integration tests for the new flow."

Selection of Display Modes

  • In-Process (Default): All teammates run inside your current terminal. Use Shift + Up/Down to cycle through their views.

  • Split-Pane: If you are inside a tmux session, Claude will automatically open new panes for each teammate. This is the best way to watch the "swarm" work in real-time.


4. Key Controls & "Delegate Mode"

Managing a team requires different shortcuts than a solo session:

ActionShortcut / Command
Switch TeammateShift + Up / Shift + Down
Toggle Delegate ModeShift + Tab
Direct MessageSelect the teammate's view and type normally.
Task ManagementAsk the lead to "show the task list" or "reassign task X to teammate Y."

Pro Tip: Delegate Mode

When you toggle Delegate Mode, the Lead Agent stops trying to write code itself. It becomes a pure "Project Manager," focusing solely on coordinating teammates and managing the shared task list.


5. Best Practices & Token Management

Because each teammate is a fully independent Claude session, token usage can scale rapidly.

  • Avoid File Collisions: Never assign two teammates to the same file. They will overwrite each other's work.

  • Research First: Teams excel at "Competing Hypotheses." If you have a bug, tell the team: "Teammate A, investigate if this is a memory leak; Teammate B, check the database connection pool."

  • Explicit Shutdown: When a teammate finishes, tell the lead: "Shut down the testing agent." Always run the /cleanup command through the Lead Agent once the project is finished to clear shared resources.


6. Current Limitations (Research Preview)

  • No Session Resumption: If your main session crashes, in-process teammates cannot be "resumed" easily. You will likely need to spawn a new team.

  • One Team per Session: You cannot run multiple independent teams from the same lead session.

  • No Nested Teams: A teammate cannot currently spawn its own "sub-team."

Would you like me to help you draft a specific CLAUDE.md file to help your agents coordinate better on your current project?

留言

這個網誌中的熱門文章

Vibe Coding:到底?氛圍驅動程式開發必殺技?

Vibe Coding(氛圍編程) 是由 OpenAI 共同創辦人 Andrej Karpathy 在 2025 年提出的革命性程式開發方式,它讓開發者透過自然語言與 AI 對話來生成程式碼,徹底改變了傳統的編程模式。 這種開發方式的核心理念是 「順著感覺走」 ,讓 AI 處理技術細節,開發者專注於創意和需求描述。 Vibe Coding 需要基本上的規劃和執行,但並沒有強制規範,從日常經驗來說可分為三個階段, 前期準備、開發過程、和後期維護 三個關鍵階段。每個階段都有其特定的任務和注意事項,正確執行這些步驟將大幅提升開發效率和程式品質。 將靈感與需求透過 AI 快速轉化成產品功能或原型。以下幫你分成 「前、中、後」 三階段要做的事情,適合你自己做、或帶團隊做 前期:設定 vibe & 準備素材 這個階段的重點是 「建立開發語境」 ,因為 AI 的生成表現高度依賴前期提供的上下文與資料。 明確目標 :釐清要解決的問題、預期要做的功能與核心價值。例如在筆記軟體的情境中,可能是:「我要做一款讓使用者能用 Markdown 記錄筆記,並提供標籤與全文搜尋功能的簡單 App。」 收集靈感 :觀察同類產品(如 Obsidian、Notion)、蒐集市場痛點(例如太多筆記軟體無法脫機使用,或同步效能差)。 建立語境 :準備初步 prompt、背景知識、產品定位、品牌調性、目標使用者輪廓等。 確認資源 :決定用哪些工具(Gemini、ChatGPT、設計軟體、流程管理工具等)。 確認完上述內容之後,就可以先開始進行準備規格,進行第一次的 Vibe Coding 方向驗證 提示詞模板準備 很多人會跳過這步驟,但一份 「好的 AI 提示詞模板」 將決定接下來每一次 AI 對話的品質。有效的提示詞模板需具備: 描述具體且無歧義 包含技術要求和約束條件 提供範例資料和測試案例 指定程式碼風格和慣例 例如針對筆記軟體的案例:   「建立一個支援 AI 功能純文字筆記,輸入內容可即時渲染;需支援儲存到本地檔案,提供標籤欄位做分類;以 React 架構,程式風格採用 Tailwind style components 並使用 hooks。」 開發工具選擇 開發工具的選擇 同樣重要,目前市場上主要的 ...

Claude Code Hooks:自動化與安全的最佳實踐

寫在最前頭,這份文章主要寫起來是給自己看, 同時內容是比較適合開發者,工程師們可以做些自動化處理的簡單筆記。 Claude Code hooks Claude Code hooks 是一種強大的自動化機制,允許用戶在 Claude Code 的不同生命週期階段,自定義執行 shell 指令。這種設計讓開發者能夠將規則和自動化行為嵌入到應用層級,確保每次都能可靠執行,而不必依賴 LLM(大型語言模型)是否會選擇執行某項操作。 Hooks 的核心用途 通知 :自訂收到 Claude Code 等待用戶輸入或執行權限時的提醒方式。 自動格式化 :如在每次檔案編輯後自動執行 prettier (針對 .ts 檔)、 gofmt (針對 .go 檔)等。 日誌記錄 :追蹤所有執行過的命令,便於合規或除錯。 自動反饋 :當 Claude Code 產生不符合團隊規範的程式碼時,自動給出反饋。 自訂權限 :阻擋對生產環境檔案或敏感目錄的修改[^1]。 配置與結構 Hooks 透過設定檔進行配置,分為全域( ~/.claude/settings.json )、專案( .claude/settings.json )、本地專案( .claude/settings.local.json )以及企業級策略設定。每個 hook 由「事件名稱」和「匹配器」組成: "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "jq -r '...'" } ] } ] } matcher :用於匹配工具名稱(支援正則表達式),如 Write 、 Edit|Write 、 Notebook.* 。 hooks :當匹配時要執行的命令陣列。 type :目前僅支援 "command" 。 ...

[CSS] z-index 在不同瀏覽器繼承問題

今天會討論到這個課題,是因為要實做一個Popup dialog,所以我們希望的結果如下圖。 可是在IE7 卻發生了這樣的情況。 Popup不論怎麼設定z-index都無法浮在最上層,我們看一下html架構發生什麼事情。