claude-code/claude-zh/commands/orchestrate.md

173 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 編排指令 (Orchestrate Command)
針對複雜任務的循序式 Agent 工作流。
## 使用方式
`/orchestrate [workflow-type] [task-description]`
## 工作流類型 (Workflow Types)
### 功能開發 (feature)
完整的功能實作工作流:
```
planner -> tdd-guide -> code-reviewer -> security-reviewer
```
### 錯誤修復 (bugfix)
錯誤調查與修復工作流:
```
planner -> tdd-guide -> code-reviewer
```
### 重構 (refactor)
安全的重構工作流:
```
architect -> code-reviewer -> tdd-guide
```
### 安全 (security)
以安全為核心的審查:
```
security-reviewer -> code-reviewer -> architect
```
## 執行模式 (Execution Pattern)
對於工作流中的每個 Agent
1. **呼叫 Agent**,並提供來自前一個 Agent 的上下文。
2. **收集輸出**,作為結構化的交接文件 (Handoff document)。
3. **傳遞給鏈條中的下一個 Agent**
4. **彙整結果** 產出最終報告。
## 交接文件格式 (Handoff Document Format)
在 Agent 之間建立交接文件:
```markdown
## 交接 (HANDOFF)[previous-agent] -> [next-agent]
### 上下文 (Context)
[已完成事項的摘要]
### 發現 (Findings)
[關鍵發現或決策]
### 已修改檔案
[涉及的檔案列表]
### 待解決問題
[留給下一個 Agent 的未決項目]
### 建議
[建議的後續步驟]
```
## 範例:功能開發工作流
```
/orchestrate feature "新增使用者身分驗證"
```
執行過程:
1. **Planner Agent**
- 分析需求
- 建立實作計畫
- 識別依賴關係
- 輸出:`HANDOFF: planner -> tdd-guide`
2. **TDD Guide Agent**
- 讀取 Planner 交接內容
- 先撰寫測試
- 實作程式碼以通過測試
- 輸出:`HANDOFF: tdd-guide -> code-reviewer`
3. **Code Reviewer Agent**
- 審查實作
- 檢查問題
- 提出改進建議
- 輸出:`HANDOFF: code-reviewer -> security-reviewer`
4. **Security Reviewer Agent**
- 進行安全稽核
- 漏洞檢查
- 最終核准
- 輸出:最終報告 (Final Report)
## 最終報告格式 (Final Report Format)
```
編排報告 (ORCHESTRATION REPORT)
====================
工作流feature
任務:新增使用者身分驗證
Agentplanner -> tdd-guide -> code-reviewer -> security-reviewer
摘要 (SUMMARY)
-------
[一段文字摘要]
AGENT 輸出
-------------
Planner: [摘要]
TDD Guide: [摘要]
Code Reviewer: [摘要]
Security Reviewer: [摘要]
變動檔案
-------------
[列出所有修改的檔案]
測試結果
------------
[測試通過/失敗摘要]
安全狀態
---------------
[安全發現項目]
建議 (RECOMMENDATION)
--------------
[可發布 / 需改進 / 已阻斷 (SHIP / NEEDS WORK / BLOCKED)]
```
## 平行執行 (Parallel Execution)
對於獨立的檢查,可以平行執行 Agent
```markdown
### 平行階段 (Parallel Phase)
同時執行:
- code-reviewer (品質)
- security-reviewer (安全)
- architect (設計)
### 合併結果
將輸出結合為單一報告
```
## 參數說明 (Arguments)
$ARGUMENTS
- `feature <描述>` - 完整的功能開發工作流
- `bugfix <描述>` - 錯誤修復工作流
- `refactor <描述>` - 重構工作流
- `security <描述>` - 安全審查工作流
- `custom <agents> <描述>` - 自定義 Agent 序列
## 自定義工作流範例
```
/orchestrate custom "architect,tdd-guide,code-reviewer" "重新設計快取層"
```
## 祕技與提示
1. **從 planner 開始** 處理複雜功能。
2. **務必包含 code-reviewer**,在合併代碼之前。
3. **使用 security-reviewer** 處理身分驗證/支付/個人隱私資訊 (PII)。
4. **保持交接內容簡潔** - 專注於下一個 Agent 需要的資訊。
5. **在 Agent 之間執行驗證** (如果需要)。