A multi-agent collaboration framework inspired by the ancient Three Departments and Six Ministries system. Core design:Strict cascading approval flow + real-time kanban observability + multi-CLI parallel analysis。
Architecture
+----------------------------------------------------------+
| Skill(skill="team-edict") |
| args="任务描述" |
+------------------------+---------------------------------+
|
Coordinator (太子·接旨分拣)
Phase 0-5 orchestration
|
+---------------+--------------+
| |
[串行审批链] [看板 State Bus]
| |
中书省(PLAN) ← 所有 agent 强制上报
| state/flow/progress
门下省(REVIEW) ← 多CLI审议
|
尚书省(DISPATCH) ← 路由分析
|
+----+----+----+----+----+----+
工部 兵部 户部 礼部 吏部 刑部
(IMPL)(OPS)(DATA)(DOC)(HR)(QA)
[team-worker × 6, 按需并行]
Role Router
This skill is coordinator-only. All workers are spawned directly as team-worker agents.
Input parsing
Directly parse $ARGUMENTS as the task description, and always route to the coordinator.
Role Registry
| Role | Alias | Spec | Task Prefix | Inner Loop | Responsibilities |
|---|---|---|---|---|---|
| coordinator | Crown Prince | roles/coordinator/role.md | (none) | - | Receive and triage edicts, drive the process |
| zhongshu | Zhongshu Sheng | role-specs/zhongshu.md | PLAN-* | false | Analyze the edict, draft the execution plan |
| menxia | Menxia Sheng | role-specs/menxia.md | REVIEW-* | false | Multi-dimensional review, approve/reject |
| shangshu | Shangshu Sheng | role-specs/shangshu.md | DISPATCH-* | false | Analyze the plan, dispatch to the Six Ministries |
| gongbu | Gongbu | role-specs/gongbu.md | IMPL-* | true | Feature development, architecture design, code implementation |
| bingbu | Bingbu | role-specs/bingbu.md | OPS-* | true | Infrastructure, deployment, performance monitoring |
| hubu | Hubu | role-specs/hubu.md | DATA-* | true | Data analysis, statistics, resource management |
| libu | Libu | role-specs/libu.md | DOC-* | true | Documentation, standards, UI/UX, external communication |
| libu-hr | Libu-HR | role-specs/libu-hr.md | HR-* | false | Agent management, training, assessment and evaluation |
| xingbu | Xingbu | role-specs/xingbu.md | QA-* | true | Code review, test acceptance, compliance audit |
Menxia Sheng — Multi-CLI review configuration
Menxia Sheng review usesmulti-CLI parallel analysis, evaluating the plan from multiple dimensions simultaneously:
| Review dimension | CLI Tool | Focus |
|---|---|---|
| Feasibility review | gemini | Technical path, dependency completeness |
| Completeness review | qwen | Subtask coverage, omission identification |
| Risk assessment | gemini (second call) | Failure points, rollback plans |
| Resource assessment | codex | Workload reasonableness, department match |
Six Ministries routing rules
Shangshu Sheng (DISPATCH) routes subtasks to the corresponding department based on task content:
| Keyword signals | Target department | Description |
|---|---|---|
| Feature development, architecture, code, refactoring, implementation | Gongbu (gongbu) | Engineering implementation |
| Deployment, CI/CD, infrastructure, containers, performance monitoring | Bingbu (bingbu) | Operations and deployment |
| Data analysis, statistics, cost, reports, resources | Hubu (hubu) | Data management |
| Documentation, README, API docs, UI copy, standards | Libu (libu) | Documentation and standards |
| Testing, QA, Bug, review, compliance | Xingbu (xingbu) | Quality assurance |
| Agent management, training, skill optimization, assessment | Libu-HR (libu-hr) | Personnel management |
Dispatch
Always route to coordinator (Taizi).
Orchestration Mode
The user only provides the task description.
Call: Skill(skill="team-edict", args="任务描述")
Lifecycle:
用户提供任务描述
-> coordinator Phase 1-2: 接旨判断 -> 简单问答直接回复 | 正式任务建 PLAN 任务
-> coordinator Phase 3: TeamCreate -> spawn 中书省 worker (PLAN-001)
-> 中书省执行 -> 生成执行方案 -> SendMessage callback
-> coordinator spawn 门下省 worker (REVIEW-001) <- 多CLI并行审议
-> 门下省审议 -> 准奏/封驳 -> SendMessage callback
-> 封驳: coordinator 通知中书省修改 (最多3轮)
-> 准奏: coordinator spawn 尚书省 worker (DISPATCH-001)
-> 尚书省分析路由 -> 生成六部任务清单 -> SendMessage callback
-> coordinator 按任务清单 spawn 六部 workers (按依赖并行/串行)
-> 六部执行 -> 各自 SendMessage callback
-> coordinator 汇总所有六部产出 -> Phase 5 报告
User command (wake up a paused coordinator):
| Command | Action |
|---|---|
check / status |
Output the kanban status diagram without advancing |
resume / continue |
Check worker status and advance to the next step |
revise PLAN-001 <反馈> |
Trigger the Zhongshu Sheng to redraft (rejection loop) |
Kanban status protocol
All workers must comply with the following status reporting specifications (mandatory):
State machine
Pending -> Doing -> Done
|
Blocked (可随时进入,需上报原因)
Status reporting call
Each worker uses team_msg to perform kanban operations (replacing kanban_update.py):
// 接任务时
team_msg(operation="log", session_id=<session_id>, from=<role>,
type="state_update", data={state: "Doing", current_step: "开始执行[任务]"})
// 进度上报 (每个关键步骤)
team_msg(operation="log", session_id=<session_id>, from=<role>,
type="impl_progress", data={
current: "正在执行步骤2:实现API接口",
plan: "步骤1分析✅|步骤2实现🔄|步骤3测试"
})
// 任务交接 (flow)
team_msg(operation="log", session_id=<session_id>, from=<role>, to="coordinator",
type="task_handoff", data={from_role: <role>, to_role: "coordinator", remark: "✅ 完成:[产出摘要]"})
// 阻塞上报
team_msg(operation="log", session_id=<session_id>, from=<role>, to="coordinator",
type="error", data={state: "Blocked", reason: "[阻塞原因],请求协助"})
Specs Reference
| File | Content | Consumer |
|---|---|---|
| specs/team-config.json | Role registry, Six Ministries routing rules, pipeline definition, session directory structure, artifact paths | coordinator (read at startup) |
| specs/quality-gates.md | Quality gate standards for each phase, cross-phase consistency check rules, message type mappings | coordinator (during Phase 8 summary acceptance), xingbu (during QA acceptance) |
Session Directory
.workflow/.team/<session-id>/
├── plan/
│ ├── zhongshu-plan.md # 中书省起草的执行方案
│ └── dispatch-plan.md # 尚书省生成的六部任务清单
├── review/
│ └── menxia-review.md # 门下省审议报告(含多CLI结论)
├── artifacts/
│ ├── gongbu-output.md # 工部产出
│ ├── xingbu-report.md # 刑部测试报告
│ └── ... # 各部门产出
├── kanban/
│ └── state.json # 看板状态快照
└── wisdom/
└── contributions/ # 各 worker 知识沉淀
Spawn Template
The coordinator uses the following template to spawn workers:
Agent({
subagent_type: "team-worker",
name: "<role>",
team_name: "<team_name>",
prompt: `role: <role>
role_spec: ~ or <project>/.claude/skills/team-edict/role-specs/<role>.md
session: <session_path>
session_id: <session_id>
team_name: <team_name>
requirement: <original_requirement>
inner_loop: <true|false>`,
run_in_background: false
})