Skip to content

Latest commit

 

History

History
102 lines (78 loc) · 4.65 KB

File metadata and controls

102 lines (78 loc) · 4.65 KB

Agent 团队实现

最后更新

← 返回 Claude Code 最佳实践 Claude

已实现

Agent 团队协作 — tmux 分屏模式

Agent 团队启动多个独立的 Claude Code 会话,通过共享任务列表进行协调。与子代理(一个会话内的独立上下文分支)不同,每个团队成员获得自己的完整上下文窗口,自动加载 CLAUDE.md、MCP 服务器和技能。


使用方法

时间编排工作流完全由 agent 团队构建。要运行成品:

cd agent-teams
claude
/time-orchestrator

这调用了命令 → Agent → 技能管道:agent 获取迪拜当前时间,技能将 SVG 时间卡渲染到 agent-teams/output/dubai-time.svg


实现方法

你可以使用 agent 团队复现天气编排工作流 —— 在这个示例中,时间编排工作流完全由 agent 团队构建。

1. 安装 iTerm2 和 tmux

brew install --cask iterm2
brew install tmux

2. 启动 iTerm2 → tmux → Claude

tmux new -s dev
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude

3. 使用团队结构进行提示

粘贴此提示到 Claude 以使用 agent 团队引导完整的时间编排器工作流:

主提示:agent-teams-prompt.md

团队协调流程

┌──────────────────────────────────────────────────────────────┐
│                         负责人(你)                           │
│       "创建一个 agent 团队来构建时间编排器"                      │
└──────────────────────────┬───────────────────────────────────┘
                           │ 生成团队(全部并行)
              ┌────────────┼────────────┐
              ▼            ▼            ▼
   ┌────────────────┐ ┌──────────┐ ┌──────────────┐
   │ 命令           │ │ Agent    │ │ 技能         │
   │ 架构师         │ │ 工程师   │ │ 设计师       │
   │                │ │          │ │              │
   │ agent-teams/   │ │ agent-   │ │ agent-teams/ │
   │ .claude/       │ │ teams/   │ │ .claude/     │
   │ commands/      │ │ .claude/ │ │ skills/      │
   │ time-          │ │ agents/  │ │ time-svg-    │
   │ orchestrator.md│ │ time-    │ │ creator/     │
   │                │ │ agent.md │ │              │
   └───────┬────────┘ └────┬─────┘ └──────┬───────┘
           │               │              │
           ▼               ▼              ▼
   ┌──────────────────────────────────────────────────┐
   │            共享任务列表                             │
   │  ☐ 就数据契约达成一致:{time, tz, formatted}        │
   │  ☐ 命令使用 Agent 工具(而非 bash)                │
   │  ☐ Agent 预加载 time-fetcher 技能                 │
   │  ☐ 技能从上下文读取时间(不重新获取)               │
   │  ☐ 所有文件都在 agent-teams/.claude/ 内            │
   └──────────────────────────────────────────────────┘
                       │
                       ▼
          ┌──────────────────────────────┐
          │  cd agent-teams && claude    │
          │    /time-orchestrator        │
          │   命令 → Agent → 技能        │
          └──────────────────────────────┘