with one click
team
基于 Kimi CLI 原生 team 能力,让 N 个 agent 协调工作在共享任务列表上
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
基于 Kimi CLI 原生 team 能力,让 N 个 agent 协调工作在共享任务列表上
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
oh-my-kimi 的目录入口,包含面向 Kimi CLI 的 agent、skill、hook 与 MCP 套件,衍生自 oh-my-* 谱系。
面向密钥、注入、authz/authn、不安全 IO、依赖与数据外泄风险的安全评审
证据驱动的追踪通道,在 Kimi 的 Agent 工具中编排互相竞争的 tracer 假设
LLM Wiki —— 跨会话持续累积的 markdown 知识库(Karpathy 模型)
面向作家的 agentic 记忆系统 —— 跟踪人物、关系、场景与主题
跑只读的深度仓库分析,返回一份带置信度排序的综合结论,附具体文件引用、清晰区分证据与推断。当用户说 'analyze'、'investigate'、'why does'、'what's causing',或在提任何改动方案之前需要跨文件的有据解释时使用。
| name | team |
| description | 基于 Kimi CLI 原生 team 能力,让 N 个 agent 协调工作在共享任务列表上 |
| argument-hint | [N:agent-type] [ralph] <task description> |
| aliases | [] |
| level | 4 |
利用 Kimi CLI 的原生 team 工具,派出 N 个协调工作的 agent 共享同一个任务列表。它用内置的 team 管理、agent 之间消息传递与任务依赖替代了旧版 /swarm skill(基于 SQLite)—— 无需任何外部依赖。
swarm 兼容别名已在 #1131 中移除。
/oh-my-kimi:team N:agent-type "task description"
/oh-my-kimi:team "task description"
/oh-my-kimi:team ralph "task description"
team-exec 阶段要派的 oh-my-kimi agent(如 executor、debugger、designer、codex、gemini)。可选;默认按阶段路由。用 codex 派 Kimi CLI worker,或用 gemini 派 Gemini CLI worker(需要装对应 CLI)。详见下文「Stage Agent Routing」。/team 5:executor "fix all TypeScript errors across the project"
/team 3:debugger "fix build errors in src/"
/team 4:designer "implement responsive layouts for all page components"
/team "refactor the auth module with security review"
/team ralph "build a complete REST API for user management"
# 使用 Kimi CLI worker(需要:npm install -g @openai/codex)
/team 2:codex "review architecture and suggest improvements"
# 使用 Gemini CLI worker(需要:npm install -g @google/gemini-cli)
/team 2:gemini "redesign the UI components"
# 混合:后端分析用 Codex、前端用 Gemini(这种场景请改用 /ccg)
User: "/team 3:executor fix all TypeScript errors"
|
v
[TEAM ORCHESTRATOR (Lead)]
|
+-- TeamCreate("fix-ts-errors")
| -> lead becomes team-lead@fix-ts-errors
|
+-- Analyze & decompose task into subtasks
| -> explore/architect produces subtask list
|
+-- TaskCreate x N (one per subtask)
| -> tasks #1, #2, #3 with dependencies
|
+-- TaskUpdate x N (pre-assign owners)
| -> task #1 owner=worker-1, etc.
|
+-- Task(team_name="fix-ts-errors", name="worker-1") x 3
| -> spawns teammates into the team
|
+-- Monitor loop
| <- SendMessage from teammates (auto-delivered)
| -> TaskList polling for progress
| -> SendMessage to unblock/coordinate
|
+-- Completion
-> SendMessage(shutdown_request) to each teammate
<- SendMessage(shutdown_response, approve: true)
-> TeamDelete("fix-ts-errors")
-> rm .omk/state/team-state.json
存储布局(由 Kimi CLI 管理):
~/.claude/
teams/fix-ts-errors/
config.json # team 元数据 + 成员列表
tasks/fix-ts-errors/
.lock # 并发访问文件锁
1.json # 子任务 #1
2.json # 子任务 #2(可能是 internal)
3.json # 子任务 #3
...
team 执行遵循阶段化流水线:
team-plan -> team-prd -> team-exec -> team-verify -> team-fix (loop)
每个流水线阶段使用专门 agent —— 不只是 executor。Lead 基于阶段与任务特征挑 agent。
| 阶段 | 必备 Agent | 可选 Agent | 选择标准 |
|---|---|---|---|
| team-plan | explore (haiku)、planner (opus) | analyst (opus)、architect (opus) | 需求不清时用 analyst。系统边界复杂时用 architect。 |
| team-prd | analyst (opus) | critic (opus) | 用 critic 挑战范围。 |
| team-exec | executor (sonnet) | executor (opus)、debugger (sonnet)、designer (sonnet)、writer (haiku)、test-engineer (sonnet) | 按子任务类型匹配 agent。复杂自主工作用 executor(model=opus),UI 用 designer,编译问题用 debugger,文档用 writer,测试创建用 test-engineer。 |
| team-verify | verifier (sonnet) | test-engineer (sonnet)、security-reviewer (sonnet)、code-reviewer (opus) | 始终跑 verifier。鉴权 / 加密改动加 security-reviewer。改动 >20 个文件或架构性改动加 code-reviewer。code-reviewer 也覆盖风格 / 格式检查。 |
| team-fix | executor (sonnet) | debugger (sonnet)、executor (opus) | 类型 / 构建错误与回归隔离用 debugger。复杂多文件修复用 executor(model=opus)。 |
路由规则:
N:agent-type 参数只覆盖 team-exec 阶段的 worker 类型。其他阶段都用对应的专门 agent。opus agent 降为 sonnet,sonnet 在质量允许时降为 haiku。team-verify 至少使用 sonnet。team-verify 中包含 security-reviewer + code-reviewer(opus)。explore 扫代码库、planner 创建任务图,复杂任务可选 analyst / architect。analyst 抽取需求,可选 critic。TeamCreate、TaskCreate、分配与 worker 启动完成。verifier + 任务相应的 reviewer(见路由表)。team-fix。executor 或 debugger。team-exec,再到 team-verify。继续 team-exec -> team-verify -> team-fix,直到:
team-fix 有最大尝试次数限制。如果 fix 尝试超过配置上限,转入终态 failed(不无限循环)。
阶段之间过渡时,重要上下文 —— 做出的决策、被驳回的替代方案、识别的风险 —— 只存在于 lead 的对话历史里。如果 lead 上下文被压缩或 agent 重启,这些知识就丢了。
每个完成的阶段在过渡之前必须生成一份 handoff 文档。
Lead 把 handoff 写到 .omk/handoffs/<stage-name>.md。
## Handoff: <current-stage> → <next-stage>
- **Decided**: [本阶段做出的关键决策]
- **Rejected**: [被考虑但被驳回的替代方案及原因]
- **Risks**: [识别的下阶段风险]
- **Files**: [创建或修改的关键文件]
- **Remaining**: [留给下阶段处理的事项]
.omk/handoffs/,便于会话恢复。TeamDelete 不会删除它们。## Handoff: team-plan → team-exec
- **Decided**: Microservice architecture with 3 services (auth, api, worker). PostgreSQL for persistence. JWT for auth tokens.
- **Rejected**: Monolith (scaling concerns), MongoDB (team expertise is SQL), session cookies (API-first design).
- **Risks**: Worker service needs Redis for job queue — not yet provisioned. Auth service has no rate limiting in initial design.
- **Files**: DESIGN.md, TEST_STRATEGY.md
- **Remaining**: Database migration scripts, CI/CD pipeline config, Redis provisioning.
.omk/handoffs/ 恢复阶段过渡上下文。/oh-my-kimi:cancel 请求队友 shutdown,等待回应(尽力而为),把 phase 标 cancelled 并 active=false,记录取消元数据,然后删除 team 资源并按策略清理 / 保留 Team 状态。.omk/handoffs/ 中的 handoff 文件保留以便恢复。complete、failed 与 cancelled。用 explore 或 architect(通过 MCP 或 agent)分析代码库,把任务拆成 N 个子任务:
subject 与详细的 description用从任务派生的 slug 调用 TeamCreate:
{
"team_name": "fix-ts-errors",
"description": "Fix all TypeScript errors across the project"
}
响应:
{
"team_name": "fix-ts-errors",
"team_file_path": "~/.claude/teams/fix-ts-errors/config.json",
"lead_agent_id": "team-lead@fix-ts-errors"
}
当前会话成为 team lead(team-lead@fix-ts-errors)。
用 state_write MCP 工具写入 oh-my-kimi 状态,做会话级持久化:
state_write(mode="team", active=true, current_phase="team-plan", state={
"team_name": "fix-ts-errors",
"agent_count": 3,
"agent_types": "executor",
"task": "fix all TypeScript errors",
"fix_loop_count": 0,
"max_fix_loops": 3,
"linked_ralph": false,
"stage_history": "team-plan"
})
注意: MCP
state_write工具把所有值按字符串传输。消费者读取时必须把agent_count、fix_loop_count、max_fix_loops强转为数字,把linked_ralph强转为 boolean。
状态字段 schema:
| 字段 | 类型 | 描述 |
|---|---|---|
active | boolean | team 模式是否激活 |
current_phase | string | 当前流水线阶段:team-plan、team-prd、team-exec、team-verify、team-fix |
team_name | string | team 的 slug 名 |
agent_count | number | worker agent 数量 |
agent_types | string | 逗号分隔的 team-exec 阶段 agent 类型 |
task | string | 原始任务描述 |
fix_loop_count | number | 当前 fix 迭代次数 |
max_fix_loops | number | 失败前的最大 fix 迭代次数(默认:3) |
linked_ralph | boolean | team 是否与 ralph 持久化循环联动 |
stage_history | string | 逗号分隔的阶段过渡列表,带时间戳 |
每次阶段过渡时更新状态:
state_write(mode="team", current_phase="team-exec", state={
"stage_history": "team-plan:2026-02-07T12:00:00Z,team-prd:2026-02-07T12:01:00Z,team-exec:2026-02-07T12:02:00Z"
})
读取状态做 resume 检测:
state_read(mode="team")
如果 active=true 且 current_phase 非终态,从最近的未完成阶段恢复,而不是新建 team。
为每个子任务调用 TaskCreate。用 TaskUpdate 加 addBlockedBy 设置依赖。
// TaskCreate for subtask 1
{
"subject": "Fix type errors in src/auth/",
"description": "Fix all TypeScript errors in src/auth/login.ts, src/auth/session.ts, and src/auth/types.ts. Run tsc --noEmit to verify.",
"activeForm": "Fixing auth type errors"
}
响应会存为一个任务文件(例如 1.json):
{
"id": "1",
"subject": "Fix type errors in src/auth/",
"description": "Fix all TypeScript errors in src/auth/login.ts...",
"activeForm": "Fixing auth type errors",
"owner": "",
"status": "pending",
"blocks": [],
"blockedBy": []
}
对有依赖的任务,创建后用 TaskUpdate:
// 任务 #3 依赖任务 #1(共享类型必须先修)
{
"taskId": "3",
"addBlockedBy": ["1"]
}
从 lead 预分配 owner,避免竞争(没有原子领取机制):
// 把任务 #1 分配给 worker-1
{
"taskId": "1",
"owner": "worker-1"
}
用 Task 的 team_name 与 name 参数派出 N 个队友。每个队友拿到 team worker 前言(见下文)加上自己具体的分配。
{
"subagent_type": "oh-my-kimi:executor",
"team_name": "fix-ts-errors",
"name": "worker-1",
"prompt": "<worker-preamble + assigned tasks>"
}
响应:
{
"agent_id": "worker-1@fix-ts-errors",
"name": "worker-1",
"team_name": "fix-ts-errors"
}
副作用:
config.json 的 members 数组metadata._internal: true),跟踪 agent 生命周期TaskList 输出里 —— 数真实任务时要过滤掉重要: 并行派出所有队友(它们是后台 agent)。不要等一个完成再派下一个。
Lead orchestrator 通过两条通道监控进度:
入站消息 —— 队友在完成任务或需要帮助时用 SendMessage 发给 team-lead。这些消息会自动作为新对话回合到达(不用轮询)。
TaskList 轮询 —— 定期调用 TaskList 检查整体进度:
#1 [completed] Fix type errors in src/auth/ (worker-1)
#3 [in_progress] Fix type errors in src/api/ (worker-2)
#5 [pending] Fix type errors in src/utils/ (worker-3)
格式:#ID [status] subject (owner)
Lead 可以采取的协调动作:
message 给队友带上指导或缺失上下文TaskUpdate 把 pending 任务分给它,并通过 SendMessage 通知监控卡住或失败的队友:
in_progress 超过 5 分钟无消息,发送状态检查每次阶段过渡时更新 oh-my-kimi 状态:
// 规划后进入 team-exec
state_write(mode="team", current_phase="team-exec", state={
"stage_history": "team-plan:T1,team-prd:T2,team-exec:T3"
})
// 执行后进入 team-verify
state_write(mode="team", current_phase="team-verify")
// 验证失败后进入 team-fix
state_write(mode="team", current_phase="team-fix", state={
"fix_loop_count": 1
})
这能支持:
state_read(mode="team") 暴露最近的阶段与 team name 用于恢复current_phase 以知道需要哪些清理所有真实任务(非 internal)都 completed 或 failed 时:
TaskList 检查所有子任务标为 completedshutdown_request:
{
"type": "shutdown_request",
"recipient": "worker-1",
"content": "All work complete, shutting down team"
}
shutdown_response(approve: true) 并终止TeamDelete 清理:
{ "team_name": "fix-ts-errors" }
响应:
{
"success": true,
"message": "Cleaned up directories and worktrees for team \"fix-ts-errors\"",
"team_name": "fix-ts-errors"
}
.omk/state/team-state.json派出队友时,在 prompt 里包含下面这段前言以建立工作协议。按队友的具体任务分配做适配。
You are a TEAM WORKER in team "{team_name}". Your name is "{worker_name}".
You report to the team lead ("team-lead").
You are not the leader and must not perform leader orchestration actions.
== WORK PROTOCOL ==
1. CLAIM: Call TaskList to see your assigned tasks (owner = "{worker_name}").
Pick the first task with status "pending" that is assigned to you.
Call TaskUpdate to set status "in_progress":
{"taskId": "ID", "status": "in_progress", "owner": "{worker_name}"}
2. WORK: Execute the task using your tools (Read, Write, Edit, Bash).
Do NOT spawn sub-agents. Do NOT delegate. Work directly.
3. COMPLETE: When done, mark the task completed:
{"taskId": "ID", "status": "completed"}
4. REPORT: Notify the lead via SendMessage:
{"type": "message", "recipient": "team-lead", "content": "Completed task #ID: <summary of what was done>", "summary": "Task #ID complete"}
5. NEXT: Check TaskList for more assigned tasks. If you have more pending tasks, go to step 1.
If no more tasks are assigned to you, notify the lead:
{"type": "message", "recipient": "team-lead", "content": "All assigned tasks complete. Standing by.", "summary": "All tasks done, standing by"}
6. SHUTDOWN: When you receive a shutdown_request, respond with:
{"type": "shutdown_response", "request_id": "<from the request>", "approve": true}
== BLOCKED TASKS ==
If a task has blockedBy dependencies, skip it until those tasks are completed.
Check TaskList periodically to see if blockers have been resolved.
== ERRORS ==
If you cannot complete a task, report the failure to the lead:
{"type": "message", "recipient": "team-lead", "content": "FAILED task #ID: <reason>", "summary": "Task #ID failed"}
Do NOT mark the task as completed. Leave it in_progress so the lead can reassign.
== RULES ==
- NEVER spawn sub-agents or use the Task tool
- NEVER run tmux pane/session orchestration commands (for example `tmux split-window`, `tmux new-session`)
- NEVER run team spawning/orchestration skills or commands (for example `$team`, `$ultrawork`, `$autopilot`, `$ralph`, `omk team ...`, `omk team ...`)
- ALWAYS use absolute file paths
- ALWAYS report progress via SendMessage to "team-lead"
- Use SendMessage with type "message" only -- never "broadcast"
组装队友 prompt 时,按 worker 类型追加一段简短附录:
kimi_worker:强调严格的 TaskList / TaskUpdate / SendMessage 循环,且不准跑编排命令。codex_worker:强调 CLI API 生命周期(omk team api ... --json),失败要带 stderr 显式 ACK。gemini_worker:强调有界的文件 ownership,每完成一个 sub-step 做一次里程碑 ACK。该附录必须保留核心规则:worker = 仅执行者,永远不是 leader / orchestrator。
{
"type": "message",
"recipient": "team-lead",
"content": "Completed task #1: Fixed 3 type errors in src/auth/login.ts and 2 in src/auth/session.ts. All files pass tsc --noEmit.",
"summary": "Task #1 complete"
}
{
"type": "message",
"recipient": "worker-2",
"content": "Task #3 is now unblocked. Also pick up task #5 which was originally assigned to worker-1.",
"summary": "New task assignment"
}
{
"type": "broadcast",
"content": "STOP: shared types in src/types/index.ts have changed. Pull latest before continuing.",
"summary": "Shared types changed"
}
关键:步骤必须按精确顺序执行。TeamDelete 永远不要在 shutdown 被确认前调用。
步骤 1:验证完成
Call TaskList — verify all real tasks (non-internal) are completed or failed.
步骤 2:向每个队友请求 shutdown
Lead 发送:
{
"type": "shutdown_request",
"recipient": "worker-1",
"content": "All work complete, shutting down team"
}
步骤 3:等待回应(阻塞)
shutdown_response队友接收并回应:
{
"type": "shutdown_response",
"request_id": "shutdown-1770428632375@worker-1",
"approve": true
}
批准后:
config.json members 数组移除步骤 4:TeamDelete —— 在所有队友确认或超时后再调
{ "team_name": "fix-ts-errors" }
步骤 5:孤儿扫描
检查在 TeamDelete 后仍存活的 agent 进程:
node "${CLAUDE_PLUGIN_ROOT}/scripts/cleanup-orphans.mjs" --team-name fix-ts-errors
它会扫描与 team 名匹配但 config 已不存在的进程,并终止它们(SIGTERM → 5 秒等待 → SIGKILL)。支持 --dry-run 做检查。
Shutdown 序列是阻塞的: 在所有队友满足以下任一条件之前,不要进入 TeamDelete:
shutdown_response 且 approve: true),或重要: request_id 由队友接收到的 shutdown 请求消息提供。队友必须抽取它并原样回传。不要伪造 request ID。
team skill 支持混合执行:Kimi subagent 队友 + 外部 CLI worker(Kimi CLI 与 Gemini CLI)。两类都能改代码 —— 区别在于能力与成本。它们是独立 CLI 工具,不是 MCP server。
任务在分解时打上执行模式标签:
| 执行模式 | Provider | 能力 |
|---|---|---|
kimi_worker | Kimi subagent | 完整 Kimi CLI 工具访问(Read / Write / Edit / Bash / Task)。适合需要 Claude 推理 + 迭代式工具使用的任务。 |
codex_worker | Kimi CLI(tmux pane) | working_directory 内完整文件系统访问。通过 tmux pane 自主跑。适合代码评审、安全分析、重构、架构。需要 npm install -g @openai/codex。 |
gemini_worker | Gemini CLI(tmux pane) | working_directory 内完整文件系统访问。通过 tmux pane 自主跑。适合 UI / 设计、文档、大上下文任务。需要 npm install -g @google/gemini-cli。 |
Tmux CLI worker 在专用 tmux pane 中跑,具备文件系统访问。它们是自主执行者,不只是分析者:
working_directory 设为项目根与 Kimi subagent 的关键区别:
| 任务类型 | 最佳路由 | 原因 |
|---|---|---|
| 迭代式多步工作 | Kimi subagent | 需要工具中介的迭代 + team 通信 |
| 代码评审 / 安全审计 | CLI worker 或专家 agent | 自主执行,擅长结构化分析 |
| 架构分析 / 规划 | architect Kimi subagent | 强分析推理 + 代码库访问 |
| 范围明确的重构 | CLI worker 或 executor agent | 自主执行,擅长结构化变换 |
| UI / 前端实现 | designer Kimi subagent | 设计专长、框架习惯 |
| 大规模文档 | writer Kimi subagent | 写作专长 + 大上下文保证一致性 |
| 构建 / 测试迭代循环 | Kimi subagent | 需要 Bash 工具 + 迭代式 fix 循环 |
| 需要团队协调的任务 | Kimi subagent | 需要 SendMessage 做状态更新 |
/team 3:executor "refactor auth module with security review"
Task decomposition:
#1 [codex_worker] Security review of current auth code -> output to .omk/research/auth-security.md
#2 [codex_worker] Refactor auth/login.ts and auth/session.ts (uses #1 findings)
#3 [kimi_worker:designer] Redesign auth UI components (login form, session indicator)
#4 [kimi_worker] Update auth tests + fix integration issues
#5 [gemini_worker] Final code review of all changes
Lead 先跑 #1(Codex 安全分析),再并行跑 #2 与 #3(Codex 重构后端、designer agent 重做前端),然后 #4(Kimi subagent 处理测试迭代),最后 #5(Gemini 终审)。
对大而模糊的任务,team 创建前先跑分析:
Agent(subagent_type="oh-my-kimi:planner", ...)任务范围不清、能从分解前的外部推理中受益时尤其有用。
Lead 可以利用 outbox reader 工具主动摄取 CLI worker 的 outbox 消息,使监控成为事件驱动,不再单纯依赖 SendMessage 投递。
readNewOutboxMessages(teamName, workerName) —— 用字节偏移游标读取单个 worker 的新 outbox 消息。每次调用推进游标,后续调用只返回自上次读取以来写入的消息。镜像了 readNewInboxMessages() 的 inbox 游标模式。
readAllTeamOutboxMessages(teamName) —— 读取 team 中所有 worker 的新 outbox 消息。返回 { workerName, messages } 条目数组,跳过没有新消息的 worker。便于在监控循环中做批量轮询。
resetOutboxCursor(teamName, workerName) —— 把某 worker 的 outbox 游标重置回字节 0。lead 重启后想重读历史消息或调试时有用。
getTeamStatus()getTeamStatus(teamName, workingDirectory, heartbeatMaxAgeMs?) 函数提供统一快照,包含:
监控循环中的示例用法:
const status = getTeamStatus('fix-ts-errors', workingDirectory);
for (const worker of status.workers) {
if (!worker.isAlive) {
// Worker 死了 —— 重新分配它的 in-progress 任务
}
for (const msg of worker.recentMessages) {
if (msg.type === 'task_complete') {
// 标任务完成,解除依赖者的阻塞
} else if (msg.type === 'task_failed') {
// 处理失败,可能重试或重新分配
} else if (msg.type === 'error') {
// 记 error,看 worker 是否需要介入
}
}
}
if (status.taskSummary.pending === 0 && status.taskSummary.inProgress === 0) {
// 所有工作完成 —— 进入 shutdown
}
| 消息类型 | 动作 |
|---|---|
task_complete | 标任务 completed,检查被阻塞任务是否解锁,通知依赖 worker |
task_failed | 增加失败 sidecar 计数,决定重试 vs 重新分配 vs 跳过 |
idle | worker 无分配任务 —— 分新工作或开始 shutdown |
error | 记 error,检查心跳里的 consecutiveErrors 是否触发隔离阈值 |
shutdown_ack | worker 已确认 shutdown —— 可从 team 移除 |
heartbeat | 更新存活跟踪(与心跳文件冗余,但对延迟监控有用) |
这种方式补足已有的基于 SendMessage 的通信,为不能用 Kimi CLI team 消息工具的 MCP worker 提供拉式机制。
SendMessage 报告失败给 leadTaskUpdate 设新 owner,然后 SendMessage 通知新 ownerTaskList 检测 —— 任务 in_progress 太久SendMessage 询问队友状态TaskUpdate 把任务重新分配给另一个 workerTaskUpdate)SendMessage 把决定传达给受影响的队友config.json members 中消失Task(team_name, name) 派一个替代队友当用户调用 /team ralph、说「team ralph」,或同时用上两个关键词时,team 模式把自己包进 Ralph 持久化循环。它提供:
Team+Ralph 在以下情况下激活:
/team ralph "task" 或 /oh-my-kimi:team ralph "task"team 与 ralphMAGIC KEYWORD: RALPH两个模式各自写状态文件,互相交叉引用:
// Team 状态(通过 state_write)
state_write(mode="team", active=true, current_phase="team-plan", state={
"team_name": "build-rest-api",
"linked_ralph": true,
"task": "build a complete REST API"
})
// Ralph 状态(通过 state_write)
state_write(mode="ralph", active=true, iteration=1, max_iterations=10, current_phase="execution", state={
"linked_team": true,
"team_name": "build-rest-api"
})
team-plan -> team-prd -> team-exec -> team-verifyteam-verify 通过:Ralph 跑 architect 验证(至少 STANDARD 等级)/oh-my-kimi:cancelteam-verify 失败或 architect 拒绝:team 进入 team-fix,再回到 team-exec -> team-verifymax_fix_loops:Ralph 增加 iteration 并重试整条流水线max_iterations:终态 failed取消任一模式都取消两者:
详见下文「取消」章节。
如果 lead 在中途崩溃,team skill 应检测已有状态并恢复:
${KIMI_CONFIG_DIR:-~/.claude}/teams/ 中匹配 task slug 的 teamconfig.json 发现活跃成员TaskList 确定当前进度这能防止 team 重复,并允许从 lead 故障中优雅恢复。
| 方面 | Team(原生) | Swarm(旧版 SQLite) |
|---|---|---|
| 存储 | ~/.claude/teams/ 与 ~/.claude/tasks/ 下的 JSON 文件 | .omk/state/swarm.db 中的 SQLite |
| 依赖 | 不需要 better-sqlite3 | 需要 better-sqlite3 npm 包 |
| 任务领取 | TaskUpdate(owner + in_progress) —— lead 预分配 | SQLite IMMEDIATE 事务 —— 原子 |
| 竞争条件 | 可能(两个 agent 抢同一任务),通过预分配缓解 | 无(SQLite 事务) |
| 通信 | SendMessage(DM、broadcast、shutdown) | 无(fire-and-forget agent) |
| 任务依赖 | 内置 blocks / blockedBy 数组 | 不支持 |
| 心跳 | Kimi CLI 自动 idle 通知 | 手动心跳表 + 轮询 |
| 关闭 | 优雅的请求 / 响应协议 | 基于信号终止 |
| Agent 生命周期 | 通过 internal task + config 成员自动跟踪 | 通过心跳表手动跟踪 |
| 进度可见性 | TaskList 实时显示状态与 owner | tasks 表 SQL 查询 |
| 冲突预防 | owner 字段(lead 分配) | 基于租约的领取 + 超时 |
| 崩溃恢复 | Lead 通过缺失消息检测、重新分配 | 5 分钟租约超时后自动释放 |
| 状态清理 | TeamDelete 清理一切 | 手动 rm SQLite 数据库 |
何时用 Team 而不用 Swarm: 新工作始终优先 /team。它基于 Kimi CLI 内置基础设施,不需要外部依赖,支持 agent 间通信,并具备任务依赖管理。
/oh-my-kimi:cancel skill 负责 team 清理:
state_read(mode="team") 读 team 状态,拿到 team_name 与 linked_ralphconfig.json members)发 shutdown_requestshutdown_response(每个成员超时 15 秒)TeamDelete 移除 team 与任务目录state_clear(mode="team") 清状态linked_ralph 为 true,也清 ralph:state_clear(mode="ralph")team 与 ralph 联动时,取消按依赖顺序进行:
--force): 通过 state_clear 无条件清掉 team 与 ralph 状态。如果队友无响应,TeamDelete 可能失败。这时 cancel skill 应短暂等待并重试,或提醒用户手动清理 ~/.claude/teams/{team_name}/ 与 ~/.claude/tasks/{team_name}/。
设置 OMC_RUNTIME_V2=1 时,team 运行时使用事件驱动架构,替代旧的 done.json 轮询看门狗:
.omk/state/team/{teamName}/events.jsonl.omk/state/team/{teamName}/workers/{name}/status.jsonv2 运行时由特性开关控制,可按会话开启。旧的 v1 运行时仍是默认。
设置 OMC_TEAM_SCALING_ENABLED=1 时,team 支持会话中扩缩容:
可选配置位于 .claude/omc.jsonc(项目)或 ~/.config/claude-omc/config.jsonc(用户)。项目值覆盖用户值;OMC_TEAM_ROLE_OVERRIDES(env JSON)覆盖两者。
{
"team": {
"ops": {
"maxAgents": 20,
"defaultAgentType": "claude",
"monitorIntervalMs": 30000,
"shutdownTimeoutMs": 15000
}
}
}
/team 调用未指定时的 CLI provider(claude | codex | gemini,默认 claude)TaskList(默认 30s)注意: team 成员没有硬编码的模型默认。每个队友是独立的 Kimi CLI 会话,继承用户配置的模型。由于队友可派出自己的 subagent,会话模型充当编排层,subagent 可使用任意模型层级。
作用域: 只适用于
/team。基于任务的委派使用delegationRouting(见单独文档)。两套系统按设计共存。
声明每个规范化角色应由哪个 provider(claude、codex、gemini)与哪个模型层级承担。路由在 team 创建时解析一次并存进 TeamConfig.resolved_routing —— spawn、scale-up、restart 都读快照,因此一个角色的 worker CLI 与模型在 team 生命周期内保持稳定。
// .claude/omc.jsonc
{
"team": {
"roleRouting": {
"orchestrator": { "model": "inherit" },
"planner": { "provider": "claude", "model": "HIGH" },
"analyst": { "provider": "claude", "model": "HIGH" },
"executor": { "provider": "claude", "model": "MEDIUM" },
"critic": { "provider": "codex" },
"code-reviewer": { "provider": "gemini" },
"test-engineer": { "provider": "gemini", "model": "MEDIUM" }
}
}
}
| 角色 | Provider | 模型 |
|---|---|---|
orchestrator | claude(钉死) | 继承调用会话 |
planner | claude | HIGH(opus) |
analyst | claude | HIGH(opus) |
executor | claude | MEDIUM(sonnet) |
critic | codex | codex 默认 |
code-reviewer | gemini | gemini 默认 |
test-engineer | gemini | MEDIUM(sonnet) |
orchestrator、planner、analyst、architect、executor、debugger、critic、code-reviewer、security-reviewer、test-engineer、designer、writer、code-simplifier、explore、document-specialist。
用户友好的别名通过 normalizeDelegationRole() 归一化 —— 例如 reviewer → code-reviewer,quality-reviewer → code-reviewer,harsh-critic → critic,build-fixer → debugger。被接受的别名键在解析快照创建与之后的阶段路由中都被识别,不只是用于校验。未知角色在解析时校验失败。
TeamRoleAssignmentSpec)"claude" | "codex" | "gemini"。省略 → 默认 claude。"HIGH" | "MEDIUM" | "LOW")或显式模型 ID。层级通过 routing.tierModels 解析。"critic"、"executor")。仅当解析后的 provider 是 claude 时被采纳。orchestrator 钉死为 claude;只有 model 由用户可配置。orchestrator 上的其他键会被校验器拒绝。
OMC_TEAM_ROLE_OVERRIDES='{"critic":{"provider":"codex"},"code-reviewer":{"provider":"gemini"}}'
优先级:OMC_TEAM_ROLE_OVERRIDES > .claude/omc.jsonc(项目) > ~/.config/claude-omc/config.jsonc(用户) > 内置默认。非法 JSON 记 warning 并忽略 —— env 覆盖是尽力而为,永不中止运行。
如果配置的 provider 在 spawn 时 PATH 上没有对应 CLI,buildLaunchArgs() 抛错,team lead 通过 SendMessage 发出可见 warning,运行时回退到 buildResolvedRoutingSnapshot 预先计算的确定性 Claude 分配(同层级 + 同 agent,provider: "claude")。回退按设计是显式的 —— 静默回退是测试失败。用 omk doctor --team-routing 探测 provider 可用性。
解析后的路由对每个 team 是不可变的。在 team 生命周期中编辑配置不会影响运行中的 team;新一次 /team 调用才会使用新映射。这保证 spawn、scale-up 与 worker-restart 看到完全相同的路由,包括跨 worktree detach(快照随 TeamConfig 一起走)。
空的 team.roleRouting 保留补丁前行为:每个 worker 是 Claude,模型层级跟随 routing.tierModels,/team 3:executor ... 仍然派出三个 Kimi executor。
成功完成时:
TeamDelete 负责所有 Kimi CLI 状态:
~/.claude/teams/{team_name}/(config)~/.claude/tasks/{team_name}/(所有任务文件 + 锁)state_clear(mode="team")
联动到 Ralph 时:
state_clear(mode="ralph")
/oh-my-kimi:cancel,它会自动做所有清理。重要: TeamDelete 必须在所有队友已 shutdown 之后调用。如果 config 中还有除 lead 之外的活跃成员,TeamDelete 会失败。
MCP worker 可以在隔离的 git worktree 中工作,防止并发 worker 之间的文件冲突。
创建 worktree:在派 worker 前调用 createWorkerWorktree(teamName, workerName, repoRoot) 在 .omk/worktrees/{team}/{worker} 创建隔离 worktree,分支为 omc-team/{teamName}/{workerName}。
Worker 隔离:把 worktree 路径作为 worker BridgeConfig 的 workingDirectory 传入。worker 只在自己的 worktree 内工作。
合并协调:worker 完成任务后用 checkMergeConflicts() 验证分支可干净合并,再用 mergeWorkerBranch() 带 --no-ff 合并,留下清晰历史。
Team 清理:team shutdown 时调用 cleanupTeamWorktrees(teamName, repoRoot) 移除所有 worktree 与对应分支。
| 函数 | 描述 |
|---|---|
createWorkerWorktree(teamName, workerName, repoRoot, baseBranch?) | 创建隔离 worktree |
removeWorkerWorktree(teamName, workerName, repoRoot) | 移除 worktree 与分支 |
listTeamWorktrees(teamName, repoRoot) | 列出所有 team worktree |
cleanupTeamWorktrees(teamName, repoRoot) | 移除所有 team worktree |
checkMergeConflicts(workerBranch, baseBranch, repoRoot) | 非破坏性冲突检查 |
mergeWorkerBranch(workerBranch, baseBranch, repoRoot) | 合并 worker 分支(--no-ff) |
mergeAllWorkerBranches(teamName, repoRoot, baseBranch?) | 合并所有完成的 worker |
tmux-session.ts 中的 createSession() 不处理 worktree 创建 —— worktree 生命周期由 git-worktree.ts 单独管理sanitizeName() 清洗,防止注入Internal task 会污染 TaskList —— 派出队友时系统自动创建带 metadata._internal: true 的 internal task。它们会出现在 TaskList 输出里。数真实任务进度时要过滤掉。internal task 的 subject 就是队友名。
没有原子领取 —— 与 SQLite swarm 不同,TaskUpdate 没有事务保证。两个队友可能竞争领取同一任务。缓解: lead 应在派出队友之前通过 TaskUpdate(taskId, owner) 预分配 owner。队友只做分配给自己的任务。
Task ID 是字符串 —— ID 是自增字符串("1"、"2"、"3"),不是整数。taskId 字段始终传字符串值。
TeamDelete 需要空 team —— 调 TeamDelete 前所有队友必须已 shutdown。lead(仅剩成员)不在此检查内。
消息自动投递 —— 队友消息作为新对话回合到达 lead。入站消息不需要轮询或查 inbox。但如果 lead 正在 turn 中(处理中),消息会排队,turn 结束后投递。
队友 prompt 存在 config 中 —— 完整 prompt 文本存在 config.json members 数组里。不要把密钥或敏感数据放进队友 prompt。
成员在 shutdown 后自动移除 —— 队友批准 shutdown 并终止后,会自动从 config.json 移除。不要重读 config 期望找到已关闭的队友。
shutdown_response 需要 request_id —— 队友必须从入站 shutdown 请求 JSON 中抽取 request_id 原样回传。格式是 shutdown-{timestamp}@{worker-name}。伪造该 ID 会导致 shutdown 静默失败。
Team 名必须是合法 slug —— 用小写字母、数字与连字符。从任务描述派生(例如 "fix TypeScript errors" 派生为 "fix-ts-errors")。
Broadcast 很贵 —— 每次 broadcast 给每个队友各发一条独立消息。默认用 message(DM)。只在真正全 team 范围的关键告警时才广播。
CLI worker 是一次性的,不是持久的 —— Tmux CLI worker 有完整文件系统访问,可以改代码。但它们是自主一次性作业 —— 不能用 TaskList / TaskUpdate / SendMessage。Lead 必须管理其生命周期:写 prompt_file、派 CLI worker、读 output_file、标任务完成。它们不像 Kimi subagent 那样参与 team 通信。