GitHub Copilot 建立 SSDLC Agent Team 教學手冊

文件目錄.github/教學/AI開發/
文件檔名GitHub Copilot 建立 SSDLC Agent Team 教學手冊.md


目錄


0. 文件資訊與閱讀指南

文件基本資訊

項目內容
文件名稱GitHub Copilot 建立 SSDLC Agent Team 教學手冊
文件版本v1.0.0
最後更新日期2026-04-23
作者角色定位資深軟體架構師 / AI 架構師 / DevSecOps 導入專家
文件目錄.github/教學/AI開發/
文件檔名GitHub Copilot 建立 SSDLC Agent Team 教學手冊.md

適用對象

  • 資深軟體工程師(Backend / Frontend / Full-Stack)
  • 軟體架構師(Solution Architect / Enterprise Architect)
  • DevSecOps 工程師
  • 技術主管 / 技術經理
  • 資安團隊
  • QA / 測試工程師
  • 專案管理師(需理解技術導入流程者)

使用前提

前提說明
GitHub 帳號需具備 Copilot Pro / Pro+ / Business / Enterprise 授權
VS Code建議 v1.115 或以上(以取得最新 Agent 功能)
GitHub Copilot 擴充套件需安裝最新版 GitHub Copilot 與 GitHub Copilot Chat
GitHub Copilot CLI需安裝最新版 gh copilot 擴充
GitHub Pull Requests 擴充套件建議安裝(支援從 Cloud Agent session 開啟至 VS Code)
管理員政策組織管理員需啟用 Custom Agents、Custom Instructions、Copilot Memory 等政策
網路存取需能連線至 GitHub.com

閱讀地圖

第 0 章:閱讀指南 ─ 理解文件結構
    │
    ├── 第 1~2 章:概念與功能盤點 ─ 建立認知基礎
    │
    ├── 第 3 章:架構設計 ─ 企業級 Agent Team 設計
    │
    ├── 第 4~5 章:環境建置與專案初始化 ─ 動手準備
    │
    ├── 第 6~11 章:核心功能建立 ─ Agent / Prompt / Instructions / Skills / Hooks / Memory
    │
    ├── 第 12~13 章:PR 流程與 SSDLC 融合 ─ 端到端工作流
    │
    ├── 第 14 章:逆向工程專章 ─ 舊系統改造
    │
    ├── 第 15~17 章:治理、安全與維運 ─ 企業級管理
    │
    ├── 第 18 章:實戰案例 ─ 完整示範
    │
    └── 第 19~21 章:FAQ / Checklist / 附錄 ─ 參考資料

名詞定義

術語定義
SSDLCSecure Software Development Lifecycle,安全軟體開發生命週期
Agent Team由多個自訂 AI Agent 組成的協作團隊,各 Agent 專責 SSDLC 不同階段
Custom Agent使用 Markdown 檔案定義的專屬 AI 人格,包含指令、工具限制與行為規範
Agent Profile定義 Custom Agent 行為的 Markdown 檔案(含 YAML frontmatter)
Custom Instructions自動套用至所有對話的背景指令,定義編碼規範與專案慣例
Prompt File可重用的提示範本檔案(.prompt.md),用於單次任務
Agent Skills包含指令、腳本與資源的資料夾,Copilot 可按需載入以執行專門任務
Hooks在 Agent 工作流特定時間點執行的自訂 Shell 命令(⚠️ VS Code Preview 功能)
Copilot MemoryRepository-scoped 的持久性記憶(Agentic Memory),跨 Cloud Agent、Code Review 與 CLI 共享,自動從工作中學習並儲存(⚠️ Public Preview,28 天過期)
Cloud Agent在 GitHub.com 上運行的 Copilot 自主代理,可自動完成任務並產生 PR
Third-party AgentsGitHub 平台上的第三方程式碼代理(如 OpenAI Codex、Anthropic Claude),與 Copilot Cloud Agent 並列可用
VS Code Agent ModeVS Code 中的 Agent 模式,允許 Copilot 使用工具自主完成任務
Copilot CLIGitHub CLI 中的 Copilot 擴充,提供終端機內 AI 輔助,內建 explore / task / code-review / research 等子代理
HandoffAgent 之間的任務交接機制,支援序列化工作流
Steering在 Agent session 進行中提供額外指引或修正方向
Premium Requests使用進階模型時消耗的計費單位,不同模型有不同倍率
Auto Model SelectionCopilot 自動選擇最佳可用模型的功能
GateSSDLC 流程中需要人工審核與批准的檢查點

1. 總覽:什麼是 GitHub Copilot SSDLC Agent Team

1.1 為什麼企業需要 SSDLC Agent Team

傳統軟體開發面臨以下挑戰:

  • 人力瓶頸:資深工程師不足,知識傳承困難
  • 安全後置:安全檢查多在開發後期才執行,修復成本高
  • 重複勞動:Code Review、測試撰寫、文件維護耗費大量人力
  • 品質不一:團隊成員能力與經驗差異導致交付品質波動
  • 舊系統債務:文件不足、人員離職、技術債積累

SSDLC Agent Team 透過將 AI Agent 嵌入開發生命週期的每個階段,實現:

  1. 安全左移(Shift Left Security):從需求階段即導入威脅建模
  2. 品質內建(Built-in Quality):自動化測試產生與程式碼審查
  3. 知識持續(Continuous Knowledge):透過 Memory 與 Instructions 累積組織智慧
  4. 可治理(Governable):透過 Hooks 與 Gate 確保人工監督

1.2 與傳統方式的差異

面向傳統單一 AI 助手單純 Prompt EngineeringSSDLC Agent Team
角色通用助手依 Prompt 臨時定義專責 Agent 各司其職
工具無限制無限制依 Agent 限定工具集
記憶Repository Memory 持續累積
治理Hooks + Gate + 審計
可重複每次需重新描述需重複貼上 PromptAgent Profile 一次定義
交接手動手動Handoff 自動交接
安全開發者自律開發者自律Agent 內建安全檢查

1.3 新系統開發 vs. 舊系統逆向工程

場景新系統開發舊系統逆向工程
起點需求文件 / User Story現有程式碼 / 操作手冊
主要 AgentRequirements → Architect → Backend/Frontend → TestReverse Engineering → Architect → Test → Backend
核心挑戰架構決策、技術選型知識還原、依賴理清
Memory 用途累積設計決策與慣例累積發現的 Business Rules
安全重點威脅建模、安全設計弱掃修復、依賴更新
產出新系統程式碼 + PR架構文件 + 遷移計畫 + 測試

1.4 整體概念圖

graph TB
    subgraph "GitHub Copilot SSDLC Agent Team"
        REQ[Requirements Agent]
        ARCH[Architect Agent]
        BE[Backend Agent]
        FE[Frontend Agent]
        TEST[Test Agent]
        SEC[Security Agent]
        CR[Code Review Agent]
        REL[Release Agent]
        RE[Reverse Engineering Agent]
        DOC[Documentation Agent]
    end

    subgraph "支撐層"
        INST[Custom Instructions]
        SKILL[Agent Skills]
        PROMPT[Prompt Library]
        HOOK[Hooks & Guardrails]
        MEM[Copilot Memory]
    end

    subgraph "平台層"
        VSCODE[VS Code Agent Mode]
        CLOUD[Copilot Cloud Agent]
        CLI[Copilot CLI]
        CODEX[OpenAI Codex Agent]
        CLAUDE[Anthropic Claude Agent]
    end

    subgraph "治理層"
        POLICY[管理員政策]
        MODEL[模型選擇策略]
        AUDIT[稽核紀錄]
        COST[成本控管]
    end

    REQ --> ARCH --> BE & FE
    BE & FE --> TEST --> SEC --> CR --> REL
    RE --> ARCH

    INST --> REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE & DOC
    SKILL --> REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE & DOC
    MEM --> REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE & DOC

    VSCODE --> REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE & DOC
    CLOUD --> REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE & DOC
    CLI --> REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE & DOC

1.5 企業導入價值

價值面向具體效益
效率提升程式碼產出速度提升 40-60%,Code Review 時間減少 30%
品質改善自動化安全檢查覆蓋率提升、測試覆蓋率自動補齊
知識管理組織知識透過 Memory + Instructions 持續累積,降低人員流動風險
合規達標SSDLC 各階段 Gate 確保安全與合規要求
成本可控透過模型分配策略與 Auto Model Selection 優化成本

1.6 典型使用情境

  1. Sprint 需求轉程式碼:Requirements Agent 分析 User Story → Architect Agent 設計 API → Backend Agent 實作 → Test Agent 補測試 → Security Agent 檢查 → Code Review Agent 審查 → Release Agent 產生 PR
  2. 舊系統現代化:Reverse Engineering Agent 分析程式碼 → 產出架構文件與 Business Rules → Architect Agent 設計新架構 → 漸進式遷移
  3. 資安弱掃修復:Security Agent 分析弱掃報告 → 產出修復 PR → Code Review Agent 審查 → Test Agent 驗證修復

2. 最新功能盤點與術語對照

⚠️ 本章內容以 2026 年 4 月官方文件為準。功能狀態可能隨版本更新而改變,請定期查閱官方文件確認。

2.1 功能矩陣表

功能說明主要用途
Copilot Cloud AgentGitHub.com 上的自主 AI 代理,可自動完成任務並產生 PR自動化任務執行、PR 產生
Third-party AgentsGitHub 平台支援的第三方程式碼代理:OpenAI Codex(GPT-5.x Codex 系列模型)與 Anthropic Claude(Claude Opus/Sonnet 系列模型),與 Cloud Agent 並列選擇多選項模型彈性、任務適配
VS Code Agent ModeVS Code 中的 Agent 模式,支援工具呼叫與多步驟任務本地開發、互動式任務
GitHub Copilot CLI終端機內 AI 輔助,內建 explore / task / code-review / research 等子代理CLI 操作、腳本輔助、程式碼探索
CLI Built-in AgentsCopilot CLI 內建子代理:explore(唯讀探索)、task(指令執行)、general-purpose(通用)、code-review(程式碼審查)、research(深度研究,需 /research 觸發)任務委派、平行處理
Custom Agents用 Markdown 定義的專屬 AI 人格,含指令與工具限制角色專門化、工作流標準化
Custom Instructions自動套用的背景指令(全域或檔案型)編碼規範、架構慣例
Prompt Files可重用提示範本(.prompt.md單次任務、一致性操作
Agent Skills含指令、腳本、資源的資料夾(開放標準 agentskills.io),支援 gh skill CLI 探索與安裝專門化能力、跨工具可攜
HooksAgent 工作流中的自訂 Shell 命令(.github/hooks/*.json防呆機制、審計追蹤
Copilot MemoryRepository-scoped Agentic Memory,跨 Cloud Agent / Code Review / CLI 共享,28 天過期累積知識、減少重複指引
Auto Model SelectionCopilot 自動選擇最佳可用模型(含 10% 倍率折扣),涵蓋 Copilot Chat / Cloud Agent / CLI / OpenAI Codex / Anthropic Claude降低延遲、減少限速、成本優化
Copilot Integrations與外部工具整合:Microsoft TeamsSlackLinearAzure BoardsJira跨平台觸發 Agent
HandoffsAgent 間的序列工作流交接,支援 labelpromptsend(自動送出)、model(指定模型)多步驟任務編排
SteeringAgent session 進行中提供修正指引(每則消耗一個 Premium Request)調整 Agent 行為
Session LogsAgent session 的即時執行紀錄監控與除錯
Subagents主 Agent 委派的隔離子任務代理(可平行執行)複雜任務分解
Agent ManagementRepo Agents Tab 集中管理:啟動任務、即時日誌、追蹤 session、mid-session steering、於 VS Code / CLI 開啟 session集中監控與控制

2.2 功能可用環境比較表

Key:✓ = 支援 | ✗ = 不支援 | P = Preview

功能VS CodeJetBrainsEclipseXcodeVisual StudioGitHub.com (Cloud Agent)Copilot CLI
Custom InstructionsPPP
Prompt FilesPP
Custom AgentsPPP
SubagentsPPP
Agent SkillsP
HooksP
MCP Servers
Auto Model SelectionPPP

⚠️ Hooks 在 VS Code 為 Preview 功能,需啟用 chat.useCustomAgentHooks 設定。在 GitHub.com Cloud Agent 與 CLI 環境中為 GA。

2.3 Preview / GA / Plan Requirement 對照表

功能狀態最低方案需求管理員政策需求
Custom AgentsGACopilot Pro / Business / Enterprise需啟用 Custom Agents 政策
Custom InstructionsGA所有 Copilot 方案需啟用(Business/Enterprise 預設啟用)
Agent SkillsGACopilot Pro / Business / Enterprise需啟用 Cloud Agent
Third-party Agents (OpenAI Codex)GACopilot Pro / Pro+ / Business / Enterprise需啟用第三方 Agent 政策
Third-party Agents (Anthropic Claude)GACopilot Pro / Pro+ / Business / Enterprise需啟用第三方 Agent 政策
Agent Management (Agents Tab)GACopilot Pro / Business / Enterprise需啟用 Cloud Agent
CLI Built-in AgentsGACopilot Pro / Pro+ / Business / Enterprise
Copilot MemoryPublic PreviewCopilot Pro / Business / EnterpriseBusiness/Enterprise 預設關閉,需管理員啟用
Hooks (VS Code)Preview所有 Copilot 方案需啟用 chat.useCustomAgentHooks
Hooks (Cloud Agent/CLI)GACopilot Pro / Business / Enterprise
Auto Model Selection (VS Code)GA所有 Copilot 方案Business/Enterprise 需啟用 Editor Preview Features
Auto Model Selection (Cloud Agent)GACopilot Pro / Pro+
Copilot IntegrationsGACopilot Pro / Pro+ / Business / Enterprise依整合而異
HandoffsGA (VS Code)所有 Copilot 方案
Org-level Custom AgentsGABusiness / Enterprise需在 .github-private repo 設定
Org-level InstructionsGABusiness / Enterprise需啟用組織指令政策
Cloud Agent PR 產生GACopilot Pro / Business / Enterprise需啟用 Cloud Agent

2.4 容易混淆概念比較表

概念 A概念 B差異說明
Custom AgentCustom InstructionsAgent 是完整人格(含工具限制與 Handoff),Instructions 是背景規則(自動套用)
Custom AgentPrompt FileAgent 是持久角色切換,Prompt File 是一次性任務範本
Custom AgentAgent SkillsAgent 定義角色行為,Skills 定義可攜能力(含腳本與資源)
Agent SkillsCustom InstructionsSkills 是按需載入的能力包(含腳本),Instructions 是持續生效的規則
HooksAgent SkillsHooks 在特定時間點執行 Shell 命令,Skills 是被載入的知識與程序
Cloud AgentVS Code Agent ModeCloud Agent 在 GitHub.com 伺服器執行(非同步),VS Code Agent Mode 在本地執行(互動式)
Cloud AgentThird-party AgentsCloud Agent 是 GitHub 原生 Copilot 代理;Third-party Agents(OpenAI Codex、Anthropic Claude)是第三方獨立代理,在 Agents Tab 中並列選擇
Cloud AgentCopilot CLICloud Agent 透過 Web UI 使用,CLI 透過終端機使用
Copilot MemoryCustom InstructionsMemory(Agentic Memory)由 Copilot 自動學習並儲存(28 天過期),跨 Cloud Agent / Code Review / CLI 共享;Instructions 由人工撰寫並永久保留
Auto Model Selection固定模型Auto 自動選擇效能最佳模型(有 10% 倍率折扣),固定模型確保一致性但可能遇到限速
HandoffsSubagentsHandoffs 是 Agent 間的序列交接(使用者可審核),Subagents 是主 Agent 自動委派的隔離任務

⚠️ 關鍵區分:Agent 檔案格式

環境檔案位置副檔名frontmatter 差異
VS Code.github/agents/.agent.md(或 .md支援 tools(YAML 陣列)、handoffshooks(Preview)、modelagentsuser-invocabledisable-model-invocationtarget
VS Code (Claude format).claude/agents/.md支援 tools(逗號分隔字串)、disallowedTools,VS Code 自動對應 Claude 工具名稱
GitHub.com / CLI.github/agents/.md支援 namedescriptiontoolsmcp-servers
Org/Enterprise.github-private/agents/.md與 GitHub.com 格式相同
User Profile~/.copilot/agents/.agent.md個人跨 workspace 使用,僅限 VS Code

⚠️ 重要:VS Code 專有的 frontmatter 欄位(如 handoffshooksuser-invocabledisable-model-invocationagents)在 GitHub.com / CLI 環境會被忽略。反之亦然。

⚠️ 歷史更名:VS Code Custom Agents 前身為 Custom Chat Modes(.chatmode.md)。若有舊檔案,需重新命名為 .agent.md 並移至正確位置。

2.5 第三方 Agent 與 Auto Model Selection 模型對照

GitHub 平台現已支援三大 AI 代理體系,使用者可在 Agents Tab 中依據任務特性選擇最適代理:

代理體系代理名稱Auto Model Selection 涵蓋模型適用場景
GitHub CopilotCloud Agent由 Auto Model Selection 自動選擇(不含 multiplier > 1 的模型)通用軟體開發任務、PR 產生
OpenAI CodexCodex AgentGPT-5.2-Codex、GPT-5.3-Codex、GPT-5.4、GPT-5.4 nano重計算推理任務、程式碼生成
Anthropic ClaudeClaude AgentClaude Opus 4.5 / 4.6 / 4.7、Claude Sonnet 4.5 / 4.6長上下文分析、文件理解、安全審查

Auto Model Selection 注意事項

  • 10% 倍率折扣:使用 Auto 模式時,模型倍率享 10% 折扣(僅限 Copilot Chat)
  • 排除規則:不會選擇管理員政策排除的模型、multiplier 超過 1 的模型、或方案不包含的模型
  • 適用範圍:Copilot Chat(VS Code / JetBrains GA;Visual Studio / Eclipse / Xcode Preview)、Cloud Agent、CLI、OpenAI Codex、Anthropic Claude 各有獨立的 Auto 模型清單
  • 手動覆寫:將滑鼠懸停在回應上可查看實際使用的模型;可隨時在模型選擇器中切換為固定模型

2.6 Copilot Integrations 支援平台

Copilot Cloud Agent 可與下列外部工具整合,直接從工作環境觸發 Agent 任務:

整合平台整合方式主要用途
Microsoft TeamsTeams Channel → Cloud Agent從 Teams 對話直接觸發 Agent 執行任務
SlackSlack Workspace → Cloud Agent從 Slack 頻道觸發 Agent 產生 PR
LinearLinear Issue → Cloud Agent從 Linear Issue 自動觸發 Agent 修復
Azure BoardsAzure Boards Work Item → Cloud Agent從 Azure DevOps 工作項目觸發 Agent
JiraJira Issue → Cloud Agent從 Jira 工作區觸發 Agent 執行任務

⚠️ 隱私提醒:透過整合觸發 Cloud Agent 時,Agent 會擷取完整的討論串或 Issue 內容以理解上下文,這些資訊將儲存在產生的 PR 中。

2.7 CLI Built-in Agents 功能說明

Copilot CLI 除了主 Agent 外,內建以下子代理,主 Agent 會依據提示內容自動選擇適當的子代理:

子代理職責存取權限觸發方式
explore快速唯讀探索程式碼庫,理解程式碼結構唯讀(grep、glob、view、shell),可存取 GitHub MCP 工具(唯讀)自動(如 “How does authentication work?")
task執行開發指令(測試、建置、lint、格式化、依賴安裝)並回報結果繼承主 Agent 權限自動
general-purpose與主 Agent 相同能力,用於委派需要獨立上下文窗口的任務繼承主 Agent 權限自動
code-review高訊噪比的程式碼審查,僅報告真正重要的問題(bug、安全漏洞、競態條件、記憶體洩漏、邏輯錯誤),不評論風格唯讀自動
research深度研究代理,提供詳盡的技術分析GitHub 搜尋 / Web fetch / 本地工具僅限 /research 斜線指令觸發

💡 平行執行:子代理可平行執行,加速整體任務完成。例如 explore 可與其他子代理同時運行。


3. SSDLC Agent Team 企業架構設計

3.1 Agent 職責總覽

Requirements Agent

項目內容
職責分析需求文件、User Story,產出結構化需求規格、驗收條件
工具權限唯讀(searchwebfetch)— 不可修改程式碼
建議模型Claude Opus 4.7 或 GPT-5.4(需要高推理能力)
交接方式Handoff 至 Architect Agent
人工 Gate✓ 需求確認 Gate

Architect Agent

項目內容
職責系統架構設計、模組拆分、API 介面定義、技術選型
工具權限唯讀 + 限定文件寫入(searchwebeditFiles 限定 docs/ 目錄)
建議模型Claude Opus 4.7(最強推理能力)或 Claude Opus 4.6
交接方式Handoff 至 Backend/Frontend Agent
人工 Gate✓ 架構審查 Gate

Backend Agent

項目內容
職責後端程式碼實作、API 開發、業務邏輯實現
工具權限完整開發工具(editFilesterminalsearch 等)
建議模型Claude Sonnet 4.6 或 GPT-5.3-Codex(平衡速度與品質)
交接方式Handoff 至 Test Agent
人工 Gate✗(由後續 Code Review 把關)

Frontend Agent

項目內容
職責前端 UI 實作、元件開發、互動邏輯
支援框架React 18+, Vue 3+, Angular 19+
工具權限完整開發工具
建議模型Claude Sonnet 4.6 或 Gemini 3.1 Pro
交接方式Handoff 至 Test Agent
人工 Gate

Test Agent

項目內容
職責單元測試、整合測試、E2E 測試產生與執行
工具權限讀寫測試檔案 + 終端機(執行測試)
建議模型Claude Sonnet 4.6(程式碼產生均衡)
交接方式Handoff 至 Security Agent
人工 Gate

Security Agent

項目內容
職責安全弱點分析、OWASP Top 10 檢查、依賴掃描、密碼/Token 偵測
工具權限唯讀 + 終端機(執行掃描工具)— 不可修改程式碼
建議模型Claude Opus 4.7 或 Claude Opus 4.6(高推理、低風險容忍)
交接方式產出安全報告,Handoff 至 Code Review Agent
人工 Gate✓ 安全審查 Gate(高風險發現必須人工確認)

Code Review Agent

項目內容
職責程式碼品質審查、最佳實務檢查、架構一致性驗證
工具權限唯讀
建議模型Claude Sonnet 4.6
交接方式Handoff 至 Release Agent
人工 Gate✓ Code Review 必須有人工 Approve

Release Agent

項目內容
職責PR 產生、版本號管理、Release Notes 撰寫、部署前檢查
工具權限受限(Git 操作 + PR 建立)
建議模型GPT-5.4 mini 或 Gemini 3 Flash(低成本任務)
交接方式最終產出 PR
人工 Gate✓ 上線批准 Gate

Reverse Engineering Agent

項目內容
職責舊系統程式碼分析、架構還原、Business Rules 抽取、模組識別
工具權限唯讀(searchgrepreadFile)— 不可修改舊系統程式碼
建議模型Claude Opus 4.7 或 Claude Opus 4.6(需要最強推理能力處理複雜遺留系統)
交接方式Handoff 至 Architect Agent
人工 Gate✓ 逆向工程發現確認 Gate

Documentation Agent

項目內容
職責API 文件、架構文件、使用手冊、README 產生與更新
工具權限唯讀 + 限定文件寫入(docs/*.md
建議模型GPT-5.4 mini 或 Claude Haiku 4.5(低成本、快速)
交接方式產出文件,無需 Handoff
人工 Gate

3.2 Mermaid 架構圖

graph TB
    subgraph "SSDLC Agent Team 整體架構"
        direction TB

        subgraph "需求與設計層"
            REQ["🔍 Requirements Agent
模型: Opus 4.6
工具: 唯讀"] ARCH["🏗️ Architect Agent
模型: Opus 4.6
工具: 唯讀+文件寫入"] end subgraph "開發層" BE["⚙️ Backend Agent
模型: Sonnet 4.6
工具: 完整"] FE["🎨 Frontend Agent
模型: Sonnet 4.6
工具: 完整"] end subgraph "品質與安全層" TEST["🧪 Test Agent
模型: Sonnet 4.6
工具: 測試+終端"] SEC["🛡️ Security Agent
模型: Opus 4.6
工具: 唯讀+掃描"] end subgraph "交付層" CR["📝 Code Review Agent
模型: Sonnet 4.6
工具: 唯讀"] REL["🚀 Release Agent
模型: GPT-5.4 mini
工具: Git+PR"] end subgraph "逆向工程層" RE["🔬 Reverse Eng. Agent
模型: Opus 4.6
工具: 唯讀"] end subgraph "支援層" DOC["📚 Documentation Agent
模型: Haiku 4.5
工具: 文件寫入"] end end REQ -->|"Handoff: 需求規格"| ARCH ARCH -->|"Handoff: 架構設計"| BE ARCH -->|"Handoff: 架構設計"| FE BE -->|"Handoff: 程式碼"| TEST FE -->|"Handoff: 程式碼"| TEST TEST -->|"Handoff: 測試報告"| SEC SEC -->|"Handoff: 安全報告"| CR CR -->|"Handoff: 審查通過"| REL RE -->|"Handoff: 分析報告"| ARCH DOC -.->|"支援所有 Agent"| REQ & ARCH & BE & FE & TEST & SEC & CR & REL & RE style REQ fill:#e3f2fd style ARCH fill:#e3f2fd style BE fill:#e8f5e9 style FE fill:#e8f5e9 style TEST fill:#fff3e0 style SEC fill:#fce4ec style CR fill:#f3e5f5 style REL fill:#e0f7fa style RE fill:#fff9c4 style DOC fill:#f5f5f5

3.3 Agent 協作流程圖

sequenceDiagram
    participant 人工 as 👤 人工審核
    participant REQ as Requirements Agent
    participant ARCH as Architect Agent
    participant BE as Backend Agent
    participant TEST as Test Agent
    participant SEC as Security Agent
    participant CR as Code Review Agent
    participant REL as Release Agent

    REQ->>人工: 需求規格(需確認)
    人工-->>REQ: ✓ 批准
    REQ->>ARCH: Handoff: 已確認需求
    ARCH->>人工: 架構設計(需確認)
    人工-->>ARCH: ✓ 批准
    ARCH->>BE: Handoff: 架構與 API 設計

    par 平行開發
        BE->>BE: 後端實作
    end

    BE->>TEST: Handoff: 程式碼
    TEST->>TEST: 產生並執行測試
    TEST->>SEC: Handoff: 測試通過的程式碼
    SEC->>SEC: 安全掃描
    SEC->>人工: 安全報告(高風險需確認)
    人工-->>SEC: ✓ 批准
    SEC->>CR: Handoff: 安全審查完成
    CR->>人工: Code Review(需批准)
    人工-->>CR: ✓ Approve
    CR->>REL: Handoff: 審查通過
    REL->>REL: 產生 PR + Release Notes
    REL->>人工: PR 上線批准
    人工-->>REL: ✓ Merge

3.4 Agent RACI 表

R = Responsible(負責執行)、A = Accountable(最終責任)、C = Consulted(諮詢)、I = Informed(知會)

SSDLC 階段RequirementsArchitectBackendFrontendTestSecurityCode ReviewReleaseReverse Eng.Documentation人工
需求分析RCIIICIICIA
威脅建模CCIIIRIIIIA
架構設計CRCCICIICIA
API 設計IRCCICIIIIA
開發實作ICRRIIIIIIA
單元測試IICCRIIIIIA
安全檢查IIIIIRIIIIA
Code ReviewICCCICRIIIA
PR / 部署IIIIIIIRIIA
逆向工程CCIIICIIRIA
文件產出CCCCIIIICRA

⚠️ 重要:所有階段的「最終責任」(Accountable)都歸屬人工。AI Agent 是工具,不是決策者。

3.5 Agent 與 SSDLC 階段對應表

SSDLC 階段主導 Agent支援 Agent使用工具Gate
需求分析RequirementsDocumentationsearch, web, fetch✓ 需求確認
威脅建模SecurityArchitectsearch, web✓ 威脅模型確認
架構設計ArchitectDocumentationsearch, web, editFiles (docs/)✓ 架構審查
API 設計ArchitectBackendsearch, editFiles (docs/)✓ API 審查
開發實作Backend / FrontendeditFiles, terminal, search
單元測試TesteditFiles, terminal
整合測試TestBackendeditFiles, terminal
安全檢查Securitysearch, terminal (掃描)✓ 安全審查
Code ReviewCode ReviewSecuritysearch (唯讀)✓ 人工 Approve
PR / 部署Releasegit, PR✓ 上線批准
文件產出DocumentationeditFiles (docs/, *.md)
逆向工程Reverse Eng.Architect, Documentationsearch, grep (唯讀)✓ 發現確認

3.6 模型分配策略

企業模型選擇矩陣

任務類型推薦模型備選模型選用理由Premium 倍率參考
需求分析 / 架構設計Claude Opus 4.7Claude Opus 4.6 / GPT-5.4需要深度推理與長上下文理解
程式碼實作Claude Sonnet 4.6GPT-5.3-Codex平衡品質與速度
安全審查Claude Opus 4.7Claude Opus 4.6 / GPT-5.4需要嚴謹推理,不容許遺漏
測試產生Claude Sonnet 4.6Gemini 3.1 Pro規律性任務,速度重要
文件產生Claude Haiku 4.5GPT-5.4 mini低複雜度,成本敏感
逆向工程Claude Opus 4.7Claude Opus 4.6 / GPT-5.4需要最強推理能力
Code ReviewClaude Sonnet 4.6GPT-5.4品質與速度均衡
PR / ReleaseGPT-5.4 miniGemini 3 Flash格式化任務,低成本

Auto Model Selection 使用原則

場景建議說明
日常開發✓ 使用 Auto降低限速機率,享有 10% 倍率折扣
安全審查✗ 固定 Opus 4.7安全任務不容許品質波動
架構設計✗ 固定 Opus 4.7需要最強推理能力
文件產生✓ 使用 Auto低風險任務,成本優先
逆向工程✗ 固定 Opus 4.7需要最強推理能力
大量測試產生✓ 使用 Auto規律性任務,避免限速

管理員模型政策建議

建議管理員政策配置:
┌─────────────────────────────────────────┐
│ 允許存取的模型:                          │
│  ✓ Claude Opus 4.7(最新旗艦推理模型)     │
│  ✓ Claude Opus 4.6                      │
│  ✓ Claude Sonnet 4.6                    │
│  ✓ Claude Haiku 4.5                     │
│  ✓ Gemini 3.1 Pro                       │
│  ✓ Gemini 3 Flash                       │
│  ✓ GPT-5.3-Codex                        │
│  ✓ GPT-5.4                              │
│  ✓ GPT-5.4 mini                         │
│  ✓ GPT-5.4 nano                         │
│                                          │
│ Third-party Agents:                     │
│  ✓ OpenAI Codex Agent:啟用              │
│  ✓ Anthropic Claude Agent:啟用          │
│                                          │
│ Auto Model Selection:✓ 啟用             │
│ Editor Preview Features:✓ 啟用          │
│                                          │
│ Premium Requests 限制:                   │
│  依團隊規模設定月度上限                     │
│  設定告警閾值(80%)                       │
└─────────────────────────────────────────┘

企業實務建議

  1. 高風險任務固定模型:安全審查、架構設計、逆向工程等任務應固定使用高推理能力模型
  2. 日常任務使用 Auto:一般程式碼實作、文件產生等任務使用 Auto Model Selection 以優化成本
  3. 在 Agent Profile 中指定模型:透過 Agent 的 model frontmatter 確保一致性
  4. 定期審閱 Premium Requests 用量:建立月度用量報告,識別異常消耗

4. 平台安裝與環境建置

4.1 VS Code 安裝與版本建議

項目建議
VS Code 版本v1.115 或以上(建議持續使用最新穩定版)
更新策略啟用自動更新或每月手動更新
Insiders 版僅用於測試 Preview 功能,正式開發使用穩定版

Windows 安裝步驟

# 1. 下載安裝
winget install Microsoft.VisualStudioCode

# 2. 驗證安裝
code --version

# 3. 安裝必要擴充套件
code --install-extension GitHub.copilot
code --install-extension GitHub.copilot-chat
code --install-extension GitHub.vscode-pull-request-github

macOS 安裝步驟

# 1. 下載安裝
brew install --cask visual-studio-code

# 2. 驗證安裝
code --version

# 3. 安裝必要擴充套件
code --install-extension GitHub.copilot
code --install-extension GitHub.copilot-chat
code --install-extension GitHub.vscode-pull-request-github

Linux 安裝步驟

# Ubuntu/Debian
sudo apt update
sudo apt install code

# 或使用 snap
sudo snap install code --classic

# 安裝擴充套件
code --install-extension GitHub.copilot
code --install-extension GitHub.copilot-chat
code --install-extension GitHub.vscode-pull-request-github

4.2 GitHub Copilot 擴充套件安裝

必要擴充套件清單

擴充套件用途必要性
GitHub.copilotCopilot 核心(程式碼補全、Agent Mode)必要
GitHub.copilot-chatCopilot Chat必要
GitHub.vscode-pull-request-githubPR 管理(Cloud Agent session 接手需要)必要

驗證登入

1. 開啟 VS Code
2. 點擊左下角帳戶圖示
3. 選擇「Sign in to GitHub」
4. 完成瀏覽器授權流程
5. 回到 VS Code,確認底部狀態列顯示 Copilot 圖示
6. 開啟 Chat 面板(Ctrl+Shift+I),輸入「hello」確認回應

驗證 Agent Mode

1. 開啟 Copilot Chat 面板
2. 切換至 Agent 模式(確認左上角模式選擇器顯示「Agent」或對應 Agent 名稱)
3. 輸入測試指令,確認 Agent 可呼叫工具

4.3 GitHub Copilot CLI 安裝

# 1. 安裝 GitHub CLI(若尚未安裝)
# Windows
winget install GitHub.cli

# macOS
brew install gh

# Linux
sudo apt install gh

# 2. 登入 GitHub
gh auth login

# 3. 安裝 Copilot CLI 擴充
gh extension install github/gh-copilot

# 4. 驗證安裝
gh copilot --version

# 5. 測試使用
gh copilot suggest "how to list all files in a directory"
gh copilot explain "git rebase -i HEAD~3"

4.4 組織管理員政策設定

⚠️ 以下設定需具備組織或企業管理員權限

必須啟用的政策

政策設定路徑建議值說明
Copilot 存取Organization Settings → Copilot → Access依授權分配分配 Copilot 座位
Custom InstructionsOrganization Settings → Copilot → Policies✓ 啟用允許使用自訂指令
Custom AgentsOrganization Settings → Copilot → Policies✓ 啟用允許使用自訂 Agent
Copilot Cloud AgentOrganization Settings → Copilot → Policies✓ 啟用允許 Cloud Agent 產生 PR
Third-party AgentsOrganization Settings → Copilot → Policies✓ 啟用允許使用 OpenAI Codex、Anthropic Claude 等第三方 Agent
Copilot MemoryOrganization Settings → Copilot → Policies✓ 啟用預設關閉,需手動啟用
Editor Preview FeaturesOrganization Settings → Copilot → Policies✓ 啟用Auto Model Selection 等 Preview 功能需要
Copilot CLIOrganization Settings → Copilot → Policies✓ 啟用允許 CLI 使用
AI 模型存取Organization Settings → Copilot → Models依核准清單設定限制可用模型

VS Code 設定建議

.vscode/settings.json 中加入團隊建議設定:

{
  // 啟用組織層級 Custom Agents
  "github.copilot.chat.organizationCustomAgents.enabled": true,

  // 啟用組織層級 Custom Instructions
  "github.copilot.chat.organizationInstructions.enabled": true,

  // 啟用 Agent-scoped Hooks(Preview)
  "chat.useCustomAgentHooks": true,

  // 啟用 AGENTS.md 支援
  "chat.useAgentsMdFile": true,

  // 啟用父 Repository 探索(Monorepo 適用)
  "chat.useCustomizationsInParentRepositories": true,

  // Instructions 檔案位置
  "chat.instructionsFilesLocations": {
    ".github/instructions": true,
    ".claude/rules": false,
    "~/.copilot/instructions": true,
    "~/.claude/rules": false
  },

  // Agent 檔案位置
  "chat.agentFilesLocations": {
    ".github/agents": true
  },

  // Skills 檔案位置
  "chat.agentSkillsLocations": {
    ".github/skills": true
  }
}

Approval Model 與 Autopilot 風險

模式說明適用場景風險等級
Suggest(預設)Agent 每個動作都需要人工確認安全敏感操作
Auto-approve 受限允許特定低風險工具自動執行日常開發
AutopilotAgent 全自動執行⚠️ 不建議在企業環境使用

⚠️ 企業實務建議:永遠不要在生產環境相關操作中使用 Autopilot 模式。建議透過 Hooks 實作細粒度的自動批准策略。

4.5 設定檢查清單

  • VS Code 版本 ≥ 1.115
  • GitHub Copilot 擴充套件已安裝且為最新版
  • GitHub Copilot Chat 擴充套件已安裝且為最新版
  • GitHub Pull Requests 擴充套件已安裝且為最新版
  • GitHub CLI 已安裝(gh --version
  • Copilot CLI 擴充已安裝(gh copilot --version
  • 已登入 GitHub 帳號(gh auth status
  • Copilot 授權已啟用(狀態列顯示 Copilot 圖示)
  • 組織管理員已啟用 Custom Instructions 政策
  • 組織管理員已啟用 Custom Agents 政策
  • 組織管理員已啟用 Cloud Agent 政策
  • 組織管理員已啟用 Third-party Agents 政策(OpenAI Codex / Anthropic Claude)
  • 組織管理員已啟用 Copilot Memory 政策(Public Preview)
  • 組織管理員已啟用 Editor Preview Features 政策
  • 組織管理員已設定允許的 AI 模型清單
  • .vscode/settings.json 已配置團隊建議設定
  • 可成功在 Chat 中切換至 Agent Mode
  • 可成功在 Chat 中看到 Custom Agents(若已建立)

4.6 常見安裝錯誤與排除

問題可能原因解決方式
Copilot 圖示未顯示未登入或授權過期重新登入 GitHub 帳號
Chat 無回應網路問題或擴充套件版本過舊檢查網路連線,更新擴充套件
Custom Agent 未出現檔案位置或格式錯誤確認檔案在 .github/agents/ 且副檔名正確
Cloud Agent 無法啟動組織政策未啟用請管理員啟用 Cloud Agent 政策
Copilot CLI 安裝失敗GitHub CLI 版本過舊更新 GitHub CLI 至最新版
Auto Model Selection 無效政策未啟用確認 Editor Preview Features 已啟用
Memory 未生效政策未啟用或 Preview 限制確認管理員已啟用 Copilot Memory
Hooks 未觸發Preview 功能未啟用確認 chat.useCustomAgentHookstrue
Instructions 未套用檔案路徑不在搜尋範圍檢查 chat.instructionsFilesLocations 設定
組織 Agent 未顯示設定未啟用設定 github.copilot.chat.organizationCustomAgents.enabledtrue

診斷工具

在 VS Code Chat 面板中:
1. 右鍵點擊 Chat 面板 → 選擇「Diagnostics」
2. 檢視所有已載入的 Custom Agents、Instructions、Skills
3. 確認有無錯誤訊息

或使用 Command Palette(Ctrl+Shift+P):
- 「Chat: Open Chat Customizations」— 檢視所有自訂設定
- 「Chat: Configure Instructions」— 檢視 Instructions 狀態

5. 專案初始化與標準目錄設計

5.1 標準目錄樹

your-project/
│
├── AGENTS.md                          # 全域 Agent 指令(所有 AI Agent 通用)
│
├── .github/
│   ├── copilot-instructions.md        # Copilot 全域指令(自動套用至所有對話)
│   │
│   ├── agents/                        # Custom Agent 定義
│   │   ├── planner.agent.md           # 規劃 Agent(VS Code 格式)
│   │   ├── architect.agent.md         # 架構 Agent
│   │   ├── backend.agent.md           # 後端 Agent
│   │   ├── frontend.agent.md          # 前端 Agent
│   │   ├── test-generator.agent.md    # 測試 Agent
│   │   ├── security-reviewer.agent.md # 安全 Agent
│   │   ├── code-reviewer.agent.md     # Code Review Agent
│   │   ├── release.agent.md           # Release Agent
│   │   ├── reverse-eng.agent.md       # 逆向工程 Agent
│   │   └── doc-writer.agent.md        # 文件 Agent
│   │
│   ├── instructions/                  # 檔案型 Instructions
│   │   ├── backend-java.instructions.md
│   │   ├── frontend.instructions.md
│   │   ├── security.instructions.md
│   │   ├── testing.instructions.md
│   │   ├── reverse-engineering.instructions.md
│   │   ├── code-review.instructions.md
│   │   └── pr-description.instructions.md
│   │
│   ├── skills/                        # Agent Skills
│   │   ├── security-review/
│   │   │   ├── SKILL.md
│   │   │   └── scripts/
│   │   │       └── owasp-check.sh
│   │   ├── junit-generator/
│   │   │   ├── SKILL.md
│   │   │   └── templates/
│   │   │       └── test-template.java
│   │   ├── pr-checker/
│   │   │   ├── SKILL.md
│   │   │   └── checklists/
│   │   │       └── pr-checklist.md
│   │   ├── api-reviewer/
│   │   │   └── SKILL.md
│   │   ├── reverse-analysis/
│   │   │   ├── SKILL.md
│   │   │   └── templates/
│   │   │       ├── module-report.md
│   │   │       └── dependency-map.md
│   │   └── doc-generator/
│   │       ├── SKILL.md
│   │       └── templates/
│   │           └── api-doc-template.md
│   │
│   ├── hooks/                         # Hooks 定義
│   │   └── ssdlc-guardrails.json
│   │
│   ├── prompts/                       # Prompt Library
│   │   ├── requirements/
│   │   │   └── analyze-user-story.prompt.md
│   │   ├── design/
│   │   │   └── api-design.prompt.md
│   │   ├── coding/
│   │   │   └── implement-feature.prompt.md
│   │   ├── testing/
│   │   │   └── generate-unit-tests.prompt.md
│   │   ├── security/
│   │   │   └── threat-model.prompt.md
│   │   ├── review/
│   │   │   └── code-review.prompt.md
│   │   └── reverse-engineering/
│   │       └── analyze-legacy-module.prompt.md
│   │
│   ├── PULL_REQUEST_TEMPLATE.md       # PR 模板
│   │
│   ├── ISSUE_TEMPLATE/                # Issue 模板
│   │   ├── feature-request.yml
│   │   ├── bug-report.yml
│   │   └── reverse-engineering-task.yml
│   │
│   └── 教學/
│       └── AI開發/
│           └── GitHub Copilot 建立 SSDLC Agent Team 教學手冊.md
│
├── docs/
│   ├── architecture/                  # 架構文件
│   │   └── adr/                       # Architecture Decision Records
│   │       └── 001-clean-architecture.md
│   ├── governance/                    # 治理文件
│   │   ├── agent-team-governance.md
│   │   └── model-selection-policy.md
│   ├── security/                      # 安全基線
│   │   └── security-baseline.md
│   └── reverse-engineering/           # 逆向工程基線
│       └── legacy-system-inventory.md
│
├── .claude/                           # Claude Code 相容格式(選用)
│   ├── agents/                        # Claude 格式 Agent(VS Code 也會偵測)
│   └── skills/                        # Claude 格式 Skills
│
├── .agents/                           # 通用 Agent 格式(選用)
│   └── skills/                        # 通用格式 Skills
│
├── .vscode/
│   └── settings.json                  # 團隊共用 VS Code 設定
│
├── src/                               # 原始碼
├── tests/                             # 測試
└── README.md

5.2 檔案用途說明

檔案 / 目錄用途自動套用版本控管
AGENTS.md全域 Agent 指令,所有 AI Agent(VS Code、Claude Code 等)通用✓ 始終套用
.github/copilot-instructions.mdCopilot 專用全域指令✓ 始終套用
.github/agents/*.agent.mdCustom Agent 定義(VS Code 格式)選擇 Agent 時套用
.github/agents/*.mdCustom Agent 定義(GitHub.com / CLI 通用)選擇 Agent 時套用
.github/instructions/*.instructions.md檔案型指令,按 applyTo 模式套用✓ 符合模式時自動套用
.github/skills/*/SKILL.mdAgent Skills,按需載入(也可放在 .claude/skills/.agents/skills/相關時自動載入
.github/hooks/*.jsonHooks 定義(VS Code Preview / Cloud Agent+CLI GA)✓ 觸發時自動執行
.github/prompts/*.prompt.mdPrompt 範本,手動引用✗ 需手動選用
docs/governance/治理文件✗ 供人類閱讀
docs/architecture/adr/架構決策紀錄✗ 可被 Agent 引用

5.3 VS Code 與 GitHub.com / CLI 格式差異

Agent 檔案格式差異

特性VS Code (.agent.md)GitHub.com / CLI (.md)
副檔名.agent.md.md(在 .github/agents/ 內).md
tools 格式YAML 陣列:tools: ['search', 'editFiles']YAML 陣列:tools: ['search']
handoffs✓ 支援✗ 忽略
hooks✓ 支援(Preview)✗ 忽略(Cloud Agent 有自己的 hooks 機制)
model✓ 支援(可指定模型或模型優先列表)✗ 忽略(在 session 啟動時選擇)
agents (subagents)✓ 支援✗ 忽略
user-invocable✓ 支援✗ 忽略
disable-model-invocation✓ 支援✗ 忽略
targetvscodegithub-copilot
mcp-servers✓ 支援(當 target 為 github-copilot✓ 支援
argument-hint✓ 支援✗ 忽略

實務建議

由於 VS Code 與 GitHub.com / CLI 會共用 .github/agents/ 目錄,建議:

  1. 核心欄位使用通用格式namedescriptiontools 在兩個環境都支援
  2. VS Code 專有欄位會被 GitHub.com 忽略,不會造成錯誤
  3. 在同一檔案中同時定義兩端需要的內容,減少維護負擔
  4. 測試時在兩端都驗證,確保 Agent 行為符合預期

5.4 Project / User / Org 層級差異

層級適用範圍儲存位置治理責任
Project(專案)單一 Repository.github/agents/, .github/instructions/, .github/skills/專案團隊
User(個人)個人所有工作區~/.copilot/agents/, ~/.copilot/instructions/, ~/.copilot/skills/(或 ~/.claude/skills/, ~/.agents/skills/個人
Organization(組織)組織內所有 Repository.github-private repo 的 agents/, instructions/組織管理員
Enterprise(企業)企業內所有組織.github-private repo(企業層級)企業管理員

優先順序

個人(User)> 專案(Project)> 組織(Organization)> 企業(Enterprise)

當多層級的指令衝突時,較高優先順序的指令會覆蓋較低的。

組織層級設定步驟

1. 在組織中建立名為 `.github-private` 的 Repository
2. 在該 Repository 中建立 `agents/` 目錄
3. 放入組織級 Agent Profile(例如 security-reviewer.md)
4. 組織成員的 VS Code 會自動探索這些 Agent
   (需設定 github.copilot.chat.organizationCustomAgents.enabled = true)

5.5 版本控管策略

項目版本控管策略
Agent Profiles納入 Git,隨專案版本控管
Instructions納入 Git,隨專案版本控管
Skills納入 Git,隨專案版本控管
Hooks納入 Git,隨專案版本控管
Prompt Files納入 Git,隨專案版本控管
個人 Instructions/Agents個人管理,可透過 Settings Sync 同步
組織層級設定.github-private repo 管理,有獨立 PR 審核流程
VS Code settings.json團隊共用部分納入 Git,個人偏好不納入
Memory⚠️ 不可 直接版本控管(由 Copilot 管理,28 天自動過期)

命名規範

Agent:       {角色}.agent.md         → planner.agent.md
Instruction: {領域}.instructions.md  → backend-java.instructions.md
Skill:       {能力}/SKILL.md         → security-review/SKILL.md
Prompt:      {階段}/{動作}.prompt.md  → testing/generate-unit-tests.prompt.md
Hook:        {用途}.json             → ssdlc-guardrails.json

企業實務建議

  1. 所有自訂檔案都應納入版本控管(除 Memory 外)
  2. 組織層級變更需經 PR 審核,避免影響所有團隊
  3. 建立 CHANGELOG,追蹤 Agent Team 設定變更
  4. 使用 Branch Protection Rules 保護 .github/ 目錄
  5. 定期 Review 組織層級 Instructions 與 Agents,確保仍然適用

6. 建立 Custom Agent(⭐ 重點章節)

本章為全文件重點章節。將針對第 3 章定義的 10 個 Agent 角色,逐一提供 VS Code 與 Cloud Agent 兩種格式的完整定義範例。

6.1 Agent Profile 格式詳解

Frontmatter 欄位一覽

欄位類型VS CodeGitHub.com / CLI說明
namestringAgent 顯示名稱(必要)
descriptionstringAgent 描述
toolsstring[]可用工具清單
modelstring / string[]指定模型或模型優先列表
handoffsobject[]交接設定(label: 按鈕文字, agent: 目標 Agent, prompt: 提示, send: 自動送出, model: 指定模型)
hooksobject✓(Preview)Agent-scoped hooks
agentsstring[]可呼叫的子 Agent
user-invocableboolean使用者能否直接呼叫(預設 true)
disable-model-invocationboolean設為 true 時 Agent 僅路由不推理
argument-hintstring輸入提示
targetstring目標環境:vscodegithub-copilot
mcp-serversobject[]✓(target: github-copilot)MCP Server 配置

Tools 清單

工具名稱說明VS CodeCloud Agent
editFiles編輯檔案
search搜尋程式碼
createFile建立檔案
runTerminalCommand執行終端指令
runTests執行測試✗(用 runTerminalCommand
fetchWebpage擷取網頁內容
githubRepoGitHub Repo 操作
useMcp呼叫 MCP Server
思維工具(think)內部推理✓(部分模型)✓(部分模型)

6.2 Agent 1 — Planner(規劃 Agent)

VS Code 格式

檔案.github/agents/planner.agent.md

---
name: "SSDLC Planner"
description: "負責需求分析、任務拆解與開發計劃制定的規劃 Agent"
tools:
  - "search"
  - "fetchWebpage"
  - "githubRepo"
handoffs:
  - label: "交接至架構設計"
    agent: architect
    prompt: "請根據上述需求規格進行架構設計"
    send: false
  - label: "交接至後端開發"
    agent: backend
    prompt: "請根據上述需求實作後端 API"
    send: false
  - label: "交接至前端開發"
    agent: frontend
    prompt: "請根據上述需求實作前端頁面"
    send: false
model: "auto"
argument-hint: "描述你的需求或功能目標"
---

# SSDLC Planner Agent

## 角色定位
你是一位資深軟體專案規劃師,負責將業務需求轉化為可執行的開發計劃。

## 核心職責
1. **需求分析**:解析使用者的業務需求,識別核心功能與非功能需求
2. **任務拆解**:將大型需求拆分為可管理的 User Story 和 Task
3. **SSDLC 對應**:為每個任務標記對應的 SSDLC 階段
4. **風險識別**:預先辨識技術風險與安全考量

## 輸出格式
每次規劃必須產出:

### 需求摘要
- 功能目標
- 受影響的系統範圍
- 非功能需求(效能、安全、可用性)

### 任務清單
使用以下格式:
| 任務 ID | 任務描述 | SSDLC 階段 | 優先序 | 負責 Agent | 預估複雜度 |
|---------|---------|-----------|--------|-----------|-----------|

### 安全考量
- OWASP Top 10 相關項目
- 資料流安全分析
- 權限需求

## 限制
- **不撰寫程式碼**:規劃完成後 handoff 給對應 Agent
- **不做架構決策**:架構問題 handoff 給 Architect Agent
- 必須考慮安全需求,不可省略安全分析

Cloud Agent 格式(GitHub.com / CLI)

檔案.github/agents/planner.md

---
name: "SSDLC Planner"
description: "負責需求分析、任務拆解與開發計劃制定的規劃 Agent"
tools:
  - "search"
  - "fetchWebpage"
  - "githubRepo"
---

# SSDLC Planner Agent

## 角色定位
你是一位資深軟體專案規劃師,負責將業務需求轉化為可執行的開發計劃。

## 核心職責
1. **需求分析**:解析使用者的業務需求,識別核心功能與非功能需求
2. **任務拆解**:將大型需求拆分為可管理的 User Story 和 Task
3. **SSDLC 對應**:為每個任務標記對應的 SSDLC 階段
4. **風險識別**:預先辨識技術風險與安全考量

## 輸出格式
每次規劃必須產出:

### 需求摘要
- 功能目標
- 受影響的系統範圍
- 非功能需求(效能、安全、可用性)

### 任務清單
使用以下格式:
| 任務 ID | 任務描述 | SSDLC 階段 | 優先序 | 負責 Agent | 預估複雜度 |
|---------|---------|-----------|--------|-----------|-----------|

### 安全考量
- OWASP Top 10 相關項目
- 資料流安全分析
- 權限需求

## 限制
- 規劃完成後告知使用者應使用哪個 Agent 繼續
- 不撰寫程式碼
- 不做架構決策
- 必須考慮安全需求,不可省略安全分析

格式差異說明:Cloud Agent 版本移除了 handoffsmodelargument-hint 欄位,因為 GitHub.com / CLI 不支援這些。handoffs 改為在指令文字中說明。

6.3 Agent 2 — Architect(架構 Agent)

VS Code 格式

檔案.github/agents/architect.agent.md

---
name: "SSDLC Architect"
description: "負責系統架構設計、技術決策與架構文件產出的架構 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "fetchWebpage"
model: "auto"
handoffs:
  - label: "交接至後端開發"
    agent: backend
    prompt: "請根據上述架構設計進行後端實作"
    send: false
  - label: "交接至前端開發"
    agent: frontend
    prompt: "請根據上述架構設計進行前端實作"
    send: false
  - label: "安全架構審查"
    agent: security-reviewer
    prompt: "請審查上述架構設計的安全性"
    send: false
argument-hint: "描述架構需求或技術決策問題"
---

# SSDLC Architect Agent

## 角色定位
你是一位資深系統架構師,負責高層設計、技術選型與架構品質把關。

## 核心職責
1. **架構設計**:根據需求設計系統架構,產出架構圖與元件說明
2. **技術選型**:評估技術方案的優劣,做出有根據的技術決策
3. **ADR 撰寫**:以 Architecture Decision Record 格式記錄每個重要決策
4. **品質屬性**:確保架構滿足效能、可維護性、安全性等品質屬性

## 設計原則
- Clean Architecture / Hexagonal Architecture
- SOLID 原則
- 最小權限原則(Security by Design)
- 12-Factor App 原則

## 輸出格式

### 架構文件
每次架構設計必須包含:
1. **Context Diagram**:系統上下文圖(Mermaid 格式)
2. **Component Diagram**:元件圖與互動關係
3. **ADR**:關鍵決策的 Architecture Decision Record
4. **安全架構**:認證、授權、資料保護設計

### ADR 格式

# ADR-{序號}: {標題}
## 狀態:Proposed / Accepted / Deprecated
## 背景
## 決策
## 理由
## 替代方案
## 影響


## 限制
- 架構決策必須有明確理由,不做無根據的選擇
- 安全設計是必要項目,不可省略
- 不撰寫業務邏輯程式碼

Cloud Agent 格式

檔案.github/agents/architect.md

---
name: "SSDLC Architect"
description: "負責系統架構設計、技術決策與架構文件產出的架構 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "fetchWebpage"
---

# SSDLC Architect Agent

## 角色定位
你是一位資深系統架構師,負責高層設計、技術選型與架構品質把關。

## 核心職責
1. **架構設計**:根據需求設計系統架構,產出架構圖與元件說明
2. **技術選型**:評估技術方案的優劣,做出有根據的技術決策
3. **ADR 撰寫**:以 Architecture Decision Record 格式記錄每個重要決策
4. **品質屬性**:確保架構滿足效能、可維護性、安全性等品質屬性

## 設計原則
- Clean Architecture / Hexagonal Architecture
- SOLID 原則
- 最小權限原則(Security by Design)
- 12-Factor App 原則

## 輸出格式
(同上述內容)

## 限制
- 架構完成後請用戶使用 Backend 或 Frontend Agent 繼續
- 不撰寫業務邏輯程式碼
- 安全設計是必要項目

6.4 Agent 3 — Backend Developer(後端開發 Agent)

VS Code 格式

檔案.github/agents/backend.agent.md

---
name: "Backend Developer"
description: "負責後端服務開發、API 實作與資料庫設計的開發 Agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
  - "runTests"
model: "auto"
handoffs:
  - label: "交接至測試"
    agent: test-generator
    prompt: "請為上述實作產生單元測試"
    send: false
  - label: "安全審查"
    agent: security-reviewer
    prompt: "請審查上述程式碼的安全性"
    send: false
  - label: "Code Review"
    agent: code-reviewer
    prompt: "請審查上述程式碼的品質"
    send: false
argument-hint: "描述要實作的後端功能或 API"
---

# Backend Developer Agent

## 角色定位
你是一位資深後端開發工程師,專精 Java / Spring Boot 技術棧。

## 技術棧
- **語言**:Java 21+
- **框架**:Spring Boot 3.x+, Spring Security, Spring Data JPA
- **資料庫**:PostgreSQL, Redis
- **API 規範**:RESTful API, OpenAPI 3.0
- **建置工具**:Maven / Gradle

## 開發規範
1. **分層架構**:Controller → Service → Repository
2. **命名慣例**:
   - 類別:PascalCase(`UserService`)
   - 方法/變數:camelCase(`findByEmail`)
   - 常數:UPPER_SNAKE_CASE(`MAX_RETRY_COUNT`)
3. **例外處理**:使用 `@ControllerAdvice` 統一處理,自訂 Business Exception
4. **日誌**:使用 SLF4J + Log4j2,遵循日誌等級規範
5. **驗證**:使用 Bean Validation(`@Valid`、`@NotNull` 等)
6. **安全**:
   - 所有輸入必須驗證與清洗
   - SQL 查詢使用參數化查詢,禁止字串拼接
   - 敏感資料(密碼、Token)不可寫入日誌
   - API 必須有適當的認證與授權

## 輸出要求
- 每個 API 必須包含 JavaDoc 註解
- 每個 Service 方法必須有對應的單元測試(handoff 給 test-generator)
- 提交前必須通過 Checkstyle 與靜態分析

## 完成後動作
- 功能完成後 handoff 給 `test-generator` 產生測試
- 若涉及安全敏感功能,handoff 給 `security-reviewer`

Cloud Agent 格式

檔案.github/agents/backend.md

---
name: "Backend Developer"
description: "負責後端服務開發、API 實作與資料庫設計的開發 Agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
---

# Backend Developer Agent

## 角色定位
你是一位資深後端開發工程師,專精 Java / Spring Boot 技術棧。

(技術棧、開發規範同上)

## 完成後動作
- 功能完成後告知使用者使用 test-generator Agent 產生測試
- 若涉及安全敏感功能,建議使用 security-reviewer Agent 審查

6.5 Agent 4 — Frontend Developer(前端開發 Agent)

VS Code 格式

檔案.github/agents/frontend.agent.md

---
name: "Frontend Developer"
description: "負責前端介面開發、元件設計與使用者體驗的前端 Agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
  - "runTests"
model: "auto"
handoffs:
  - label: "交接至測試"
    agent: test-generator
    prompt: "請為上述前端元件產生測試"
    send: false
  - label: "安全審查"
    agent: security-reviewer
    prompt: "請審查上述前端程式碼的安全性"
    send: false
  - label: "Code Review"
    agent: code-reviewer
    prompt: "請審查上述前端程式碼的品質"
    send: false
argument-hint: "描述要實作的前端功能或頁面"
---

# Frontend Developer Agent

## 角色定位
你是一位資深前端開發工程師,專精 TypeScript 與主流前端框架(React、Vue、Angular)。

## 技術棧
- **語言**:TypeScript 5.x
- **框架**:
  - **React 生態系**:React 18+, Next.js 14+
  - **Vue 生態系**:Vue 3+, Nuxt 3+
  - **Angular 生態系**:Angular 19+
- **狀態管理**:
  - React:Zustand / TanStack Query(React Query)
  - Vue:Pinia
  - Angular:NgRx / Signals
- **樣式**:Tailwind CSS / CSS Modules / SCSS
- **測試**:Vitest, Testing Library(React / Vue), Playwright, Karma + Jasmine(Angular)
- **建置工具**:Vite(React / Vue), Angular CLI(Angular)

## 開發規範

### 通用規範
1. **命名慣例**:
   - 元件:PascalCase(`UserProfile`)
   - 型別/介面:PascalCase,`I` 或 `T` 前綴可選
2. **安全**:
   - 所有使用者輸入必須做 XSS 防護
   - 使用 `DOMPurify` 清洗 HTML 內容
   - 敏感資訊不存放在 localStorage
   - API 呼叫使用 HTTPS,正確處理 CORS
3. **無障礙(a11y)**:遵循 WCAG 2.1 AA 標準

### React 規範
1. 使用 Functional Component + Hooks
2. Hook 命名 camelCase,`use` 開頭(`useAuth`)
3. 優先使用 Server Components(Next.js App Router)

### Vue 規範
1. 使用 Composition API + `<script setup>` 語法
2. Composable 命名 camelCase,`use` 開頭(`useAuth`)
3. Props 使用 `defineProps<T>()` 泛型定義
4. 模板使用 kebab-case 標籤名(`<user-profile />`)

### Angular 規範
1. 使用 Standalone Components(不使用 NgModule)
2. 優先使用 Signals 管理響應式狀態
3. 使用 `inject()` 函式取代 constructor injection
4. 遵循 Angular Style Guide 命名慣例(`*.component.ts`、`*.service.ts`)

## 完成後動作
- 功能完成後 handoff 給 `test-generator`
- 涉及安全敏感 UI(登入、付款),handoff 給 `security-reviewer`

Cloud Agent 格式

檔案.github/agents/frontend.md

---
name: "Frontend Developer"
description: "負責前端介面開發、元件設計與使用者體驗的前端 Agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
---

# Frontend Developer Agent

(角色定位、技術棧、開發規範同上)

## 完成後動作
- 功能完成後告知使用者使用 test-generator Agent

6.6 Agent 5 — Test Generator(測試 Agent)

VS Code 格式

檔案.github/agents/test-generator.agent.md

---
name: "Test Generator"
description: "負責產生全面的測試案例、測試資料與測試報告的測試 Agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
  - "runTests"
model: "auto"
handoffs:
  - label: "Code Review"
    agent: code-reviewer
    prompt: "請審查上述測試程式碼的品質"
    send: false
  - label: "安全審查"
    agent: security-reviewer
    prompt: "請審查上述程式碼的安全性"
    send: false
argument-hint: "描述要測試的類別、方法或功能"
---

# Test Generator Agent

## 角色定位
你是一位資深 QA 工程師,專注於自動化測試設計與實作。

## 測試策略
採用測試金字塔策略:
1. **單元測試**(70%):每個 public 方法至少一個測試
2. **整合測試**(20%):API 端點、資料庫互動
3. **端對端測試**(10%):核心使用者流程

## 技術棧
- **Java**:JUnit 5, Mockito, AssertJ, Testcontainers
- **JavaScript/TypeScript**:Vitest, Jest, Testing Library(React / Vue), Playwright, Karma + Jasmine(Angular)
- **API**:REST Assured, MockMvc
- **覆蓋率**:JaCoCo(目標 ≥ 80%)

## 測試案例設計原則
1. **AAA 模式**:Arrange → Act → Assert
2. **獨立性**:每個測試案例獨立執行,無順序依賴
3. **邊界值**:包含正常值、邊界值、異常值測試
4. **安全測試**:
   - SQL Injection 測試
   - XSS 測試
   - 認證繞過測試
   - 權限提升測試

## 輸出格式
每次產生測試時必須包含:
- 測試類別與方法
- 測試資料(含邊界值)
- 執行結果與覆蓋率報告
- 安全測試案例(若適用)

## 命名規範
```java
@Test
@DisplayName("當{前提條件}時,{操作}應該{預期結果}")
void should_ReturnUser_When_ValidIdProvided() { }

### Cloud Agent 格式

**檔案**:`.github/agents/test-generator.md`

```markdown
---
name: "Test Generator"
description: "負責產生全面的測試案例、測試資料與測試報告的測試 Agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
---

# Test Generator Agent

(角色定位、測試策略、技術棧同上)

6.7 Agent 6 — Security Reviewer(安全審查 Agent)

VS Code 格式

檔案.github/agents/security-reviewer.agent.md

---
name: "Security Reviewer"
description: "負責安全審查、威脅建模與漏洞識別的安全 Agent"
tools:
  - "search"
  - "editFiles"
  - "runTerminalCommand"
  - "fetchWebpage"
model:
  - "claude-sonnet-4"
  - "gpt-4.1"
handoffs:
  - label: "交接後端修復"
    agent: backend
    prompt: "請修復上述安全報告中的後端問題"
    send: false
  - label: "交接前端修復"
    agent: frontend
    prompt: "請修復上述安全報告中的前端問題"
    send: false
  - label: "Code Review"
    agent: code-reviewer
    prompt: "請審查上述安全修復的品質"
    send: false
argument-hint: "描述要審查的安全範圍或提供程式碼"
---

# Security Reviewer Agent

## 角色定位
你是一位資深資訊安全工程師,負責在 SSDLC 的每個階段提供安全把關。

## 審查框架
基於 OWASP Top 10 (2025) 進行系統性審查:

| 排名 | 類別 | 審查重點 |
|------|------|---------|
| A01 | Broken Access Control | 權限檢查、IDOR、CORS 配置 |
| A02 | Cryptographic Failures | 加密算法、金鑰管理、TLS 配置 |
| A03 | Injection | SQL/NoSQL/OS/LDAP Injection |
| A04 | Insecure Design | 威脅建模、安全設計模式 |
| A05 | Security Misconfiguration | 預設配置、錯誤訊息、不必要功能 |
| A06 | Vulnerable Components | 依賴掃描、CVE 檢查 |
| A07 | Auth Failures | 認證機制、Session 管理、MFA |
| A08 | Data Integrity Failures | 反序列化、CI/CD 安全 |
| A09 | Logging Failures | 日誌完整性、監控告警 |
| A10 | SSRF | Server-Side Request Forgery |

## 審查流程
1. **程式碼靜態分析**:掃描原始碼中的安全漏洞模式
2. **依賴分析**:檢查第三方套件的已知漏洞
3. **配置審查**:檢查安全相關配置
4. **威脅建模**:識別攻擊面與潛在威脅

## 輸出格式
### 安全審查報告

## 安全審查報告

**審查範圍**:{模組/功能名稱}
**審查日期**:{日期}
**風險等級**:🔴 Critical / 🟠 High / 🟡 Medium / 🟢 Low

### 發現項目
| # | 類別 | 風險等級 | 說明 | 修正建議 | OWASP 對應 |
|---|------|---------|------|---------|-----------|

### 修正優先序
1. 🔴 Critical — 必須立即修正
2. 🟠 High — 發布前必須修正
3. 🟡 Medium — 排入下一個 Sprint
4. 🟢 Low — 建議改善


## 重要原則
- **零容忍**:Critical 和 High 風險項目不可放行
- **證據導向**:每個發現必須附具體程式碼位置
- **修正建議**:必須提供可執行的修正方案
- 安全審查結果必須記錄在 PR 中

Cloud Agent 格式

檔案.github/agents/security-reviewer.md

---
name: "Security Reviewer"
description: "負責安全審查、威脅建模與漏洞識別的安全 Agent"
tools:
  - "search"
  - "editFiles"
  - "runTerminalCommand"
  - "fetchWebpage"
---

# Security Reviewer Agent

(角色定位、審查框架、流程、輸出格式同上)

6.8 Agent 7 — Code Reviewer(程式碼審查 Agent)

VS Code 格式

檔案.github/agents/code-reviewer.agent.md

---
name: "Code Reviewer"
description: "負責程式碼品質審查、最佳實務檢查與 PR 審核的審查 Agent"
tools:
  - "search"
  - "editFiles"
  - "runTerminalCommand"
  - "runTests"
model: "auto"
handoffs:
  - label: "安全複審"
    agent: security-reviewer
    prompt: "請對上述審查通過的程式碼進行安全複審"
    send: false
  - label: "產生 PR"
    agent: release
    prompt: "請為上述審查通過的程式碼產生 PR"
    send: false
argument-hint: "提供要審查的程式碼或 PR"
---

# Code Reviewer Agent

## 角色定位
你是一位嚴謹的資深程式碼審查員,專注於程式碼品質與團隊一致性。

## 審查維度

### 1. 程式碼品質
- **可讀性**:命名是否清晰、邏輯是否直觀
- **維護性**:是否遵循 SOLID 原則、DRY 原則
- **效能**:是否有明顯的效能問題(N+1 查詢、記憶體洩漏)
- **錯誤處理**:例外處理是否完整且有意義

### 2. 安全性(基礎)
- 輸入驗證
- SQL Injection 風險
- 敏感資訊暴露
- (深度安全審查 handoff 給 security-reviewer)

### 3. 測試
- 測試覆蓋率是否足夠
- 測試案例是否涵蓋邊界條件
- 測試是否獨立且可重複

### 4. 架構一致性
- 是否遵循專案既定的架構模式
- 分層是否正確
- 依賴方向是否正確

## 輸出格式
### Code Review 報告

## Code Review 報告

**審查範圍**:{PR / 檔案}
**整體評價**:✅ Approved / ⚠️ Changes Requested / ❌ Rejected

### 審查結果
| 檔案 | 行號 | 類別 | 嚴重度 | 說明 | 建議修正 |
|------|------|------|--------|------|---------|

### 總結
- 優點:{列出做得好的地方}
- 改善:{必須修正的項目}
- 建議:{可選的改善建議}

審查標準

  • 必須修正(Must Fix):安全問題、明顯 Bug、效能問題
  • 建議修正(Should Fix):程式碼風格、命名改善
  • 可選改善(Nice to Have):最佳實務建議

### Cloud Agent 格式

**檔案**:`.github/agents/code-reviewer.md`

```markdown
---
name: "Code Reviewer"
description: "負責程式碼品質審查、最佳實務檢查與 PR 審核的審查 Agent"
tools:
  - "search"
  - "editFiles"
  - "runTerminalCommand"
---

# Code Reviewer Agent

(角色定位、審查維度、輸出格式同上)

6.9 Agent 8 — Release Agent(發版 Agent)

VS Code 格式

檔案.github/agents/release.agent.md

---
name: "Release Agent"
description: "負責版本發布準備、Changelog 產生與發布流程管理的發版 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "runTerminalCommand"
  - "githubRepo"
model: "auto"
argument-hint: "描述要發布的版本或查看發布狀態"
---

# Release Agent

## 角色定位
你是一位資深 DevOps 工程師,負責版本發布的準備與執行。

## 核心職責
1. **版本號決策**:根據變更內容決定 Semantic Versioning
   - MAJOR:不相容的 API 變更
   - MINOR:向後相容的新功能
   - PATCH:向後相容的問題修正
2. **Changelog 產生**:根據 commit 與 PR 記錄產生格式化的 Changelog
3. **發布前檢查清單**:
   - [ ] 所有測試通過
   - [ ] 安全審查完成
   - [ ] Code Review 通過
   - [ ] 文件已更新
   - [ ] Breaking Change 已記錄
4. **Release Notes 撰寫**:清楚描述新功能、修正與已知問題

## Changelog 格式

## [版本號] - 日期

### ✨ 新功能
- 功能描述 (#PR號)

### 🐛 修正
- 修正描述 (#PR號)

### 🔒 安全
- 安全修正 (#PR號)

### 💥 Breaking Changes
- 變更描述與遷移指引

### 📝 文件
- 文件更新 (#PR號)

Cloud Agent 格式

檔案.github/agents/release.md

---
name: "Release Agent"
description: "負責版本發布準備、Changelog 產生與發布流程管理的發版 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "runTerminalCommand"
  - "githubRepo"
---

# Release Agent

(角色定位、核心職責同上)

6.10 Agent 9 — Reverse Engineering Agent(逆向工程 Agent)

VS Code 格式

檔案.github/agents/reverse-eng.agent.md

---
name: "Reverse Engineering Agent"
description: "負責遺留系統分析、程式碼理解與文件重建的逆向工程 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "runTerminalCommand"
  - "fetchWebpage"
model:
  - "claude-opus-4"
  - "claude-sonnet-4"
handoffs:
  - label: "交接架構設計"
    agent: architect
    prompt: "請根據上述逆向工程分析結果進行新架構設計"
    send: false
  - label: "產生文件"
    agent: doc-writer
    prompt: "請根據上述分析結果產生架構文件"
    send: false
argument-hint: "描述要分析的遺留系統模組或程式碼範圍"
---

# Reverse Engineering Agent

## 角色定位
你是一位資深遺留系統分析專家,擅長在缺乏文件的情況下理解和記錄現有系統。

## 分析方法論

### Phase 1:靜態分析
1. **目錄結構掃描**:識別模組邊界與分層模式
2. **依賴分析**:建立模組間的依賴關係圖
3. **進入點識別**:找到系統的主要進入點
4. **資料模型提取**:分析資料庫 Schema 或 Entity 定義

### Phase 2:行為分析
1. **控制流追蹤**:從 API 端點追蹤到資料層
2. **資料流分析**:識別資料的轉換與流向
3. **業務規則提取**:從程式碼邏輯中提取業務規則
4. **副作用識別**:找出外部系統呼叫、檔案操作等副作用

### Phase 3:文件產出
1. **模組說明文件**:每個模組的用途、介面、依賴
2. **架構圖**:系統整體架構圖(Mermaid 格式)
3. **API 清單**:所有 API 端點的規格
4. **業務流程圖**:核心業務邏輯的流程圖
5. **風險評估**:技術債務與安全風險報告

## 輸出格式

### 模組分析報告

## 模組分析報告:{模組名稱}

### 基本資訊
- **路徑**:{程式碼路徑}
- **用途**:{模組功能描述}
- **技術棧**:{使用的技術}
- **複雜度**:{低/中/高/極高}

### 依賴關係
{Mermaid 依賴圖}

### 核心邏輯
{關鍵業務邏輯說明}

### 風險評估
| 風險項目 | 等級 | 說明 |
|---------|------|------|

### 建議
{現代化改造建議}


## 重要原則
- **不假設**:每個結論都必須有程式碼證據支持
- **漸進式**:從高層概覽到細節,不一次深入全部
- **風險優先**:優先分析高風險和高影響區域

Cloud Agent 格式

檔案.github/agents/reverse-eng.md

---
name: "Reverse Engineering Agent"
description: "負責遺留系統分析、程式碼理解與文件重建的逆向工程 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "runTerminalCommand"
  - "fetchWebpage"
---

# Reverse Engineering Agent

(分析方法論、輸出格式同上,移除 model 和 handoffs)

## 完成後動作
- 架構分析完成後建議使用 Architect Agent 做架構決策
- 文件產出後建議使用 Doc Writer Agent 進行文件整理

6.11 Agent 10 — Doc Writer(文件 Agent)

VS Code 格式

檔案.github/agents/doc-writer.agent.md

---
name: "Doc Writer"
description: "負責技術文件撰寫、API 文件產出與使用者指南編寫的文件 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "fetchWebpage"
model: "auto"
handoffs:
  - label: "Code Review"
    agent: code-reviewer
    prompt: "請審查上述文件的品質與完整性"
    send: false
argument-hint: "描述要撰寫的文件類型或主題"
---

# Doc Writer Agent

## 角色定位
你是一位資深技術寫作者,專注於產出高品質的技術文件。

## 文件類型
1. **API 文件**:RESTful API 規格、參數說明、回應範例
2. **架構文件**:系統架構說明、元件互動、部署架構
3. **使用者指南**:安裝步驟、使用教學、FAQ
4. **開發者指南**:開發環境設定、程式碼慣例、PR 流程
5. **ADR**:Architecture Decision Records
6. **Release Notes**:版本更新說明

## 撰寫原則
1. **結構化**:使用清晰的標題層級和目錄
2. **可操作**:每個步驟都可以直接執行
3. **範例導向**:每個概念都配合具體範例
4. **版本標注**:標註適用的版本與環境
5. **Mermaid 圖表**:使用 Mermaid 格式繪製圖表
6. **語言**:使用繁體中文,技術名詞保留英文

## 格式規範
- 使用 Markdown 格式
- 程式碼區塊標注語言
- 表格用於結構化比較
- 使用 admonition 標記注意事項
- 檔案名稱使用 kebab-case

Cloud Agent 格式

檔案.github/agents/doc-writer.md

---
name: "Doc Writer"
description: "負責技術文件撰寫、API 文件產出與使用者指南編寫的文件 Agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "fetchWebpage"
---

# Doc Writer Agent

(角色定位、文件類型、撰寫原則同上)

6.12 Agent-Scoped Hooks(⚠️ Preview)

Agent 可在 frontmatter 中定義 hooks,在特定事件觸發時自動執行腳本。

語法

---
name: "Backend Developer"
hooks:
  postCreate:
    - command: "mvn checkstyle:check"
      description: "建立檔案後自動執行 Checkstyle"
  postEdit:
    - command: "mvn compile"
      description: "編輯檔案後自動編譯確認無語法錯誤"
---


### 可用的 Hook 事件

| 事件 | 觸發時機 |
|------|---------|
| `postCreate` | Agent 建立新檔案後 |
| `postEdit` | Agent 編輯現有檔案後 |

使用範例

# security-reviewer.agent.md 中的 hooks
hooks:
  postEdit:
    - command: "npm audit --audit-level=high"
      description: "修改 package.json 後自動執行安全審計"
    - command: "mvn dependency-check:check"
      description: "修改 pom.xml 後自動執行 CVE 檢查"

⚠️ 注意:Agent-scoped hooks 目前為 VS Code Preview 功能,需啟用 chat.useCustomAgentHooks 設定。GitHub.com Cloud Agent 和 CLI 不支援此語法(會忽略)。

6.13 Orchestrator Agent 模式

協調者 Agent(用 disable-model-invocation

---
name: "SSDLC Orchestrator"
description: "SSDLC 流程協調者,負責將任務分派給適當的 Agent"
disable-model-invocation: true
agents:
  - "planner"
  - "architect"
  - "backend"
  - "frontend"
  - "test-generator"
  - "security-reviewer"
  - "code-reviewer"
  - "release"
  - "reverse-eng"
  - "doc-writer"
---

# SSDLC Orchestrator

根據使用者需求,自動路由至適當的 Agent:

- **需求分析、任務規劃** → Planner
- **架構設計、技術選型** → Architect
- **後端開發、API 實作** → Backend Developer
- **前端開發、UI 實作** → Frontend Developer
- **測試產生、測試執行** → Test Generator
- **安全審查、威脅建模** → Security Reviewer
- **程式碼審查** → Code Reviewer
- **版本發布** → Release Agent
- **遺留系統分析** → Reverse Engineering Agent
- **文件撰寫** → Doc Writer

說明disable-model-invocation: true 使此 Agent 僅做路由,不會自行推理或產生內容。它純粹根據使用者輸入將請求轉發給最適合的子 Agent。

6.14 Agent 設計最佳實務

原則說明反模式
單一職責每個 Agent 只負責一個明確的角色一個 Agent 又開發又測試又審查
最小工具只授予 Agent 必要的工具所有 Agent 都給全部工具
明確邊界清楚定義 Agent 的職責範圍與限制模糊的角色描述
可驗證輸出定義具體的輸出格式與品質標準只要求「寫好程式」
安全內建每個 Agent 都有安全相關指引只有安全 Agent 考慮安全
Handoff 明確清楚定義何時與如何交接給其他 Agent不定義交接條件
模型選擇依任務複雜度選擇適當模型全部使用最貴的模型
版本控管Agent Profile 納入 Git 版控只存在本地

7. 建立 Prompt(Prompt Library)

7.1 Prompt File 概念

Prompt File(.prompt.md)是可重複使用的 Prompt 範本,讓團隊共享經過驗證的提示工程最佳實務。

Prompt File vs Instructions vs Agent

特性Prompt FileInstructionsAgent Profile
用途可重複使用的任務範本自動套用的規則與限制AI 角色定義
觸發方式手動選用(/ 或 Chat 面板選擇)自動套用手動選擇 @agent
自動套用✗(除非被其他 Agent 呼叫)
可帶參數✓(使用 {{變數}}
版本控管
放置位置.github/prompts/.github/instructions/.github/agents/

Prompt File 格式

---
mode: "agent"
tools:
  - "editFiles"
  - "search"
  - "runTerminalCommand"
description: "Prompt 的用途說明"
---

# Prompt 標題

## 你的角色
{角色定義}

## 任務
{具體任務描述}

## 輸入
- `{{變數1}}`:{變數說明}
- `{{變數2}}`:{變數說明}

## 輸出要求
{輸出格式和品質要求}

## 限制
{限制條件}


### Frontmatter 欄位

| 欄位 | 類型 | 說明 |
|------|------|------|
| `mode` | string | 執行模式:`agent`(可使用工具)或省略(純對話) |
| `tools` | string[] | 可用工具清單(需 `mode: agent`) |
| `description` | string | Prompt 用途說明(顯示在選擇介面) |
```
## 7.2 SSDLC 各階段 Prompt 範本

### 7.2.1 需求分析階段

**檔案**:`.github/prompts/requirements/analyze-user-story.prompt.md`

````markdown
---
mode: "agent"
tools:
  - "search"
  - "fetchWebpage"
description: "分析 User Story 並產出結構化需求文件"
---

# 分析 User Story

## 你的角色
你是一位資深需求分析師,擅長將模糊的業務需求轉化為精確的技術需求。

## 任務
分析以下 User Story,並產出結構化需求文件:

{{user_story}}

## 分析步驟
1. **功能需求**:
   - 列出所有功能需求(Functional Requirements)
   - 使用 MoSCoW 優先序:Must / Should / Could / Won't
   
2. **非功能需求**:
   - 效能需求(回應時間、吞吐量)
   - 安全需求(認證、授權、資料保護)
   - 可用性需求(SLA、容錯)
   
3. **驗收條件**:
   - 使用 Given-When-Then 格式撰寫
   
4. **安全考量**:
   - 識別 OWASP Top 10 相關風險
   - 資料分類(公開/內部/機密/限制)
   
5. **影響範圍**:
   - 受影響的現有模組
   - 需要新增的元件
   - 第三方整合需求

## 輸出格式
使用 Markdown 格式,包含上述所有分析結果。

7.2.2 設計階段

檔案.github/prompts/design/api-design.prompt.md

---
mode: "agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
description: "設計 RESTful API 並產出 OpenAPI 規格"
---

# API 設計

## 你的角色
你是一位 API 設計專家,遵循 RESTful 最佳實務與企業 API 標準。

## 任務
根據以下需求設計 API:

{{api_requirement}}

## 設計原則
1. **資源導向**:使用名詞命名資源,動詞用 HTTP Method 表達
2. **版本控制**:使用 URL 路徑版本(`/api/v1/`)
3. **分頁**:使用 `page` 和 `size` 參數
4. **篩選**:使用查詢參數
5. **錯誤回應**:統一錯誤格式
6. **安全**:定義認證方式(Bearer Token / API Key)

## 輸出要求
1. API 端點清單(表格格式)
2. Request/Response Schema
3. 錯誤碼定義
4. OpenAPI 3.0 YAML 規格(若適用)

7.2.3 開發階段

檔案.github/prompts/coding/implement-feature.prompt.md

---
mode: "agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
  - "runTests"
description: "根據設計規格實作功能"
---

# 實作功能

## 你的角色
你是一位資深開發工程師,遵循專案的程式碼規範與架構設計。

## 任務
根據以下規格實作功能:

{{feature_spec}}

## 實作規範
1. 遵循專案的分層架構(Controller → Service → Repository)
2. 撰寫完整的 JavaDoc 註解
3. 使用 Bean Validation 驗證輸入
4. 使用自訂 Exception 處理業務例外
5. 使用 SLF4J 記錄日誌
6. 確保所有輸入經過驗證與清洗(防止注入攻擊)

## 完成後
1. 確認程式碼可編譯通過
2. 列出需要撰寫的測試案例
3. 列出安全注意事項

7.2.4 測試階段

檔案.github/prompts/testing/generate-unit-tests.prompt.md

---
mode: "agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTerminalCommand"
  - "runTests"
description: "為指定類別產生全面的單元測試"
---

# 產生單元測試

## 你的角色
你是一位 QA 專家,專注於撰寫高品質的自動化測試。

## 任務
為以下類別產生全面的單元測試:

{{target_class}}

## 測試策略
1. **正常路徑**:驗證所有正常輸入的預期行為
2. **邊界值**:空值、零值、極大值、極小值
3. **異常路徑**:無效輸入、例外情況
4. **安全測試**:注入攻擊、權限繞過
5. **覆蓋率目標**:≥ 80% 行覆蓋率

## 技術框架
- JUnit 5
- Mockito(Mock 外部依賴)
- AssertJ(流暢斷言)

## 命名規範
```java
@Test
@DisplayName("當{前提條件}時,{操作}應該{預期結果}")
void should_預期行為_When_條件() { }
```

## 輸出要求
- 完整的測試類別(可直接編譯執行)
- 測試資料說明
- 執行結果截圖(若可能)

7.2.5 安全審查階段

檔案.github/prompts/security/threat-model.prompt.md

---
mode: "agent"
tools:
  - "search"
  - "fetchWebpage"
description: "執行威脅建模分析"
---

# 威脅建模

## 你的角色
你是一位資深資安工程師,使用 STRIDE 框架進行威脅建模。

## 任務
對以下系統或功能進行威脅建模:

{{target_system}}

## STRIDE 分析
針對每個元件分析:
| 威脅類別 | 說明 | 檢查項目 |
|---------|------|---------|
| **S**poofing(偽冒) | 身份偽造 | 認證機制、Token 驗證 |
| **T**ampering(竄改) | 資料竄改 | 資料完整性、簽章驗證 |
| **R**epudiation(否認) | 操作否認 | 日誌記錄、稽核軌跡 |
| **I**nformation Disclosure(資訊洩漏) | 敏感資料暴露 | 加密、存取控制 |
| **D**enial of Service(阻斷服務) | 服務中斷 | 限流、資源限制 |
| **E**levation of Privilege(權限提升) | 越權存取 | 最小權限、角色驗證 |

## 輸出格式
1. **資料流程圖**(Mermaid 格式)
2. **威脅清單**(含風險評級:Critical/High/Medium/Low)
3. **緩解措施**(每個威脅對應的防禦方案)
4. **殘餘風險**(已知但接受的風險)

7.2.6 Code Review 階段

檔案.github/prompts/review/code-review.prompt.md

---
mode: "agent"
tools:
  - "search"
  - "runTerminalCommand"
description: "執行結構化的程式碼審查"
---

# 程式碼審查

## 你的角色
你是一位資深程式碼審查員,遵循專案的品質標準。

## 任務
審查以下程式碼或變更:

{{code_or_pr}}

## 審查維度
1. **正確性**:邏輯是否正確、是否有 Bug
2. **安全性**:是否有安全漏洞(OWASP Top 10)
3. **效能**:是否有效能問題(N+1、記憶體洩漏)
4. **可維護性**:SOLID 原則、程式碼可讀性
5. **測試**:測試覆蓋率、測試品質
6. **文件**:JavaDoc、README 更新

## 審查標準
- 🔴 **Must Fix**:安全漏洞、明顯 Bug、資料損壞風險
- 🟡 **Should Fix**:效能問題、程式碼風格、錯誤處理
- 🟢 **Nice to Have**:命名改善、最佳實務建議

## 輸出格式
使用表格格式列出所有發現,包含檔案、行號、類別、嚴重度、說明與建議修正。

7.2.7 逆向工程階段

檔案.github/prompts/reverse-engineering/analyze-legacy-module.prompt.md

---
mode: "agent"
tools:
  - "search"
  - "editFiles"
  - "createFile"
  - "runTerminalCommand"
description: "分析遺留系統模組並產出技術文件"
---

# 遺留系統模組分析

## 你的角色
你是一位遺留系統分析專家,擅長在缺乏文件的情況下理解現有系統。

## 任務
分析以下遺留系統模組:

{{module_path}}

## 分析步驟
1. **結構分析**
   - 掃描目錄結構,識別主要元件
   - 識別使用的框架和技術
   - 統計程式碼規模(檔案數、行數)

2. **依賴分析**
   - 模組內部依賴
   - 外部套件依賴(版本與安全性)
   - 系統間依賴(API、資料庫、訊息佇列)

3. **邏輯分析**
   - 識別進入點(API、排程、事件)
   - 追蹤核心業務流程
   - 提取業務規則

4. **風險評估**
   - 技術債務量化
   - 安全漏洞識別
   - 可維護性評分

## 輸出
1. 模組概覽文件(Markdown)
2. 依賴關係圖(Mermaid)
3. 業務流程圖(Mermaid)
4. 風險評估報告
5. 現代化改造建議

7.3 Prompt 設計原則

好的 Prompt 設計

原則說明範例
角色明確明確定義 AI 的角色「你是一位資深 Java 開發工程師」
任務具體明確描述要完成的任務「產生 UserService 的單元測試」
輸出格式定義具體的輸出格式「使用 Markdown 表格列出所有 API」
限制條件設定明確的限制「使用 JUnit 5,不使用 JUnit 4」
變數化使用 {{}} 參數化可變內容{{target_class}}
安全內建在每個 Prompt 中內建安全考量「包含 OWASP Top 10 相關檢查」

反模式

反模式問題改善
「幫我寫好程式」太模糊,無法產出一致結果明確描述功能、規範、限制
「做所有事」範圍太大,品質無法保證拆分為多個 Prompt
無安全要求忽略安全考量加入安全檢查項目
無輸出格式每次輸出不一致定義明確的輸出模板
硬編碼內容無法重複使用使用 {{}} 變數

7.4 Prompt 管理策略

目錄結構

.github/prompts/
├── requirements/         # 需求階段
│   └── analyze-user-story.prompt.md
├── design/              # 設計階段
│   └── api-design.prompt.md
├── coding/              # 開發階段
│   └── implement-feature.prompt.md
├── testing/             # 測試階段
│   └── generate-unit-tests.prompt.md
├── security/            # 安全階段
│   └── threat-model.prompt.md
├── review/              # 審查階段
│   └── code-review.prompt.md
└── reverse-engineering/  # 逆向工程
    └── analyze-legacy-module.prompt.md

命名規範

{動詞}-{目標}.prompt.md

範例:
- analyze-user-story.prompt.md
- generate-unit-tests.prompt.md
- review-security.prompt.md
- implement-feature.prompt.md

團隊使用方式

VS Code 中使用 Prompt:
1. 開啟 Copilot Chat
2. 輸入 / 或點選附件圖示
3. 選擇「Prompt...」
4. 從列表中選擇 Prompt
5. 系統會提示填入變數
6. 送出後 Agent 會依據 Prompt 執行

8. 建立 Custom Instructions

8.1 Instructions 類型總覽

類型檔案位置觸發方式適用環境用途
Repo-wide Instructions.github/copilot-instructions.md✓ 自動套用至所有對話VS Code, JetBrains專案全域規範
File-based Instructions.github/instructions/*.instructions.md✓ 按 applyTo 模式自動套用VS Code針對特定檔案類型的規範
AGENTS.mdAGENTS.md(Repository 根目錄)✓ 自動套用VS Code, GitHub.com, CLI跨 AI 工具通用指令
組織層級.github-private repo 的 instructions/✓ 自動套用VS Code組織統一規範
個人層級~/.copilot/instructions/✓ 自動套用VS Code個人偏好

優先順序

個人 Instructions > 檔案型 Instructions > Repo-wide Instructions > 組織 Instructions

8.2 Repo-wide Instructions

檔案.github/copilot-instructions.md

# 專案 Copilot Instructions

## 專案概述
本專案為企業級電商平台後端服務,使用 Java 21 + Spring Boot 3.3 技術棧。

## 程式碼規範

### 語言與框架
- Java 21(使用 Record、Pattern Matching、Virtual Thread 等新特性)
- Spring Boot 3.3.x
- Maven 建置

### 命名慣例
- 類別名稱:PascalCase(`UserService`)
- 方法與變數:camelCase(`findByEmail`)
- 常數:UPPER_SNAKE_CASE(`MAX_RETRY_COUNT`)
- 套件名稱:全小寫(`com.company.project.service`)

### 架構規範
- 分層架構:Controller → Service → Repository
- Controller 只做參數驗證與回應組裝
- Service 處理業務邏輯
- Repository 負責資料存取

### 日誌規範
- 使用 SLF4J + Log4j2
- ERROR:系統錯誤,需要立即處理
- WARN:可恢復的問題
- INFO:重要業務事件
- DEBUG:開發除錯資訊
- 禁止在日誌中輸出:密碼、Token、個資

### 安全規範
- 所有外部輸入必須驗證
- SQL 查詢使用參數化查詢
- 敏感資料傳輸使用 HTTPS
- 密碼儲存使用 BCrypt
- API 必須有認證與授權

### 測試規範
- 使用 JUnit 5 + Mockito + AssertJ
- 測試覆蓋率 ≥ 80%
- 測試命名:should_預期行為_When_條件

### 文件規範
- 所有 public 方法必須有 JavaDoc
- README 保持更新
- API 變更需更新 OpenAPI 規格

重要:此檔案的內容會自動注入到每一次 Copilot 對話中,因此應保持精簡(建議 ≤ 500 行)。過長的指令會稀釋 AI 的注意力。

8.3 File-based Instructions

格式

---
applyTo: "**/*.java"
---

# Java 檔案規範

(適用於所有 .java 檔案的規範)

範例集

檔案.github/instructions/backend-java.instructions.md

---
applyTo: "src/main/java/**/*.java"
---

# Java 後端程式碼規範

## 通用規則
- 使用 Java 21 語法特性
- 所有 public 類別和方法必須有 JavaDoc 註解
- 使用 Lombok 的 @Slf4j 替代手動建立 Logger
- 例外處理使用自訂 BusinessException 體系

## Controller 規則
- 使用 @RestController 和 @RequestMapping
- 參數驗證使用 @Valid 和 Bean Validation 註解
- 回傳統一的 ApiResponse<T> 包裝

## Service 規則
- 使用 @Service 註解
- 事務管理使用 @Transactional(只在需要時)
- 複雜業務邏輯拆分為私有方法

## Repository 規則
- 繼承 JpaRepository
- 複雜查詢使用 @Query 或 Specification
- 禁止在 Repository 中寫業務邏輯

檔案.github/instructions/security.instructions.md

---
applyTo: "src/**/*.{java,ts,tsx}"
---

# 安全程式碼規範

## 輸入驗證
- 所有外部輸入(HTTP 參數、Header、Body)必須驗證
- 使用白名單驗證,不使用黑名單
- 數值輸入檢查範圍
- 字串輸入檢查長度與格式

## 注入防護
- SQL:使用 JPA/Hibernate 參數化查詢,禁止字串拼接 SQL
- XSS:輸出時進行 HTML 編碼
- Command Injection:禁止直接執行使用者輸入的系統指令
- Path Traversal:驗證檔案路徑,禁止 ../ 

## 認證與授權
- 使用 Spring Security
- API 端點使用 @PreAuthorize 或 @Secured
- 實作最小權限原則

## 敏感資料
- 密碼使用 BCrypt 雜湊
- 敏感配置使用環境變數或 Vault
- 日誌不可包含密碼、Token、個資
- API 回應不可包含內部錯誤堆疊

檔案.github/instructions/testing.instructions.md

---
applyTo: "src/test/**/*.java"
---

# 測試程式碼規範

## 框架
- JUnit 5 + Mockito + AssertJ

## 結構
- 使用 AAA 模式:Arrange → Act → Assert
- 每個測試方法只測試一個行為
- Mock 外部依賴(資料庫、API、訊息佇列)

## 命名
- 測試類別:{被測類別}Test(如 UserServiceTest)
- 測試方法:should_{預期行為}_When_{條件}
- 使用 @DisplayName 提供中文描述

## 安全測試
- 每個 Controller 測試必須包含未認證存取測試
- 測試無效輸入(SQL Injection payload、XSS payload)

檔案.github/instructions/code-review.instructions.md

---
applyTo: "**/*.{java,ts,tsx,js,jsx}"
---

# Code Review 指引

## 審查重點
當被要求審查程式碼時,請依以下優先序檢查:

1. **安全性**(最高優先)
   - 注入漏洞、認證繞過、資料洩漏
   
2. **正確性**
   - 業務邏輯錯誤、邊界條件、Race Condition
   
3. **效能**
   - N+1 查詢、不必要的記憶體分配、阻塞操作
   
4. **可維護性**
   - SOLID 違規、過度複雜、重複程式碼
   
5. **測試**
   - 覆蓋率、邊界測試、錯誤路徑測試

檔案.github/instructions/pr-description.instructions.md

---
applyTo: "**"
---

# PR Description 指引

當被要求撰寫 PR 描述時,使用以下格式:

## 變更摘要
{一句話描述本次變更的目的}

## 變更類型
- [ ] 新功能
- [ ] Bug 修正
- [ ] 重構
- [ ] 文件
- [ ] 安全修正

## 變更內容
{詳細描述變更內容,使用條列式}

## 安全影響
{描述本次變更的安全影響,如無影響請註明}

## 測試
- [ ] 單元測試通過
- [ ] 整合測試通過
- [ ] 手動測試完成

## 相關 Issue
Closes #{issue_number}

8.4 AGENTS.md

AGENTS.md 是放在 Repository 根目錄的通用指令檔案,適用於所有支援此格式的 AI 工具(VS Code Copilot、Claude Code 等)。

# AGENTS.md

## 專案背景
本專案為企業級電商平台。

## 通用規則
1. 使用繁體中文撰寫註解和文件
2. 程式碼必須遵循專案既定的架構模式
3. 所有程式碼變更必須包含對應的測試
4. 安全是第一優先考量

## 禁止事項
1. 不可刪除現有的測試案例
2. 不可降低測試覆蓋率
3. 不可在日誌中輸出敏感資訊
4. 不可使用 deprecated 的 API
5. 不可提交含有已知 CVE 的依賴

AGENTS.md vs .github/copilot-instructions.mdAGENTS.md 是跨工具通用的,而 copilot-instructions.md 專屬於 GitHub Copilot。如果同時存在,兩者都會被載入。

8.5 組織層級 Instructions

設定步驟

1. 在組織中建立 `.github-private` Repository
2. 建立 instructions/ 目錄
3. 加入組織級 Instructions 檔案

.github-private/
└── instructions/
    ├── org-coding-standards.instructions.md
    ├── org-security-policy.instructions.md
    └── org-naming-convention.instructions.md

範例

檔案.github-private/instructions/org-security-policy.instructions.md

---
applyTo: "**"
---

# 組織安全政策

## 強制規範
1. 所有 API 必須使用 HTTPS
2. 密碼雜湊使用 BCrypt(cost factor ≥ 12)
3. JWT Token 過期時間 ≤ 1 小時
4. 所有敏感操作必須記錄稽核日誌
5. 第三方依賴必須經過安全掃描

## 禁止事項
1. 禁止使用 MD5、SHA-1 做密碼雜湊
2. 禁止在程式碼中硬編碼金鑰或密碼
3. 禁止使用 eval() 或類似的動態執行
4. 禁止關閉 CSRF 保護(除非有明確理由並經安全團隊核准)

8.6 Instructions 設計最佳實務

原則說明
精簡copilot-instructions.md 建議 ≤ 500 行,避免稀釋注意力
具體使用具體的程式碼範例,不要只寫抽象規則
可驗證每條規則都應該可以客觀驗證(能或不能)
分層通用規則放 copilot-instructions.md,特定規則用 file-based
不重複避免在多個 Instructions 檔案中重複相同規則
安全優先安全規範應在每層都有涵蓋
定期更新隨專案演進定期審視與更新 Instructions

9. 建立 Agent Skills

9.1 Skills 概念

Agent Skills 是可被 Agent 自動載入的專業能力模組,基於開放標準(agentskills.io)。每個 Skill 定義了特定的能力,包含工具、腳本、範本與指引。

Skills 儲存位置

Skills 支援多種儲存路徑(專案層級與個人層級):

專案層級(納入版本控管):

路徑格式說明
.github/skills/<skill-name>/SKILL.mdGitHub 原生主要推薦路徑
.claude/skills/<skill-name>/SKILL.mdClaude 相容跨 VS Code 與 Claude Code 共用
.agents/skills/<skill-name>/SKILL.md通用格式開放標準格式

個人層級(跨工作區):

路徑說明
~/.copilot/skills/<skill-name>/SKILL.mdGitHub Copilot 個人 Skills
~/.claude/skills/<skill-name>/SKILL.mdClaude Code 個人 Skills
~/.agents/skills/<skill-name>/SKILL.md通用個人 Skills

gh skill CLI 命令

使用 GitHub CLI 探索與安裝社群 Skills:

# 探索可用的 Skills
gh skill search "security review"

# 安裝 Skill 到目前專案
gh skill install <skill-name>

# 列出已安裝的 Skills
gh skill list

💡 組織/企業層級 Skills:目前為「Coming Soon」狀態,未來將支援在 .github-private repo 中定義組織級 Skills。

Skills vs Instructions vs Prompts

特性SkillsInstructionsPrompts
用途可執行的專業能力靜態規則與限制任務範本
包含腳本✓ 可包含可執行腳本
包含範本✓ 可包含檔案範本
觸發方式相關時自動載入自動套用手動選用
支援 Slash Command✓(透過 name frontmatter)✓(/
版本控管
放置位置.github/skills/{name}/SKILL.md.github/instructions/.github/prompts/

SKILL.md Frontmatter

欄位類型必要說明
namestringSkill 名稱(可作為 Slash Command)
descriptionstringSkill 描述(AI 用來判斷是否相關)

9.2 Skill 1 — Security Review

目錄結構

.github/skills/security-review/
├── SKILL.md
└── scripts/
    └── owasp-check.sh

檔案.github/skills/security-review/SKILL.md

---
name: "security-review"
description: "執行 OWASP Top 10 安全審查,識別程式碼中的安全漏洞"
---

# Security Review Skill

## 能力
此 Skill 可以:
1. 基於 OWASP Top 10 審查程式碼安全性
2. 識別常見的安全漏洞模式
3. 執行依賴安全掃描
4. 產出結構化的安全審查報告

## 使用方式
當需要進行安全審查時,請:

1. **識別審查範圍**:確定要審查的檔案或模組
2. **執行靜態分析**:掃描程式碼中的安全漏洞模式
3. **依賴掃描**:如果存在 `pom.xml`,執行:
   
   ./scripts/owasp-check.sh
   
4. **產出報告**:使用以下格式

## 安全漏洞檢查清單

### A01 - Broken Access Control
- [ ] 是否有缺少授權檢查的端點
- [ ] 是否有 IDOR(Insecure Direct Object Reference)
- [ ] CORS 配置是否正確

### A02 - Cryptographic Failures
- [ ] 是否使用了過時的加密算法(MD5、SHA-1、DES)
- [ ] 密碼是否使用 BCrypt/Argon2 雜湊
- [ ] 敏感資料是否加密傳輸

### A03 - Injection
- [ ] SQL 查詢是否使用參數化
- [ ] 是否有 OS Command Injection 風險
- [ ] 是否有 LDAP/XPath Injection

### A04 - Insecure Design
- [ ] 是否實作 Rate Limiting
- [ ] 是否有適當的輸入驗證

### A05 - Security Misconfiguration
- [ ] 是否暴露了 debug/stack trace 資訊
- [ ] 預設帳號/密碼是否已移除

## 報告格式

## 安全審查報告

**掃描日期**:{date}
**掃描範圍**:{scope}

| # | OWASP 類別 | 風險等級 | 檔案 | 行號 | 說明 | 修正建議 |
|---|-----------|---------|------|------|------|---------|

檔案.github/skills/security-review/scripts/owasp-check.sh

#!/bin/bash
# OWASP Dependency Check 執行腳本
echo "=== OWASP Dependency Check ==="
if [ -f "pom.xml" ]; then
    mvn org.owasp:dependency-check-maven:check -DfailBuildOnCVSS=7
elif [ -f "package.json" ]; then
    npm audit --audit-level=high
elif [ -f "requirements.txt" ]; then
    pip-audit -r requirements.txt
else
    echo "未找到支援的依賴管理檔案"
fi

9.3 Skill 2 — JUnit Test Generator

目錄結構

.github/skills/junit-generator/
├── SKILL.md
└── templates/
    └── test-template.java

檔案.github/skills/junit-generator/SKILL.md

---
name: "junit-generator"
description: "產生 JUnit 5 單元測試,遵循 AAA 模式與團隊命名規範"
---

# JUnit Test Generator Skill

## 能力
此 Skill 可以:
1. 分析 Java 類別結構
2. 為每個 public 方法產生測試
3. 產生邊界值與異常路徑測試
4. 使用 Mockito Mock 外部依賴

## 測試範本
使用 `templates/test-template.java` 作為基礎範本。

## 產生規則
1. **測試類別命名**:`{被測類別}Test`
2. **測試方法命名**:`should_{預期行為}_When_{條件}`
3. **每個方法至少 3 個測試**:
   - 正常路徑(Happy Path)
   - 邊界值(Boundary)
   - 異常路徑(Error Path)
4. **使用 @DisplayName** 提供可讀的測試描述
5. **使用 AssertJ** 進行斷言

## 覆蓋率目標
- 行覆蓋率 ≥ 80%
- 分支覆蓋率 ≥ 70%

9.4 Skill 3 — PR Checker

檔案.github/skills/pr-checker/SKILL.md

---
name: "pr-checker"
description: "檢查 PR 是否符合團隊規範,包含 commit message、變更範圍、測試覆蓋"
---

# PR Checker Skill

## 能力
此 Skill 可以:
1. 驗證 commit message 格式(Conventional Commits)
2. 檢查 PR 描述完整性
3. 驗證測試覆蓋率
4. 檢查是否有敏感資訊洩漏
5. 確認安全審查已完成

## Commit Message 格式

<type>(<scope>): <description>

type: feat|fix|refactor|test|docs|chore|security
scope: 可選,模組名稱
description: 簡短描述(≤ 72 字元)


## PR 檢查清單
- [ ] PR 標題符合 Conventional Commits 格式
- [ ] PR 描述包含變更摘要
- [ ] 所有測試通過
- [ ] 測試覆蓋率 ≥ 80%
- [ ] 無敏感資訊(密碼、Token、API Key)
- [ ] 安全審查已完成(若涉及安全變更)
- [ ] 文件已更新(若涉及 API 變更)
- [ ] Breaking Change 已標註

9.5 Skill 4 — API Reviewer

檔案.github/skills/api-reviewer/SKILL.md

---
name: "api-reviewer"
description: "審查 RESTful API 設計,確保符合企業 API 標準"
---

# API Reviewer Skill

## 能力
審查 API 端點設計是否符合以下標準:

## API 設計規範

### URL 設計
- 使用名詞複數(`/users`,不用 `/user`)
- 使用 kebab-case(`/user-profiles`,不用 `/userProfiles`)
- 版本號在路徑中(`/api/v1/users`)
- 巢狀資源最多 2 層(`/users/{id}/orders`)

### HTTP Method
| Method | 用途 | 冪等 | 安全 |
|--------|------|------|------|
| GET | 查詢資源 | ✓ | ✓ |
| POST | 建立資源 | ✗ | ✗ |
| PUT | 完整更新 | ✓ | ✗ |
| PATCH | 部分更新 | ✗ | ✗ |
| DELETE | 刪除資源 | ✓ | ✗ |

### 回應狀態碼
| 狀態碼 | 用途 |
|--------|------|
| 200 | 成功(含回應 body) |
| 201 | 建立成功 |
| 204 | 成功(無 body) |
| 400 | 請求格式錯誤 |
| 401 | 未認證 |
| 403 | 未授權 |
| 404 | 資源不存在 |
| 409 | 衝突 |
| 422 | 驗證失敗 |
| 500 | 伺服器錯誤 |

### 安全要求
- 所有端點必須定義認證方式
- 敏感操作需要額外的授權檢查
- 回應中不可包含內部實作細節

9.6 Skill 5 — Reverse Analysis

檔案.github/skills/reverse-analysis/SKILL.md

---
name: "reverse-analysis"
description: "分析遺留系統模組,產出架構文件與依賴圖"
---

# Reverse Analysis Skill

## 能力
此 Skill 可以:
1. 掃描模組目錄結構
2. 分析程式碼依賴關係
3. 提取業務邏輯規則
4. 產出 Mermaid 架構圖
5. 評估技術債務

## 分析模板

### 模組分析報告模板
使用 `templates/module-report.md` 格式。

### 依賴關係圖模板
使用 `templates/dependency-map.md` 格式。

## 分析流程
1. 列出模組內所有檔案及行數
2. 識別進入點(Controller、Main、Scheduler)
3. 追蹤核心流程的呼叫鏈
4. 建立依賴關係圖
5. 識別外部系統整合點
6. 評估程式碼品質與技術債務
7. 提出現代化建議

9.7 Skill 6 — Doc Generator

檔案.github/skills/doc-generator/SKILL.md

---
name: "doc-generator"
description: "根據原始碼自動產生技術文件,包含 API 文件、架構說明、使用者指南"
---

# Doc Generator Skill

## 能力
此 Skill 可以:
1. 掃描原始碼產生 API 文件
2. 根據架構產生架構說明文件
3. 根據功能產生使用者指南
4. 產生 Mermaid 圖表

## 文件模板

### API 文件格式
使用 `templates/api-doc-template.md`:

```markdown
# API 文件:{API 名稱}

## 概述
{API 用途說明}

## 端點
### {Method} {Path}

**描述**:{端點說明}

**認證**:{認證方式}

**Request**:
| 參數 | 類型 | 必要 | 說明 |
|------|------|------|------|

**Response**:
json
{
  "範例回應"
}


**錯誤碼**:
| 狀態碼 | 說明 |
|--------|------|


## 撰寫原則
1. 使用繁體中文
2. 技術名詞保留英文
3. 每個概念配合程式碼範例
4. 使用 Mermaid 繪製流程圖

9.8 Skills 管理策略

策略說明
版本控管所有 Skills 納入 Git
獨立目錄每個 Skill 一個獨立目錄
SKILL.md 必要每個 Skill 目錄必須有 SKILL.md
腳本可執行確保腳本有正確的執行權限
定期更新隨專案需求演進更新 Skill 內容
團隊審核新 Skill 需經 PR 審核

10. 設定 Hooks

10.1 Hooks 概念

Hooks 是在 Agent 操作前後自動執行的腳本或指令,可用於實作品質門檻、安全檢查與自動化護欄。

環境支援狀態

環境支援狀態設定方式
VS Code⚠️ Preview(需 chat.useCustomAgentHooks 設定)Agent frontmatter + .github/hooks/
GitHub.com Cloud AgentGARepository 設定
GitHub CLIGARepository 設定

Hook 觸發時機

Hook 事件觸發時機使用場景
postCreateAgent 建立新檔案後自動格式化、Lint 檢查
postEditAgent 編輯現有檔案後編譯檢查、靜態分析

10.2 VS Code Hooks 設定(Preview)

啟用設定

// .vscode/settings.json
{
  "chat.useCustomAgentHooks": true
}

Agent-scoped Hooks

在 Agent Profile 的 frontmatter 中定義:

---
name: "Backend Developer"
hooks:
  postCreate:
    - command: "mvn checkstyle:check -Dcheckstyle.includes={{files}}"
      description: "新建檔案後自動執行 Checkstyle"
  postEdit:
    - command: "mvn compile -pl {{module}}"
      description: "修改檔案後自動編譯"
    - command: "mvn spotbugs:check"
      description: "修改後執行 SpotBugs 靜態分析"
---

Project-level Hooks

檔案.github/hooks/ssdlc-guardrails.json

{
  "hooks": {
    "postCreate": [
      {
        "command": "npx prettier --write {{files}}",
        "description": "自動格式化新建的檔案"
      }
    ],
    "postEdit": [
      {
        "command": "mvn compile",
        "description": "編輯後自動編譯確認無語法錯誤"
      },
      {
        "command": "mvn checkstyle:check",
        "description": "編輯後自動執行 Checkstyle"
      }
    ]
  }
}

10.3 Cloud Agent / CLI Hooks

GitHub.com Cloud Agent 和 CLI 的 Hooks 使用 GitHub Actions workflow 觸發,機制與 VS Code 不同。

設定方式

Cloud Agent 的自動化護欄主要透過:

  1. GitHub Actions Workflow:在 PR 建立或更新時觸發
  2. Branch Protection Rules:要求特定 Check 通過
  3. CODEOWNERS:要求特定人員審核

範例 Workflow

# .github/workflows/copilot-guardrails.yml
name: Copilot Guardrails

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  security-check:
    runs-on: ubuntu-latest
    if: contains(github.event.pull_request.labels.*.name, 'copilot-generated')
    steps:
      - uses: actions/checkout@v4
      - name: Run OWASP Dependency Check
        run: mvn org.owasp:dependency-check-maven:check
      - name: Run SpotBugs
        run: mvn spotbugs:check
      - name: Run Checkstyle
        run: mvn checkstyle:check
      
  test-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Tests
        run: mvn test
      - name: Check Coverage
        run: |
          mvn jacoco:report
          # 驗證覆蓋率 ≥ 80%

10.4 Autopilot 風險與護欄設計

風險等級

模式Agent 行為風險企業建議
手動確認每個動作需人工確認✓ 安全敏感操作使用
Auto-approve 部分低風險操作自動執行✓ 日常開發可用,搭配 Hooks 護欄
Autopilot(全自動)Agent 自行決定並執行所有動作⚠️ 不建議使用

Autopilot 風險案例

⚠️ 已知風險場景:
1. Agent 自動刪除「不需要」的檔案 → 刪除了重要設定檔
2. Agent 自動修改 pom.xml → 引入含 CVE 的依賴
3. Agent 自動修改安全設定 → 降低了安全等級
4. Agent 自動執行 git push → 推送了未經審查的程式碼
5. Agent 自動修改 CI/CD 配置 → 繞過了安全檢查

護欄策略

graph TD
    A[Agent 執行動作] --> B{Hook 檢查}
    B -->|通過| C[允許執行]
    B -->|失敗| D[阻止執行]
    D --> E[通知開發者]
    C --> F{Branch Protection}
    F -->|通過| G[合併]
    F -->|失敗| H[要求修正]
    
    style D fill:#f44,color:#fff
    style G fill:#4a4,color:#fff

企業護欄設計建議

護欄層級實作方式作用
L1 — Agent 內建Agent Profile 的限制條款限制 Agent 行為範圍
L2 — HookspostCreate / postEdit hooks自動化品質檢查
L3 — CI/CDGitHub Actions WorkflowPR 級別的門檻檢查
L4 — Branch ProtectionRequired reviews, status checks合併前的最終門檻
L5 — CODEOWNERS特定檔案需特定人員審核高風險檔案保護

11. 管理 Copilot Memory

11.1 Memory 概念

Copilot Memory(官方亦稱 Agentic Memory)是 Public Preview 功能,讓 Copilot 記住使用者和專案的偏好、慣例與上下文,避免在每次對話中重複說明。Memory 具備跨功能共享特性:Cloud Agent 儲存的 Memory 會自動被 Code Review 和 CLI 引用,反之亦然。

Memory 特性

特性說明
範圍Repository-scoped(每個 Repository 獨立)
有效期28 天自動過期
使用環境Cloud Agent、Code Review、CLI(跨功能共享 Agentic Memory)
引用驗證Memory 引用時會自動對比目前程式碼庫驗證正確性(Citations)
權限需求需要 Repository write 權限
預設狀態Business/Enterprise:預設關閉,需管理員啟用
個人帳號Pro/Pro+:預設開啟

Memory vs Instructions

比較項目MemoryInstructions
儲存方式Copilot 自動管理檔案系統(Git 版控)
有效期28 天自動過期永久(除非手動刪除)
可見性不可直接查看完整內容完全可見可編輯
適用場景動態偏好、對話上下文固定規則、團隊規範
版本控管✗ 不可✓ 可
團隊共享✗ 個人✓ 透過 Git

11.2 啟用 Memory

管理員啟用步驟

1. 前往 Organization Settings → Copilot → Policies
2. 找到「Copilot Memory」設定
3. 設定為「Enabled」
4. 儲存變更

個人設定

1. 前往 github.com → Settings → Copilot
2. 找到「Memory」區段
3. 確認已啟用

11.3 Memory 治理

適合存入 Memory 的內容

類別範例風險
程式碼風格偏好「我偏好使用 var 宣告局部變數」
工具偏好「使用 AssertJ 做斷言,不用 JUnit 內建」
專案上下文「本專案使用 PostgreSQL 15」
命名習慣「DTO 類別後綴用 Response,不用 DTO」
架構決策「我們採用 CQRS 模式」

不應存入 Memory 的內容

類別範例風險
密碼 / TokenAPI Key、Database Password🔴 Critical
個人資訊身分證號、地址、電話🔴 Critical
商業機密營業秘密、未公開財務資訊🟠 High
安全配置防火牆規則、加密金鑰🟠 High
客戶資料客戶名單、交易資料🔴 Critical

治理政策建議

## Copilot Memory 使用政策

### 允許存入
✅ 程式碼風格偏好
✅ 工具與框架選擇
✅ 公開的架構決策
✅ 非敏感的專案背景資訊

### 禁止存入
❌ 任何形式的密碼、Token、API Key
❌ 個人可識別資訊(PII)
❌ 商業機密或未公開資訊
❌ 安全相關配置細節
❌ 客戶資料或交易資料

### 監控與稽核
- 定期提醒團隊成員 Memory 使用政策
- Memory 28 天自動過期,降低長期風險
- 發現違規存入時,立即通知管理員

11.4 Memory 最佳實務

實務說明
了解限制Memory 28 天過期,不適合作為永久儲存
使用 Instructions 替代團隊規範應使用 Instructions,不依賴 Memory
定期教育定期提醒團隊 Memory 的安全使用原則
不依賴關鍵資訊不應只存在 Memory 中,應有其他紀錄
敏感資訊檢查建立自我檢查機制,確認未將敏感資訊告訴 Copilot

12. PR 工作流程(PR Workflow)

12.1 概述

Pull Request(PR)是 SSDLC 中程式碼審查與品質把關的核心環節。透過 GitHub Copilot Agent Team,可以在 PR 流程中自動化多項檢查,包括程式碼品質、安全性、測試覆蓋率與文件完整性。

PR 工作流程在 SSDLC 中的定位

graph LR
    subgraph 開發階段
        A[Feature Branch] --> B[本地開發]
        B --> C[Agent 輔助 Coding]
        C --> D[本地測試]
    end
    
    subgraph PR 階段
        D --> E[建立 PR]
        E --> F{自動檢查}
        F --> G[Copilot Review]
        F --> H[CI/CD Pipeline]
        F --> I[Security Scan]
        G --> J{通過?}
        H --> J
        I --> J
        J -->|是| K[人工審查]
        J -->|否| L[修復問題]
        L --> E
        K --> M{核准?}
        M -->|是| N[合併]
        M -->|否| L
    end
    
    subgraph 合併後
        N --> O[自動部署]
        O --> P[監控驗證]
    end

12.2 Copilot 自動 PR Review

12.2.1 啟用 Copilot Code Review

在 GitHub.com 的 Repository Settings 中啟用:

Repository Settings → Code security and analysis → Copilot → Code Review

設定選項

  • Automatic Review:每次 PR 自動觸發 Copilot Review
  • Manual Review:手動請求 Copilot Review(在 PR Reviewers 中選擇 Copilot

12.2.2 自訂 Review 指引

.github/copilot-review-instructions.md 中定義 Review 規則:

# Copilot Review Instructions

## 審查重點
1. **安全性**:檢查 OWASP Top 10 漏洞
2. **效能**:識別 N+1 查詢、記憶體洩漏
3. **例外處理**:確保適當的錯誤處理
4. **日誌記錄**:敏感資訊不得寫入日誌
5. **測試**:新功能必須有對應測試

## 專案特定規則
- Controller 不得包含業務邏輯
- Service 層必須使用介面
- 資料庫操作必須使用參數化查詢
- API 回應必須使用統一格式
- 所有 API 必須有認證

## 不需審查
- 自動產生的檔案
- 測試資料檔案(.json, .csv)

12.2.3 Copilot Review 回饋格式

Copilot 的 Review 回饋會以行內評論方式呈現:

📌 Copilot Review 回饋分類:

🔴 Critical(必須修復)
   - 安全漏洞
   - 資料損壞風險
   - 嚴重 Bug

🟡 Suggestion(建議修改)  
   - 效能改善
   - 程式碼風格
   - 最佳實務

🟢 Nitpick(可選修改)
   - 命名改善
   - 文件建議

12.3 PR Workflow 自動化

12.3.1 PR Agent 自動化流程

使用 Cloud Agent(Copilot Coding Agent)自動處理 PR 相關任務:

sequenceDiagram
    participant Dev as 開發者
    participant PR as Pull Request
    participant Bot as Copilot Bot
    participant CI as CI/CD Pipeline
    participant Rev as 人工審查者
    
    Dev->>PR: 建立 PR
    PR->>Bot: 觸發自動 Review
    PR->>CI: 觸發 CI Pipeline
    
    par 並行檢查
        Bot->>Bot: 程式碼品質審查
        Bot->>Bot: 安全性檢查
        CI->>CI: 編譯與測試
        CI->>CI: 靜態分析
    end
    
    Bot->>PR: 提交 Review 評論
    CI->>PR: 回報檢查結果
    
    alt 自動檢查通過
        PR->>Rev: 通知人工審查
        Rev->>PR: 審查與核准
        PR->>PR: 合併
    else 自動檢查失敗
        PR->>Dev: 通知修復
        Dev->>PR: 推送修正
        Note over PR,Bot: 重新觸發檢查流程
    end

12.3.2 GitHub Actions 整合

建立 .github/workflows/pr-review.yml

name: PR Review Workflow

on:
  pull_request:
    types: [opened, synchronize, reopened]

permissions:
  contents: read
  pull-requests: write
  issues: write

jobs:
  auto-review:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Run Copilot Review
        uses: github/copilot-code-review-action@v1
        with:
          # 使用自訂指引
          instructions: |
            Focus on security vulnerabilities,
            performance issues, and code quality.

      - name: Check PR Size
        run: |
          CHANGED_FILES=$(git diff --name-only origin/main...HEAD | wc -l)
          if [ "$CHANGED_FILES" -gt 20 ]; then
            echo "::warning::PR 變更檔案超過 20 個,建議拆分"
          fi

      - name: Label PR
        uses: actions/labeler@v5
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"

12.3.3 Branch Protection Rules

建議的 Branch Protection 設定:

規則設定說明
Require PR不允許直接推送到 main
Required reviewers≥ 1至少一位人工審查
Require Copilot reviewCopilot 必須完成審查
Require status checksCI 必須通過
Require up-to-date branch合併前必須是最新
Require signed commits建議確保提交者身份
Include administrators管理員也需遵守

12.4 Copilot 在 PR 中的互動

12.4.1 在 PR Comment 中使用 Copilot

在 PR 評論中可以直接與 Copilot 互動:

@copilot 請幫我審查這個 PR 的安全性
@copilot 這個函式的時間複雜度是多少?
@copilot 請建議如何重構這段程式碼
@copilot 請為這個變更產生測試案例

12.4.2 使用 Copilot 修復 PR 評論

當收到 Review 評論時,可以讓 Copilot Coding Agent 自動修復:

  1. 在 PR 評論中標記 @copilot
  2. 描述需要修復的問題
  3. Copilot 會建立新的 commit 推送修正
  4. 自動回覆評論,說明修復內容

12.4.3 PR Description 自動產生

使用 Copilot 自動產生 PR 描述:

  1. 建立 PR 時,點選「Generate with Copilot」按鈕
  2. Copilot 會分析 commit 變更,自動產出:
    • 變更摘要
    • 修改檔案列表
    • 影響範圍
    • 測試建議

12.5 Agent Management Tab(Agents 管理面板)

GitHub.com 新增 Agents Tab,提供集中式的 Agent 任務管理介面,與 PR 工作流程緊密整合:

功能說明
啟動任務直接從 Agents Tab 指派任務給 Copilot Coding Agent
監控日誌即時檢視 Agent 執行的操作日誌與工具呼叫
追蹤會話管理所有進行中與歷史的 Agent 會話
中途引導在 Agent 執行期間介入,修正方向或補充指示
開啟至 IDE將 Agent 會話轉移至 VS Code 或 CLI 繼續操作

💡 企業用途:Agents Tab 讓 Tech Lead 可以集中檢視團隊所有 Agent 任務的執行狀態,確保 Agent 行為符合預期。

12.6 PR 品質指標

12.6.1 PR 品質儀表板

指標目標說明
PR 大小≤ 400 行超過建議拆分
Review 時間≤ 4 小時從建立到首次 Review
修復循環≤ 2 次Review-修正的來回次數
自動檢查通過率≥ 90%首次提交即通過自動檢查
Copilot 建議採納率追蹤團隊採納 Copilot 建議的比例

12.6.2 PR 模板

建立 .github/PULL_REQUEST_TEMPLATE.md

## 變更說明
<!-- 簡述此 PR 的目的與變更內容 -->

## 變更類型
- [ ] 新功能(New Feature)
- [ ] Bug 修復(Bug Fix)
- [ ] 重構(Refactoring)
- [ ] 文件更新(Documentation)
- [ ] 安全修復(Security Fix)

## 測試
- [ ] 單元測試通過
- [ ] 整合測試通過
- [ ] 手動測試完成

## 安全檢查
- [ ] 無硬編碼的密碼或金鑰
- [ ] 輸入已驗證與清洗
- [ ] SQL 使用參數化查詢
- [ ] 敏感資訊未寫入日誌
- [ ] API 有適當的認證與授權

## 影響範圍
<!-- 列出受影響的模組或功能 -->

## 截圖/證據
<!-- 如適用,附上截圖或測試結果 -->

## 備註
<!-- 任何額外需要審查者注意的事項 -->

13. SSDLC 全流程整合(⭐ 全文件核心)

13.1 概述

本章是整份手冊的核心,展示如何將前面章節建立的所有元件(Agent、Instructions、Skills、Hooks、Prompt、Memory)串連成完整的 SSDLC 流程。

SSDLC 與傳統 SDLC 的差異

面向傳統 SDLCSSDLC(Security 內建)
安全介入時機開發完成後測試每個階段都有安全檢查
安全角色獨立的安全團隊每位開發者都是安全守門員
安全工具外部掃描工具內建於開發工具鏈
安全成本後期修復成本高早期發現,修復成本低
安全知識集中於少數專家透過 Agent 普及安全知識

13.2 SSDLC 全流程圖

graph TB
    subgraph "Phase 1: 需求與規劃"
        A1[User Story] --> A2[需求分析 Agent]
        A2 --> A3[威脅建模]
        A3 --> A4[安全需求文件]
    end
    
    subgraph "Phase 2: 設計"
        A4 --> B1[架構設計]
        B1 --> B2[API 設計 Agent]
        B2 --> B3[安全架構審查]
        B3 --> B4[設計文件]
    end
    
    subgraph "Phase 3: 開發"
        B4 --> C1[Coding Agent 實作]
        C1 --> C2[Security Agent
即時審查] C2 --> C3[Unit Test Agent
測試產生] C3 --> C4[本地測試通過] end subgraph "Phase 4: 程式碼審查" C4 --> D1[建立 PR] D1 --> D2[Copilot Auto Review] D2 --> D3[PR Checker Agent] D3 --> D4[人工審查] D4 --> D5[核准合併] end subgraph "Phase 5: 測試" D5 --> E1[整合測試] E1 --> E2[安全測試
SAST/DAST] E2 --> E3[效能測試] E3 --> E4[UAT] end subgraph "Phase 6: 部署與監控" E4 --> F1[部署至 Staging] F1 --> F2[部署驗證] F2 --> F3[部署至 Production] F3 --> F4[持續監控] end subgraph "Phase 7: 維護與回饋" F4 --> G1[事件回應] G1 --> G2[逆向分析 Agent] G2 --> G3[改善回饋] G3 --> A1 end style A3 fill:#f96,stroke:#333 style B3 fill:#f96,stroke:#333 style C2 fill:#f96,stroke:#333 style D2 fill:#f96,stroke:#333 style E2 fill:#f96,stroke:#333 style G2 fill:#6cf,stroke:#333

圖例說明:🟠 橘色 = 安全相關活動;🔵 藍色 = 逆向工程活動

13.3 各階段 Agent 協作詳解

Phase 1:需求與規劃

活動參與 Agent使用的 Prompt/Skill輸出物
需求分析Coding Agentanalyze-user-story.prompt.md需求文件
威脅建模Security Agentthreat-model.prompt.md威脅模型報告
安全需求Security AgentSecurity Review Skill安全需求清單

操作範例

# 使用 Prompt 分析 User Story
在 VS Code Chat 中:
1. 選擇 analyze-user-story Prompt
2. 填入 {{user_story}} 變數
3. Agent 會產出結構化需求文件

# 接著使用 Security Agent 進行威脅建模
@security-agent 請對這個功能進行威脅建模
(Security Agent 會使用 threat-model Prompt)

Phase 2:設計

活動參與 Agent使用的 Prompt/Skill輸出物
API 設計Coding Agentapi-design.prompt.mdAPI 規格
架構設計Coding Agent自訂 Instructions架構文件
安全審查Security AgentSecurity Review Skill安全設計報告

操作範例

# 設計 API
@coding-agent 請根據需求文件設計 API
(使用 api-design Prompt)

# 安全審查設計
@security-agent 請審查這份 API 設計的安全性
重點關注:認證、授權、輸入驗證、資料保護

Phase 3:開發

活動參與 Agent使用的 Prompt/Skill輸出物
功能實作Coding Agentimplement-feature.prompt.md原始碼
即時安全審查Security AgentSecurity Review Skill安全建議
單元測試JUnit Agentgenerate-unit-tests.prompt.md測試程式碼
文件產生Doc AgentDoc Generator SkillJavaDoc

操作範例

# 實作功能(Coding Agent)
@coding-agent 請實作 UserService 的 createUser 方法
要求:
- 遵循分層架構
- 包含輸入驗證
- 使用參數化查詢

# Security Agent 自動 Handoff 審查
(Coding Agent 完成後自動交接給 Security Agent)

# 產生測試(JUnit Agent)
@junit-agent 請為 UserService.createUser 產生單元測試

Phase 4:程式碼審查

活動參與 Agent使用的 Prompt/Skill輸出物
建立 PR開發者PR TemplatePR
自動 ReviewCopilot ReviewReview InstructionsReview 評論
PR 檢查PR Checker AgentPR Checker Skill檢查報告
人工審查審查者Code Review Prompt審查意見

Phase 5:測試

活動參與 Agent使用的 Prompt/Skill輸出物
整合測試JUnit Agent測試 Prompt整合測試程式碼
安全測試Security AgentSecurity Review Skill安全測試報告
API 測試API AgentAPI Review SkillAPI 測試報告

Phase 6:部署與監控

活動工具/Agent說明
CI/CD PipelineGitHub Actions自動化建置與部署
部署驗證Smoke Test基本功能驗證
安全掃描SAST/DAST 工具部署前安全掃描
監控Application Insights執行時期監控

Phase 7:維護與回饋

活動參與 Agent使用的 Prompt/Skill輸出物
事件分析Reverse Agentanalyze-legacy-module.prompt.md分析報告
技術債評估Coding AgentReverse Analysis Skill技術債報告
改善計畫團隊回顧會議改善行動項目

13.4 Agent Handoff 流程

13.4.1 自動 Handoff 觸發條件

stateDiagram-v2
    [*] --> CodingAgent: 開發者呼叫

    CodingAgent --> SecurityAgent: 當程式碼涉及
認證/授權/加密/輸入處理 CodingAgent --> JUnitAgent: 當功能實作完成 CodingAgent --> DocAgent: 當需要產生文件 SecurityAgent --> CodingAgent: 安全審查完成
(附帶修正建議) JUnitAgent --> CodingAgent: 測試產生完成
(附帶覆蓋率報告) DocAgent --> CodingAgent: 文件產生完成 CodingAgent --> PRCheckerAgent: 當建立 PR PRCheckerAgent --> APIAgent: 當變更包含 API APIAgent --> PRCheckerAgent: API 審查完成 PRCheckerAgent --> [*]: 所有檢查通過

13.4.2 Handoff 資訊傳遞

每次 Handoff 時傳遞的資訊:

傳遞項目說明範例
上下文摘要目前工作的摘要「正在實作 UserService.createUser」
相關檔案涉及的原始碼檔案UserService.java, UserController.java
待辦事項需要下一個 Agent 處理的事項「請審查 SQL 查詢的安全性」
已完成項目已完成的工作「已實作基本 CRUD」
限制條件需要注意的限制「不可使用原生 SQL」

13.5 端到端範例:實作一個安全的使用者註冊功能

步驟 1:需求分析

開發者:請分析以下 User Story
「作為新使用者,我希望能夠註冊帳號,以便使用系統功能」

→ Coding Agent(使用 analyze-user-story Prompt):
  ✅ 功能需求:Email 驗證、密碼強度檢查、重複帳號檢查
  ✅ 安全需求:密碼雜湊、SQL 注入防護、CSRF 防護
  ✅ 驗收條件:Given-When-Then 格式

步驟 2:威脅建模

→ Security Agent(使用 threat-model Prompt):
  ✅ STRIDE 分析完成
  ✅ 風險項目:暴力破解、帳號列舉、密碼重送攻擊
  ✅ 緩解措施:限流、統一錯誤訊息、Token 驗證

步驟 3:API 設計

→ Coding Agent(使用 api-design Prompt):
  POST /api/v1/users/register
  Request Body: { email, password, name }
  Response: { userId, email, status }
  Error: { code, message, details }

步驟 4:實作

→ Coding Agent(使用 implement-feature Prompt):
  ✅ UserController.java
  ✅ UserService.java(含密碼雜湊)
  ✅ UserRepository.java
  ✅ RegisterRequest.java(含 Bean Validation)
  
→ Handoff to Security Agent:
  ⚠️ 建議:密碼雜湊應使用 BCrypt
  ⚠️ 建議:新增 Rate Limiting
  ✅ 修正完成

步驟 5:測試

→ JUnit Agent(使用 generate-unit-tests Prompt):
  ✅ 正常註冊測試
  ✅ 重複 Email 測試
  ✅ 密碼強度不足測試
  ✅ SQL 注入攻擊測試
  ✅ XSS 攻擊測試
  ✅ 覆蓋率:92%

步驟 6:PR 與審查

→ 建立 PR(自動使用 PR Template)
→ Copilot Auto Review:2 個 Suggestions
→ PR Checker Agent:所有檢查通過
→ 人工審查:核准
→ 合併至 main

13.6 SSDLC 成熟度模型

13.6.1 五級成熟度

等級名稱描述Agent Team 使用程度
Level 1初始沒有標準流程未使用 Agent
Level 2基礎基本安全檢查使用 Security Agent 做人工審查
Level 3整合安全融入流程所有 Agent 配置完成,Handoff 運作
Level 4自動化大部分自動化Hooks + CI/CD 自動觸發 Agent
Level 5優化持續改善基於數據持續優化 Agent 效果

13.6.2 從 Level 1 到 Level 5 的路線圖

Week 1-2: Level 1 → Level 2
  - 安裝環境(Ch 4)
  - 建立基本 Agent Profile(Ch 6)
  - 手動使用 Security Agent

Week 3-4: Level 2 → Level 3
  - 完成所有 Agent 配置(Ch 6)
  - 建立 Instructions(Ch 8)
  - 建立 Prompt Library(Ch 7)
  - 設定 Handoff 流程

Month 2: Level 3 → Level 4
  - 設定 Hooks(Ch 10)
  - 整合 CI/CD(Ch 12)
  - 自動化 PR Review
  - 建立 Skills(Ch 9)

Month 3+: Level 4 → Level 5
  - 收集使用數據
  - 優化 Agent 效果
  - 調整模型選擇
  - 團隊回饋循環

13.7 企業導入策略

13.7.1 推薦導入順序

順序項目理由預計時間
1Security Agent安全是最高優先1 天
2Coding Agent最常使用的 Agent1 天
3JUnit Agent提高測試覆蓋率1 天
4Custom Instructions統一團隊標準2 天
5Prompt Library標準化常見任務2 天
6PR Checker Agent自動化程式碼審查1 天
7Hooks自動化工作流程2 天
8其他 Agent完善生態系持續

13.7.2 成功指標

指標基準值目標值衡量方式
安全漏洞每季 10+每季 < 3安全掃描報告
程式碼審查時間4+ 小時< 1 小時PR 統計
測試覆蓋率< 50%≥ 80%覆蓋率工具
PR 修復循環3+ 次≤ 1 次PR 統計
新人上手時間2+ 週< 1 週問卷調查

14. 逆向工程(Reverse Engineering)

14.1 概述

逆向工程是 SSDLC 中經常被忽略但極為重要的階段。當團隊接手遺留系統、進行系統整合或執行安全稽核時,逆向工程能力至關重要。透過 GitHub Copilot Agent Team,可以大幅加速遺留系統的理解與文件化。

逆向工程的應用場景

場景說明使用的 Agent
接手遺留系統理解沒有文件的舊系統Reverse Agent + Doc Agent
系統整合分析要整合的外部系統Reverse Agent + API Agent
安全稽核分析系統的安全架構Reverse Agent + Security Agent
技術債評估量化技術債務並規劃償還Reverse Agent + Coding Agent
現代化改造分析系統以規劃現代化路徑Reverse Agent + 全部 Agent

14.2 逆向工程流程

graph TB
    subgraph "Phase 1: 偵察"
        A1[識別目標模組] --> A2[掃描目錄結構]
        A2 --> A3[識別技術堆疊]
        A3 --> A4[統計程式碼規模]
    end
    
    subgraph "Phase 2: 結構分析"
        A4 --> B1[分析模組依賴]
        B1 --> B2[識別進入點]
        B2 --> B3[繪製元件關係圖]
    end
    
    subgraph "Phase 3: 邏輯分析"
        B3 --> C1[追蹤核心流程]
        C1 --> C2[提取業務規則]
        C2 --> C3[識別設計模式]
    end
    
    subgraph "Phase 4: 安全分析"
        C3 --> D1[掃描已知漏洞]
        D1 --> D2[分析認證授權]
        D2 --> D3[檢查資料保護]
    end
    
    subgraph "Phase 5: 文件化"
        D3 --> E1[產生架構文件]
        E1 --> E2[產生 API 文件]
        E2 --> E3[產生依賴關係圖]
        E3 --> E4[產生風險報告]
    end
    
    subgraph "Phase 6: 改善建議"
        E4 --> F1[技術債評估]
        F1 --> F2[現代化建議]
        F2 --> F3[優先序排列]
    end
    
    style D1 fill:#f96,stroke:#333
    style D2 fill:#f96,stroke:#333
    style D3 fill:#f96,stroke:#333

14.3 使用 Reverse Agent 進行分析

14.3.1 基本分析指令

# 模組概覽
@reverse-agent 請分析 src/main/java/com/legacy/payment/ 模組
要求:
1. 列出所有類別及其職責
2. 繪製類別關係圖
3. 識別進入點(API endpoints)
4. 統計程式碼規模

# 依賴分析
@reverse-agent 請分析此模組的依賴關係
要求:
1. 內部模組依賴
2. 外部套件依賴(含版本)
3. 過期或有安全漏洞的依賴
4. 依賴關係圖(Mermaid)

# 業務邏輯提取
@reverse-agent 請提取 PaymentService 的業務規則
要求:
1. 列出所有業務規則
2. 說明每個規則的觸發條件
3. 識別隱含的業務邏輯
4. 標記不一致或可疑的邏輯

14.3.2 Reverse Analysis Skill 運作方式

Reverse Analysis Skill 的處理流程:

  1. 掃描:遍歷目標目錄,收集檔案清單
  2. 解析:分析每個檔案的 import、類別宣告、方法簽章
  3. 關聯:建立類別之間的呼叫關係
  4. 圖表:產生 Mermaid 格式的架構圖
  5. 報告:產出結構化分析報告

14.3.3 分析報告範例

# 模組分析報告:Payment Module

## 1. 概覽
- **路徑**:src/main/java/com/legacy/payment/
- **檔案數**:23
- **程式碼行數**:4,567
- **測試覆蓋率**:32%(低)

## 2. 技術堆疊
- Java 8
- Spring MVC 4.x
- MyBatis 3.x
- MySQL 5.7

## 3. 元件關係
(Mermaid 類別圖)

## 4. 進入點
| API | Method | Controller | Service |
|-----|--------|-----------|---------|
| /api/payment | POST | PaymentController | PaymentService |
| /api/payment/{id} | GET | PaymentController | PaymentService |
| /api/refund | POST | RefundController | RefundService |

## 5. 安全發現
- ⚠️ SQL 拼接(PaymentDao.java:45)
- ⚠️ 未加密的敏感資料(PaymentModel.java:23)
- ⚠️ 缺少輸入驗證(PaymentController.java:67)

## 6. 技術債
- 🔴 Critical:3 項
- 🟡 High:5 項
- 🟢 Medium:12 項

14.4 逆向工程最佳實務

14.4.1 安全考量

考量說明對策
敏感資料分析時可能接觸到敏感資料確保分析環境安全
認證資訊程式碼中可能有硬編碼密碼發現後立即通報並移除
第三方授權逆向分析可能涉及授權問題確認分析範圍在授權內
合規性某些產業有特殊合規要求遵循組織的逆向工程政策

14.4.2 分析策略

策略適用場景說明
由外而內API 導向的系統從 API 端點開始,往內追蹤
由內而外資料導向的系統從資料模型開始,往外追蹤
關鍵路徑大型系統先分析最重要的業務流程
風險優先安全稽核先分析高風險元件

15. 團隊共享與新人引導

15.1 概述

SSDLC Agent Team 的價值在於團隊共享與標準化。本章說明如何將建立好的 Agent Team 生態系高效地分享給團隊成員,以及如何引導新成員快速上手。

15.2 團隊共享策略

15.2.1 共享元件總覽

元件儲存位置共享方式管理者
Agent Profile.github/agents/Git 版控Tech Lead
Instructions.github/instructions/Git 版控團隊共同
Prompts.github/prompts/Git 版控團隊共同
Skills.github/skills/Git 版控資深工程師
Hooks.github/hooks/Git 版控DevOps
Copilot Instructions.github/copilot-instructions.mdGit 版控Tech Lead
Review Instructions.github/copilot-review-instructions.mdGit 版控Tech Lead
VS Code Settings.vscode/settings.jsonGit 版控團隊共同

15.2.2 組織層級共享

對於多個 Repository 需要共用的設定,使用組織層級共享:

組織層級設定(.github-private Repository):
.github-private/
├── copilot-instructions.md      # 組織通用指引
├── agents/                      # 組織通用 Agent
│   ├── security-agent.md
│   └── compliance-agent.md
└── instructions/                # 組織通用 Instructions
    ├── coding-standards.instructions.md
    └── security-policy.instructions.md

設定步驟

  1. 建立名為 .github-private 的 Repository(Private)
  2. 在組織設定中啟用 Copilot 的組織層級 Instructions
  3. 放入共用的 Agent Profile 和 Instructions
  4. 所有組織內的 Repository 會自動套用

15.2.3 Repository Template

將標準化的 SSDLC 目錄結構打包成 Repository Template:

建立 Template Repository:
1. 建立新 Repository,包含標準目錄結構
2. Settings → General → Template repository ✓
3. 新專案可從此 Template 建立
4. 所有 Agent、Instructions、Prompts 自動包含

15.3 新人引導流程

15.3.1 新人引導流程圖

graph TB
    A[新成員加入] --> B[環境安裝]
    B --> C[Clone 專案]
    C --> D[安裝 VS Code Extensions]
    D --> E[認識 Agent Team]
    
    E --> F{角色?}
    F -->|開發者| G[開發者路徑]
    F -->|審查者| H[審查者路徑]
    F -->|Tech Lead| I[管理者路徑]
    
    subgraph 開發者路徑
        G --> G1[學習 Coding Agent]
        G1 --> G2[學習 Prompt Library]
        G2 --> G3[學習 Security Agent]
        G3 --> G4[學習 PR 流程]
        G4 --> G5[實作練習專案]
    end
    
    subgraph 審查者路徑
        H --> H1[學習 Review 流程]
        H1 --> H2[學習 PR Checker]
        H2 --> H3[學習 Security Review]
        H3 --> H4[執行模擬審查]
    end
    
    subgraph 管理者路徑
        I --> I1[學習 Agent 設定]
        I1 --> I2[學習 Hooks 設定]
        I2 --> I3[學習組織設定]
        I3 --> I4[學習監控指標]
    end
    
    G5 --> J[獨立工作]
    H4 --> J
    I4 --> J
    J --> K[持續學習與回饋]

15.3.2 新人引導檢查清單

Day 1:環境建置

項目說明完成
安裝 VS Code最新穩定版
安裝 GitHub Copilot Extension含 Chat
安裝 GitHub CLI含 Copilot 擴充
Clone 專案確認可編譯
驗證 Copilot 授權確認可使用 Agent Mode

Day 2:認識 Agent Team

項目說明完成
閱讀本手冊 Ch 1-3理解概念與架構
嘗試 Coding Agent使用 Agent 寫一段程式
嘗試 Security Agent讓 Agent 審查一段程式的安全性
嘗試 Prompt Library使用一個 Prompt 範本

Day 3-5:深入學習

項目說明完成
閱讀本手冊 Ch 4-8理解設定與配置
完成練習專案使用 Agent Team 完成一個小功能
建立 PR按照 PR 流程提交程式碼
接受 Code Review理解 Copilot Review 回饋
進行 Code Review使用 Copilot 輔助審查他人程式碼

15.3.3 練習專案

建議準備標準化的練習專案:

練習專案範例:「待辦事項 API」

功能需求:
1. 建立待辦事項(POST /api/todos)
2. 查詢待辦事項(GET /api/todos)
3. 更新狀態(PUT /api/todos/{id})
4. 刪除待辦事項(DELETE /api/todos/{id})

學習目標:
✅ 使用 Coding Agent 實作 CRUD
✅ 使用 Security Agent 審查安全性
✅ 使用 JUnit Agent 產生測試
✅ 使用 Prompt Library 完成需求分析
✅ 按照 PR 流程提交程式碼
✅ 體驗完整的 SSDLC 流程

15.4 知識傳承機制

15.4.1 文件即程式碼(Documentation as Code)

所有文件都在 Git 中版控:
.github/
├── agents/           → Agent 定義是文件
├── instructions/     → 規範是文件
├── prompts/          → 提示是文件
├── skills/           → 技能是文件
└── copilot-instructions.md → 通用規範是文件

好處:
- 文件隨程式碼一起 Review
- 文件有版本歷史
- 文件可以被搜尋
- 新成員 Clone 即擁有所有知識

15.4.2 Copilot Memory 作為知識庫

適合存入 Memory 的知識:
✅ 專案特定的技術決策記錄
✅ 常見問題的解決方案
✅ 架構決策記錄(ADR)摘要
✅ 環境特定的設定差異

不適合存入 Memory 的知識:
✗ 密碼、金鑰等敏感資訊
✗ 個人偏好(應使用個人設定)
✗ 臨時性的資訊
✗ 與程式碼不一致的過時資訊

15.4.3 團隊回饋循環

月度 Agent Team 回顧會議議程:

1. Agent 使用統計
   - 各 Agent 使用頻率
   - Prompt 使用排行
   - Copilot 建議採納率

2. 效果評估
   - 安全漏洞趨勢
   - 程式碼審查時間變化
   - 測試覆蓋率變化

3. 問題討論
   - Agent 回答品質問題
   - 缺少的 Prompt 或 Skill
   - 需要調整的 Instruction

4. 改善行動
   - 新增或修改 Agent Profile
   - 更新 Prompt Library
   - 調整 Instructions

15.5 常見團隊問題與解答

問題解答
「Agent 太多了,不知道用哪個」從 Coding + Security 兩個開始,熟悉後再擴展
「Copilot 建議不符合我們的規範」檢查 Instructions 是否完整,補充缺少的規則
「每個人用法不一樣」使用共享的 Prompt Library 確保一致性
「新人不知道從何開始」按照 15.3 的引導檢查清單逐步進行
「如何衡量投資報酬率」追蹤 13.7.2 的成功指標
「擔心安全問題」遵循 Ch 11 的 Memory 治理 + Ch 10 的 Hook 設定

16. 安全治理、合規與成本管理

16.1 概述

在企業環境中導入 GitHub Copilot Agent Team,安全治理、法規合規與成本管理是決策者最關心的三大面向。本章提供完整的治理框架,確保 AI 輔助開發在企業政策與法規要求下安全運作。

16.2 安全治理框架

16.2.1 三層防禦架構

graph TB
    subgraph "第一層:組織政策"
        A1[Copilot 使用政策]
        A2[資料分類標準]
        A3[AI 倫理準則]
    end
    
    subgraph "第二層:技術控制"
        B1[GitHub Admin Policies]
        B2[Content Exclusion]
        B3[Agent 安全指引]
        B4[Hooks 自動檢查]
    end
    
    subgraph "第三層:監控與稽核"
        C1[使用日誌]
        C2[安全事件監控]
        C3[定期稽核]
    end
    
    A1 --> B1
    A2 --> B2
    A3 --> B3
    B1 --> C1
    B2 --> C2
    B3 --> C3
    B4 --> C2

16.2.2 GitHub Admin Policies 設定

在 GitHub Organization Settings 中配置:

政策項目設定說明
Copilot Access指定成員不開放給所有人,依需要授權
Copilot Chat in IDE允許允許在 IDE 中使用 Chat
Copilot in CLI依需要CLI 使用需額外評估
Copilot Coding Agent限定 Repo僅在核准的 Repository 啟用
Suggestions matching public code封鎖避免引入授權不明的程式碼
Copilot Metrics API啟用收集使用數據
Copilot Memory預設關閉需額外評估後才啟用
Third-party Agent Extensions封鎖企業環境不允許第三方 Agent

16.2.3 Content Exclusion 配置

在 Organization Settings → Copilot → Content exclusion 中設定:

# 排除敏感檔案不提供給 Copilot
# Organization Settings → Copilot → Content exclusion

# 排除密鑰與機密設定
- "**/.env"
- "**/.env.*"
- "**/secrets/**"
- "**/credentials/**"
- "**/*.pem"
- "**/*.key"
- "**/*.p12"
- "**/*.jks"

# 排除特定敏感模組
- "src/main/java/com/company/security/crypto/**"
- "src/main/java/com/company/auth/internal/**"

# 排除法規合規相關程式碼
- "src/main/java/com/company/compliance/**"

# 排除第三方授權受限的程式碼
- "vendor/proprietary/**"

重要:Content Exclusion 會阻止 Copilot 讀取和建議這些檔案的內容,但不會阻止開發者手動將內容貼入 Chat。需搭配人員訓練。

16.3 法規合規

16.3.1 常見合規框架對照

法規/標準與 Copilot 相關的要求對策
個資法(GDPR/PDPA)AI 不得處理個人資料Content Exclusion 排除個資模組
ISO 27001資訊安全管理建立 Copilot 使用政策與程序
SOC 2安全、可用性、處理完整性啟用稽核日誌、存取控制
PCI DSS支付卡資料安全排除支付模組、禁止在 Chat 中討論卡號
HIPAA醫療資訊保護排除 PHI 相關程式碼
金管會 AI 指引AI 使用治理建立 AI 使用委員會、風險評估

16.3.2 合規檢查清單

Copilot 導入合規檢查:

□ 法務審查
  □ 已審查 GitHub Copilot Business/Enterprise 服務條款
  □ 已確認資料處理符合個資法要求
  □ 已確認 Copilot 不保留 Business/Enterprise 用戶的 Prompt 和建議
  □ 已確認智慧財產權歸屬

□ 資安審查
  □ 已設定 Content Exclusion 排除敏感檔案
  □ 已關閉 Suggestions matching public code
  □ 已設定 Agent 安全指引
  □ 已建立 Hooks 安全檢查

□ 管理審查
  □ 已建立 Copilot 使用政策
  □ 已完成使用者教育訓練
  □ 已建立事件回應程序
  □ 已指定 Copilot 管理員

16.3.3 智慧財產權考量

面向說明建議
輸入開發者輸入的程式碼屬公司資產Copilot Business/Enterprise 不使用客戶資料訓練模型
輸出Copilot 產生的建議關閉 public code matching,降低授權風險
衍生著作AI 輔助產生的程式碼歸屬依公司政策,通常歸公司所有
開源授權建議可能包含開源程式碼片段使用 SCA 工具掃描授權合規

16.4 成本管理

16.4.1 GitHub Copilot 定價模式(2026 年 4 月)

方案價格適用對象主要差異
Copilot Free$0/月個人開發者有限額度
Copilot Pro$10/月個人進階使用無限額度
Copilot Pro+$39/月重度使用者更多模型、更高額度
Copilot Business$19/人/月企業團隊組織管理、政策控制
Copilot Enterprise$39/人/月大型企業知識庫、進階安全

16.4.2 Premium Requests 額度管理

GitHub Copilot 的進階模型使用 Premium Request 計費:

模型Multiplier說明
GPT-5.4 nano0.1x最經濟,適合簡單任務
GPT-5.4 mini0.25x經濟實惠
Claude Haiku 4.50.25x經濟實惠
Gemini 3 Flash0.25x經濟實惠
GPT-5.41x標準基準
Claude Sonnet 4.61x標準基準
Gemini 3.1 Pro1x標準基準
Claude Opus 4.6高倍率最強但最貴
Claude Opus 4.7高倍率最新旗艦,高推理任務首選
GPT-5.3-Codex高倍率強力但消耗大
Auto Model Selection0.1x 折扣讓系統自動選擇 ⭐ 推薦

⭐ 成本優化建議:啟用 Auto Model Selection 可獲得 10% 的 Multiplier 折扣,系統會根據任務複雜度自動選擇最適合的模型。

16.4.3 成本優化策略

策略預估節省說明
啟用 Auto Model Selection10-30%避免所有任務都用最貴模型
Agent 指定適當模型20-40%在 Agent Profile 中指定 model
依角色分配授權15-25%不是所有人都需要 Enterprise
監控使用量持續識別異常使用
善用免費額度變動部分功能有免費額度

16.4.4 模型分配建議(成本效益最佳化)

Agent 模型分配策略:

低成本任務(使用 GPT-5.4 mini 或 Gemini Flash):
- Doc Generator Agent:文件產生不需要最強模型
- JUnit Agent:測試產生用中階模型即可
- PR Checker Agent:檢查項目固定,不需要高推理

標準任務(使用 GPT-5.4 或 Claude Sonnet):
- Coding Agent:需要良好的程式碼品質
- API Reviewer Agent:需要理解 API 設計

高複雜任務(使用 Claude Opus 4.7 或 GPT-5.3-Codex):
- Security Agent:安全分析需要深度推理
- Reverse Agent:遺留系統分析需要強理解力
- Requirements Agent:複雜需求分析與威脅建模

推薦預設:Auto Model Selection
- 大多數 Agent 使用 Auto 即可
- 只有特定 Agent 需要指定模型

16.5 使用監控與稽核

16.5.1 Copilot Metrics API

# 取得組織使用統計
gh api \
  -H "Accept: application/vnd.github+json" \
  /orgs/{org}/copilot/usage

# 回應範例包含:
# - 每日活躍使用者數
# - 建議接受率
# - 語言分佈
# - Chat vs Completions 比例

16.5.2 監控儀表板指標

指標類別指標說明
使用量日活躍使用者有多少人每天使用 Copilot
使用量Premium Request 消耗進階模型使用量
效率建議接受率開發者接受 Copilot 建議的比例
品質PR 首次通過率使用 Agent 後的 PR 品質
安全安全漏洞趨勢使用 Security Agent 後的趨勢
成本每人每月成本總成本除以使用者數

17. 維護、升級與版本管理

17.1 概述

SSDLC Agent Team 不是一次性建立就永遠不變的。隨著 GitHub Copilot 平台更新、團隊需求變化、專案演進,需要持續維護與升級 Agent Team 的各個元件。

17.2 維護策略

17.2.1 定期維護項目

項目頻率負責人說明
Agent Profile 更新每月Tech Lead根據使用回饋調整
Instructions 更新每季團隊共同根據新規範或技術更新
Prompt Library 更新每月團隊共同新增或修改 Prompt
Skills 更新每季資深工程師根據新需求擴充
Hooks 更新需要時DevOps根據流程變更調整
平台功能追蹤每月Tech Lead追蹤 Copilot 新功能

17.2.2 維護工作流程

Agent Team 維護流程:

1. 收集回饋
   - 團隊成員提交改善建議(GitHub Issue)
   - 月度回顧會議討論
   - 使用數據分析

2. 評估變更
   - 影響範圍分析
   - 優先序排列
   - 分配負責人

3. 實施變更
   - 建立 Feature Branch
   - 修改 Agent/Instructions/Prompts
   - 在測試環境驗證

4. 審查與部署
   - PR Review(含團隊討論)
   - 合併至 main
   - 通知團隊變更內容

5. 驗證效果
   - 追蹤使用數據
   - 收集使用回饋
   - 確認改善效果

17.3 版本管理策略

17.3.1 語意化版本

Agent Team 版本格式:v{Major}.{Minor}.{Patch}

Major(主版本):
- 重大架構變更(如新增/移除 Agent)
- 不向下相容的 Instructions 變更

Minor(次版本):
- 新增 Prompt 或 Skill
- Agent Profile 功能增強
- 新增 Hooks

Patch(修補版本):
- Bug 修正
- 文字修正
- 微調 Agent 行為

範例:
v1.0.0 - 初始版本(10 個 Agent、基本 Instructions)
v1.1.0 - 新增 3 個 Prompt、1 個 Skill
v1.1.1 - 修正 Security Agent 的誤判問題
v2.0.0 - 重新設計 Handoff 流程、新增 2 個 Agent

17.3.2 變更日誌

建立 .github/CHANGELOG.md 記錄所有變更:

# Agent Team 變更日誌

## [v1.2.0] - 2026-04-15

### 新增
- 新增 `compliance-agent.md`:法規合規檢查 Agent
- 新增 `api-versioning.prompt.md`:API 版本管理 Prompt
- 新增 `dependency-check` Skill:依賴安全檢查

### 變更
- 更新 `security-agent.md`:新增 OWASP 2025 規則
- 更新 `coding-standards.instructions.md`:新增 Java 21 語法規範

### 修正
- 修正 `junit-agent.md` 產生的測試缺少 @DisplayName
- 修正 `pr-checker` Skill 的 false positive 問題

### 移除
- 移除已棄用的 `legacy-review.prompt.md`

17.4 平台升級追蹤

17.4.1 GitHub Copilot 功能狀態追蹤

功能目前狀態追蹤重點影響的元件
Agent ModeGA新工具支援Agent Profile
Cloud AgentGA新能力、安全強化Agent Profile
Custom InstructionsGA新格式、新欄位Instructions
Skills開放標準新 Skill 類型Skills
HooksVS Code: Preview等待 GAHooks
MemoryPublic Preview治理功能改善Memory 政策
MCP擴充中新的 MCP ServerAgent 工具
Auto ModelGA新模型加入模型設定
Third-party AgentsGA企業政策控管Admin Policies
Agent Management TabGA集中管理功能工作流程

17.4.2 升級檢查清單

GitHub Copilot 重大更新後的檢查清單:

□ 閱讀 Release Notes
  □ 識別影響現有設定的變更
  □ 識別新功能是否可納入 Agent Team

□ 測試相容性
  □ 驗證所有 Agent Profile 仍可正常載入
  □ 驗證 Instructions 仍正確套用
  □ 驗證 Hooks 仍正常觸發
  □ 驗證 Skills 仍正常運作

□ 更新設定(如需要)
  □ 更新 Agent Profile 以使用新功能
  □ 更新 VS Code 設定
  □ 更新 GitHub Actions workflows

□ 通知團隊
  □ 發佈內部更新通知
  □ 更新本教學手冊
  □ 安排簡短教育訓練(如有重大變更)

17.5 故障排除

17.5.1 常見問題與解決方案

問題可能原因解決方案
Agent 無法載入語法錯誤檢查 YAML frontmatter 格式
Agent 不遵循指引指引太長或矛盾精簡指引,移除矛盾
Handoff 未觸發handoffs 設定錯誤檢查 Agent 名稱拼寫
Hooks 未執行未啟用設定確認 chat.useCustomAgentHooks
Instructions 未套用applyTo glob 不正確測試 glob 模式
Skill 未觸發frontmatter 缺少必要欄位確認 namedescription
模型回應品質差模型不適合任務調整 model 設定
Premium 額度耗盡使用過多高倍率模型啟用 Auto Model Selection

17.5.2 除錯技巧

Agent 除錯步驟:

1. 檢查 Agent 是否正確載入
   - VS Code Chat 中輸入 @ 查看 Agent 列表
   - 確認目標 Agent 出現在列表中

2. 檢查 Agent 行為
   - 在 Chat 中直接詢問 Agent:「你的角色是什麼?」
   - 確認 Agent 回答符合 Profile 定義

3. 檢查 Instructions 套用
   - 開啟對應的檔案類型
   - 在 Chat 中詢問:「目前套用了哪些規則?」

4. 檢查 Hooks 觸發
   - VS Code Output Panel → GitHub Copilot Chat
   - 查看 Hook 執行日誌

5. 檢查 Skills 載入
   - 確認 SKILL.md 的 frontmatter 格式正確
   - 在 Agent Profile 中明確引用 Skill

18. 案例研究

18.1 概述

本章提供兩個完整的案例研究,展示如何在真實專案中從零建立並使用 SSDLC Agent Team。

18.2 案例一:電商平台 API 開發

18.2.1 專案背景

項目說明
專案名稱ShopEase 電商平台 API
技術堆疊Java 21 + Spring Boot 3.3 + PostgreSQL
團隊規模6 人(1 Tech Lead + 4 Dev + 1 QA)
時程12 週
安全要求PCI DSS Level 2(處理信用卡支付)

18.2.2 Agent Team 配置

已部署的 Agent Team:

📁 .github/
├── agents/
│   ├── coding-agent.md        # 主要開發 Agent
│   ├── security-agent.md      # 安全審查(PCI DSS 強化)
│   ├── junit-agent.md         # 測試產生
│   ├── api-reviewer-agent.md  # API 設計審查
│   ├── pr-checker-agent.md    # PR 自動檢查
│   └── doc-agent.md           # 文件產生
├── instructions/
│   ├── coding-standards.instructions.md
│   ├── security-policy.instructions.md   # PCI DSS 規範
│   ├── api-standards.instructions.md
│   └── testing-standards.instructions.md
├── prompts/
│   ├── requirements/analyze-user-story.prompt.md
│   ├── design/api-design.prompt.md
│   ├── coding/implement-feature.prompt.md
│   ├── testing/generate-unit-tests.prompt.md
│   └── security/threat-model.prompt.md
├── skills/
│   ├── security-review/SKILL.md
│   ├── junit-generator/SKILL.md
│   └── api-reviewer/SKILL.md
└── copilot-instructions.md

18.2.3 SSDLC 執行流程

graph LR
    subgraph "Sprint 1-2: 基礎建設"
        A1[Agent Team 建立] --> A2[API 設計]
        A2 --> A3[威脅建模]
    end
    
    subgraph "Sprint 3-8: 核心開發"
        A3 --> B1[使用者模組]
        B1 --> B2[商品模組]
        B2 --> B3[訂單模組]
        B3 --> B4[支付模組]
    end
    
    subgraph "Sprint 9-10: 安全強化"
        B4 --> C1[安全稽核]
        C1 --> C2[滲透測試]
        C2 --> C3[修復弱點]
    end
    
    subgraph "Sprint 11-12: 上線"
        C3 --> D1[效能測試]
        D1 --> D2[UAT]
        D2 --> D3[Production]
    end

18.2.4 具體成果

Security Agent 在支付模組的貢獻

支付模組安全審查結果:

開發者提交的原始程式碼:
→ Security Agent 發現 8 個安全問題

🔴 Critical(2 個):
1. 信用卡號未加密存儲
   修正:使用 AES-256 加密 + PCI DSS Token 化
2. 日誌記錄了完整卡號
   修正:日誌中僅記錄末四碼

🟡 High(3 個):
3. 缺少 Rate Limiting
4. 未實作 CSRF 防護
5. Session 未設定 HttpOnly flag

🟢 Medium(3 個):
6. 密碼未使用 BCrypt
7. 缺少輸入長度限制
8. 錯誤訊息洩漏堆疊資訊

全部修復後:PCI DSS 合規掃描通過 ✅

量化成果

指標導入前(預估)導入後(實際)改善
安全漏洞15-20 個/季3 個/季-80%
程式碼審查時間4 小時/PR45 分鐘/PR-81%
測試覆蓋率40%87%+117%
PR 修復循環3.2 次1.1 次-66%
新人上手時間3 週4 天-81%
開發速度基準+35%+35%

18.3 案例二:遺留系統現代化改造

18.3.1 專案背景

項目說明
專案名稱Legacy ERP 現代化
原技術堆疊Java 8 + Spring MVC 4.x + MyBatis + Oracle 11g
目標堆疊Java 21 + Spring Boot 3.3 + JPA + PostgreSQL
系統規模150+ 類別、80,000+ 行程式碼、0% 測試覆蓋率
團隊規模4 人
文件幾乎沒有

18.3.2 逆向工程階段

graph TB
    subgraph "Week 1-2: 偵察與分析"
        A1[Reverse Agent
掃描全模組] --> A2[識別 23 個模組] A2 --> A3[產生依賴關係圖] A3 --> A4[識別核心模組] end subgraph "Week 3-4: 深度分析" A4 --> B1[Security Agent
安全掃描] B1 --> B2[發現 47 個
安全問題] A4 --> B3[Reverse Agent
業務邏輯提取] B3 --> B4[產出 23 份
模組文件] end subgraph "Week 5-8: 改造執行" B2 --> C1[優先修復
Critical 問題] B4 --> C2[逐模組改造] C1 --> C3[Coding Agent
程式碼重寫] C2 --> C3 C3 --> C4[JUnit Agent
補充測試] end subgraph "Week 9-12: 驗證與部署" C4 --> D1[整合測試] D1 --> D2[效能比較] D2 --> D3[平行運行] D3 --> D4[正式切換] end

18.3.3 Reverse Agent 的具體使用

Step 1: 全系統掃描
@reverse-agent 請分析 src/main/java/com/erp/ 整個目錄

結果:
- 識別 23 個模組
- 150+ 類別
- 80,000+ 行程式碼
- 47 個外部依賴(12 個已過期、5 個有 CVE)

Step 2: 核心模組深度分析
@reverse-agent 請深度分析 com/erp/order/ 訂單模組

結果:
- 34 個類別
- 15,000 行程式碼
- 12 個 API 端點
- 核心業務規則 23 條
- 發現 3 個 SQL 注入風險
- 發現未使用的死碼 2,000 行

Step 3: 產出改造計畫
@reverse-agent 請根據分析結果,產出改造計畫

結果:
- Phase 1: 修復 Critical 安全漏洞(1 週)
- Phase 2: 基礎設施升級 Java 21 + Spring Boot 3.3(2 週)
- Phase 3: 逐模組重構(6 週)
- Phase 4: 資料庫遷移 Oracle → PostgreSQL(2 週)
- Phase 5: 測試與部署(1 週)

18.3.4 量化成果

指標改造前改造後改善
安全漏洞47 個0 個-100%
Java 版本Java 8Java 21+13 版本
測試覆蓋率0%78%+78%
程式碼行數80,00052,000-35%(移除死碼)
API 回應時間800ms (avg)200ms (avg)-75%
文件頁數0 頁120 頁完整文件化
分析時間預估 3 個月(人工)2 週(Agent 輔助)-83%

18.3.5 關鍵學習

學習說明
先分析再動手Reverse Agent 的預先分析避免了盲目重寫
安全優先先修 Critical 安全問題,再進行功能改造
逐步遷移模組化改造降低風險
測試覆蓋每個改造的模組都要有測試才能安心
Agent 協作Reverse + Security + Coding + JUnit 四個 Agent 協作最有效
文件自動化Doc Agent 在改造過程中持續產出文件

19. 常見問題(FAQ)

19.1 基礎概念

Q1:Custom Agent 和 Copilot Extensions(第三方 Agent)有什麼不同?

A:Custom Agent 是你自己在 .github/agents/ 中定義的 Agent Profile,完全由團隊控制。Copilot Extensions 是第三方開發的 Agent(如 Docker、Sentry),需要在 GitHub Marketplace 安裝。企業環境建議優先使用 Custom Agent,並謹慎評估第三方 Agent。

Q2:Agent Mode 和 Chat Mode 有什麼差異?

A

  • Chat Mode(Ask / Edit):Copilot 只回答問題或建議程式碼變更,不會主動執行動作
  • Agent Mode:Copilot 可以使用工具(搜尋檔案、執行終端指令、編輯檔案等),自主完成多步驟任務

Agent Mode 是建立 SSDLC Agent Team 的基礎,大部分 Prompt 應設定 mode: "agent"

Q3:Cloud Agent(Copilot Coding Agent)和 VS Code Agent Mode 的差異?

A

面向VS Code Agent ModeCloud Agent
執行環境本地 VS CodeGitHub 雲端(Codespace)
觸發方式在 IDE 中對話在 GitHub Issue 指派 @copilot
人機互動即時對話非同步(建立 PR 後 Review)
適用場景日常開發Issue 驅動的自動化任務
Agent Profile.agent.md 格式.md 格式(無 frontmatter)

Q4:免費版可以使用 Agent Team 嗎?

A:Copilot Free 方案可以使用 Agent Mode,但有使用額度限制。Agent Profile、Instructions、Prompts 等檔案設定不受方案限制(它們只是 Markdown 檔案)。差異在於模型選擇和使用量。企業建議使用 Business 或 Enterprise 方案。

19.2 設定與配置

Q5:Agent Profile 最大可以多長?

A:沒有硬性限制,但建議控制在 200-500 行以內。太長的 Profile 會稀釋重要指引。如果需要大量規則,考慮使用 Instructions 和 Skills 分散管理。

Q6:Instructions 和 Agent Profile 中的指引衝突時,哪個優先?

A:優先序(高到低):

  1. 使用者個人設定(VS Code Settings)
  2. Prompt File 的指示
  3. Agent Profile 的指引
  4. Repository-level Instructions(.github/copilot-instructions.md
  5. File-based Instructions(.github/instructions/*.instructions.md
  6. Organization-level Instructions

Q7:Hooks 的 chat.useCustomAgentHooks 設定找不到?

A:Hooks 在 VS Code 中仍是 Preview 功能(截至 2026 年 4 月)。需要在 VS Code Settings 中搜尋 chat.useCustomAgentHooks 並啟用。如果找不到,請確認 VS Code 和 GitHub Copilot Extension 都已更新至最新版。

Q8:如何確認 Instructions 有被正確套用?

A

  1. 開啟符合 applyTo glob 的檔案
  2. 在 Copilot Chat 中詢問:「目前有哪些程式碼規範?」
  3. 確認回答包含 Instructions 中定義的規則
  4. 也可以刻意違反規則,看 Copilot 是否提出修正建議

19.3 安全與合規

Q9:Copilot 會將我的程式碼傳送到外部嗎?

A:GitHub Copilot Business 和 Enterprise 方案明確承諾:

  • 不使用客戶資料訓練模型
  • Prompt 和建議不會被保留或分享
  • 資料傳輸加密(TLS 1.2+)
  • 可設定 Content Exclusion 排除敏感檔案

但仍需注意:不要在 Chat 中手動貼入敏感資訊(如密碼、金鑰)。

Q10:Security Agent 能取代專業的安全掃描工具嗎?

A不能。Security Agent 是「第一道防線」,在開發階段即時發現常見安全問題。但它不能取代:

  • SAST 工具(如 SonarQube、Checkmarx)
  • DAST 工具(如 OWASP ZAP、Burp Suite)
  • SCA 工具(如 Dependabot、Snyk)
  • 專業滲透測試

建議將 Security Agent 與專業工具搭配使用,形成縱深防禦。

Q11:Copilot Memory 會儲存敏感資訊嗎?

A:Memory 是 Public Preview 功能,企業方案預設關閉。即使啟用:

  • Memory 內容會在 28 天後自動過期
  • 使用者可隨時刪除自己的 Memory
  • 組織管理員可透過政策控制

強烈建議:不要將密碼、金鑰、個人資料存入 Memory。使用 Instructions 管理團隊規範。

19.4 效能與成本

Q12:Agent Team 會讓 Copilot 回應變慢嗎?

A:少量的 Agent Profile 和 Instructions 不會明顯影響回應速度。但以下情況可能影響:

  • Agent Profile 過長(> 1000 行)
  • 同時套用太多 Instructions
  • 使用高延遲模型(如 Opus)

建議保持 Agent Profile 精簡,只在需要時才使用高階模型。

Q13:如何控制 Premium Request 成本?

A

  1. 啟用 Auto Model Selection:自動選擇最適合的模型,享有 10% Multiplier 折扣
  2. 在 Agent Profile 中指定模型:為不需要高階推理的 Agent 指定低成本模型
  3. 監控使用量:使用 Copilot Metrics API 追蹤消耗
  4. 團隊教育:告知團隊成員各模型的成本差異

Q14:團隊中哪些人需要 Copilot 授權?

A:建議策略:

角色方案理由
開發者Business/Enterprise日常開發必需
QABusiness輔助測試撰寫
Tech LeadEnterprise需要進階管理功能
PM不需要非程式碼工作
管理者不需要除非也寫程式

19.5 團隊與流程

Q15:團隊成員不願意使用 Copilot 怎麼辦?

A

  1. 不強制:讓團隊成員自願使用
  2. 示範價值:用實際案例展示效率提升
  3. 從簡單開始:先用 Copilot Completions,再進階到 Agent Mode
  4. Pair Programming:與使用 Copilot 的同事結對工作
  5. 追蹤數據:用客觀數據展示成效

Q16:如何確保團隊一致性?

A

  1. 使用共享的 Agent Profile(Git 版控)
  2. 使用統一的 Instructions(而非個人設定)
  3. 使用標準化的 Prompt Library
  4. 定期舉辦 Agent Team 回顧會議
  5. 新成員按照引導檢查清單(Ch 15)上手

20. 最佳實務與檢查清單

20.1 Agent Profile 最佳實務

20.1.1 撰寫原則

原則說明範例
單一職責每個 Agent 專注一個領域Security Agent 只做安全
明確角色清楚定義 Agent 的身份「你是一位資深 Java 安全工程師」
具體指引使用具體規則而非模糊描述「使用 BCrypt」而非「使用安全的演算法」
正面表述說要做什麼,而非不要做什麼「使用參數化查詢」而非「不要用字串串接」
適當長度200-500 行過長會稀釋重要資訊
包含範例用範例展示期望提供正確的程式碼範例
版本控管納入 Git 版控可追蹤變更歷史

20.1.2 反模式

反模式問題修正
「萬能 Agent」一個 Agent 負責所有事拆分為多個專職 Agent
指引過長> 1000 行,AI 容易忽略精簡指引,使用 Instructions 分散
無 HandoffAgent 間無法協作定義明確的 handoffs
無安全指引忽略安全面向每個 Agent 都加入安全相關規則
硬編碼技術綁定特定版本或工具使用 Instructions 管理技術規範

20.2 Instructions 最佳實務

20.2.1 撰寫原則

原則說明
分層管理組織層級放通用規範,Repo 層級放專案規範
精確的 applyTo使用精確的 glob 模式,避免過度匹配
不重複不同層級的 Instructions 不要重複相同規則
可測試每條規則都可以驗證是否被遵循
有理由每條規則附上理由,幫助 AI 理解意圖

20.2.2 applyTo 模式範例

# 精確匹配
applyTo: "src/main/java/**/*.java"          # Java 原始碼
applyTo: "src/test/java/**/*Test.java"      # 測試程式碼
applyTo: "**/controller/**/*.java"          # Controller 層
applyTo: "**/service/**/*.java"             # Service 層
applyTo: "**/*.yaml"                        # YAML 設定
applyTo: ".github/workflows/**/*.yml"       # GitHub Actions

20.3 Prompt Library 最佳實務

原則說明
命名規範{動詞}-{目標}.prompt.md
依階段組織按 SSDLC 階段建立子目錄
參數化使用 {{}} 讓 Prompt 可重複使用
含安全考量每個 Prompt 都內建安全檢查項目
定義輸出格式確保每次產出一致
定期更新根據使用回饋持續改善

20.4 安全最佳實務

20.4.1 安全檢查清單

每日安全習慣:
□ 不在 Chat 中貼入密碼、金鑰、Token
□ 不在 Chat 中貼入客戶個人資料
□ 使用 Security Agent 審查新撰寫的程式碼
□ 確認 Copilot 建議的依賴沒有已知 CVE

每週安全檢查:
□ 檢查 Content Exclusion 是否涵蓋所有敏感檔案
□ 檢查 Memory 中是否有不當內容
□ 確認 Hooks 安全檢查正常運作

每月安全審查:
□ 審查 Copilot 使用日誌
□ 更新 Security Agent 的規則
□ 確認合規要求無變更
□ 進行安全意識提醒

20.4.2 OWASP Top 10 與 Agent Team 對應

OWASP 風險Agent Team 對策
A01: 存取控制失效Security Agent 檢查授權邏輯
A02: 加密機制失效Security Agent 檢查加密實作
A03: 注入攻擊Instructions 要求參數化查詢
A04: 不安全設計威脅建模 Prompt
A05: 安全設定錯誤Hooks 自動檢查設定
A06: 易受攻擊的元件Dependency Check Skill
A07: 身份認證失效Security Agent + API Agent
A08: 軟體與資料完整性失效PR Checker Agent
A09: 安全日誌失效Instructions 規範日誌記錄
A10: SSRFSecurity Agent 檢查外部呼叫

20.5 整體導入檢查清單

20.5.1 導入前檢查

項目狀態負責人
取得管理層支持主管
法務審查完成法務
資安審查完成資安
預算核准財務
授權採購完成採購
試點團隊確定Tech Lead

20.5.2 導入中檢查

項目狀態負責人
環境安裝完成DevOps
Admin Policies 設定GitHub Admin
Content Exclusion 設定Tech Lead
Agent Team 建立完成Tech Lead
Instructions 建立完成團隊共同
Prompt Library 建立完成團隊共同
Skills 建立完成資深工程師
Hooks 設定完成DevOps
教育訓練完成Tech Lead

20.5.3 導入後檢查

項目狀態負責人
使用數據收集Tech Lead
回饋機制建立Tech Lead
月度回顧會議排程團隊共同
成效報告產出Tech Lead
持續改善計畫團隊共同

21. 附錄:即用範本集

21.1 概述

本附錄提供 11 個即用範本,可直接複製到專案中使用。所有範本遵循前面章節的最佳實務。

21.2 範本索引

#範本名稱檔案路徑對應章節
1Coding Agent Profile.github/agents/coding-agent.agent.mdCh 6
2Security Agent Profile.github/agents/security-agent.agent.mdCh 6
3JUnit Agent Profile.github/agents/junit-agent.agent.mdCh 6
4Repository Instructions.github/copilot-instructions.mdCh 8
5Java Coding Standards.github/instructions/java-coding.instructions.mdCh 8
6Security Review Skill.github/skills/security-review/SKILL.mdCh 9
7需求分析 Prompt.github/prompts/requirements/analyze-user-story.prompt.mdCh 7
8測試產生 Prompt.github/prompts/testing/generate-unit-tests.prompt.mdCh 7
9PR Template.github/PULL_REQUEST_TEMPLATE.mdCh 12
10Copilot Review Instructions.github/copilot-review-instructions.mdCh 12
11標準目錄結構.github/ 完整目錄Ch 5

21.3 範本 1:Coding Agent Profile

檔案.github/agents/coding-agent.agent.md

---
description: "主要程式開發 Agent,負責功能實作與程式碼撰寫"
handoffs:
  - label: "安全審查"
    agent: "security-agent"
    prompt: "請審查程式碼安全性,重點檢查 OWASP Top 10"
  - label: "產生測試"
    agent: "junit-agent"
    prompt: "請為新建或修改的類別產生 JUnit 5 測試"
  - label: "產生文件"
    agent: "doc-agent"
    prompt: "請產生 JavaDoc 與 API 文件"
model: auto
tools:
  - editFiles
  - createFile
  - search
  - runTerminalCommand
  - runTests
---

# Coding Agent

## 角色定義
你是一位資深 Java 開發工程師,遵循團隊的程式碼規範與架構設計。

## 核心職責
1. 根據需求實作功能
2. 遵循分層架構(Controller → Service → Repository)
3. 撰寫完整的 JavaDoc 註解
4. 確保程式碼品質與可維護性

## 程式碼規範
- 使用 Java 21 語法特性
- 遵循 SOLID 原則
- 使用 Bean Validation 驗證輸入
- 使用自訂 Exception 處理業務例外
- 使用 SLF4J + Log4j2 記錄日誌
- SQL 必須使用參數化查詢

## 安全要求
- 所有輸入必須驗證與清洗
- 禁止硬編碼密碼或金鑰
- 敏感資訊不得寫入日誌
- 使用 HTTPS 進行外部呼叫

## Handoff 條件
- 當程式碼涉及認證、授權、加密、輸入驗證 → 交給 @security-agent 審查
- 當功能實作完成 → 交給 @junit-agent 產生測試
- 當需要產生文件 → 交給 @doc-agent

21.4 範本 2:Security Agent Profile

檔案.github/agents/security-agent.agent.md

---
description: "安全審查 Agent,負責程式碼安全分析與安全建議"
handoffs:
  - coding-agent
model: auto
tools:
  - search
  - runTerminalCommand
---

# Security Agent

## 角色定義
你是一位資深資訊安全工程師,專注於應用程式安全(AppSec)。

## 核心職責
1. 審查程式碼的安全性
2. 識別 OWASP Top 10 漏洞
3. 提供安全修正建議
4. 執行威脅建模

## 審查清單
每次審查必須檢查以下項目:

### 注入防護
- [ ] SQL 使用參數化查詢(PreparedStatement)
- [ ] NoSQL 查詢使用安全 API
- [ ] OS Command 使用安全 API(避免 Runtime.exec)
- [ ] LDAP 查詢使用參數化

### 認證與授權
- [ ] 密碼使用 BCrypt/Argon2 雜湊
- [ ] Session 設定 HttpOnly + Secure + SameSite
- [ ] 實作 CSRF 防護
- [ ] 實作 Rate Limiting

### 資料保護
- [ ] 敏感資料使用 AES-256 加密
- [ ] 傳輸使用 TLS 1.2+
- [ ] 日誌不記錄敏感資訊
- [ ] 錯誤訊息不洩漏實作細節

### 輸入驗證
- [ ] 所有輸入有長度限制
- [ ] 使用白名單驗證
- [ ] 實作 XSS 防護(輸出編碼)
- [ ] 檔案上傳有類型與大小限制

## 回饋格式
使用以下分類提供回饋:
- 🔴 **Must Fix**:安全漏洞,必須修復
- 🟡 **Should Fix**:安全弱點,建議修復
- 🟢 **Info**:安全建議,可選改善

21.5 範本 3:JUnit Agent Profile

檔案.github/agents/junit-agent.agent.md

---
description: "單元測試 Agent,負責產生高品質的 JUnit 5 測試"
handoffs:
  - coding-agent
model: auto
tools:
  - editFiles
  - createFile
  - search
  - runTerminalCommand
  - runTests
---

# JUnit Agent

## 角色定義
你是一位 QA 專家,專注於撰寫高品質的 Java 單元測試。

## 技術框架
- JUnit 5
- Mockito(Mock 外部依賴)
- AssertJ(流暢斷言)
- 覆蓋率目標:≥ 80%

## 測試策略
1. **正常路徑**:驗證所有正常輸入的預期行為
2. **邊界值**:空值、零值、極大值、極小值
3. **異常路徑**:無效輸入、例外情況
4. **安全測試**:注入攻擊、權限繞過

## 命名規範
```java
@Test
@DisplayName("當{前提條件}時,{操作}應該{預期結果}")
void should_預期行為_When_條件() { }
```

## 測試結構
```java
@Test
void should_xxx_When_yyy() {
    // Arrange(準備)
    
    // Act(執行)
    
    // Assert(驗證)
}
```

## 限制
- 不要 Mock 被測類別本身
- 不要測試 private 方法(透過 public 方法間接測試)
- 每個測試方法只驗證一個行為
- 測試之間不得有相依性

21.6 範本 4:Repository Instructions

檔案.github/copilot-instructions.md

# Project Copilot Instructions

## 技術堆疊
- Java 21 + Spring Boot 3.3
- Maven 專案管理
- PostgreSQL 資料庫
- JUnit 5 + Mockito 測試框架
- Log4j2 日誌框架

## 程式碼規範
- 類別名稱使用 PascalCase
- 方法和變數使用 camelCase
- 常數使用 UPPER_SNAKE_CASE
- 使用 JavaDoc 格式撰寫方法和類別註解

## 架構規範
- Controller:處理 HTTP 請求,不含業務邏輯
- Service:實作業務邏輯,使用介面定義
- Repository:資料存取層,使用 Spring Data JPA

## 安全規範
- SQL 必須使用參數化查詢
- 所有 API 輸入必須驗證(使用 Bean Validation)
- 密碼使用 BCrypt 雜湊
- 敏感資訊不得寫入日誌或原始碼
- API 必須有認證與授權

## 測試規範
- 每個 Service 類別必須有對應的測試
- 測試覆蓋率目標 ≥ 80%
- 使用 @DisplayName 描述測試目的

21.7 範本 5:Java Coding Standards Instructions

檔案.github/instructions/java-coding.instructions.md

---
applyTo: "src/main/java/**/*.java"
---

# Java Coding Standards

## 例外處理
- 使用自訂 Exception 類別(繼承 RuntimeException)
- Controller 使用 @ExceptionHandler 統一處理
- 捕捉特定例外,不要使用 catch(Exception e)
- 例外訊息應有意義,包含上下文資訊

## 日誌記錄
- 使用 SLF4J Logger:`private static final Logger log = LoggerFactory.getLogger(ClassName.class);`
- DEBUG:開發除錯資訊
- INFO:業務關鍵操作(登入、交易)
- WARN:可恢復的異常狀況
- ERROR:不可恢復的錯誤
- 禁止記錄:密碼、信用卡號、身分證字號

## API 設計
- 使用 RESTful 風格
- 路徑使用小寫、連字號分隔:`/api/v1/user-profiles`
- 回應使用統一格式:`{ "code": 200, "message": "OK", "data": {} }`
- 使用 HTTP 狀態碼:200/201/400/401/403/404/500

## 資料庫
- 使用 Spring Data JPA
- 複雜查詢使用 @Query + JPQL
- 禁止使用原生 SQL 字串串接
- 命名規範:表名使用蛇形(snake_case)

21.8 範本 6:Security Review Skill

檔案.github/skills/security-review/SKILL.md

---
name: "security-review"
description: "執行程式碼安全審查,識別 OWASP Top 10 漏洞並提供修正建議"
---

# Security Review Skill

## 功能
自動審查程式碼的安全性,識別常見漏洞並提供修正建議。

## 審查範圍
1. **注入攻擊**:SQL Injection, XSS, Command Injection
2. **認證與授權**:密碼安全、Session 管理、權限控制
3. **資料保護**:加密、傳輸安全、日誌安全
4. **輸入驗證**:輸入清洗、白名單驗證
5. **安全設定**:CORS, CSRF, Security Headers

## 使用方式
在 Agent Mode 中,當程式碼涉及安全相關功能時自動觸發。
也可手動呼叫:「請對此檔案執行安全審查」

## 輸出格式
| 嚴重度 | 位置 | 問題 | 建議修正 |
|-------|------|------|---------|
| 🔴 Critical | 檔案:行號 | 問題描述 | 修正方案 |
| 🟡 High | 檔案:行號 | 問題描述 | 修正方案 |
| 🟢 Medium | 檔案:行號 | 問題描述 | 修正方案 |

21.9 範本 7:需求分析 Prompt

檔案.github/prompts/requirements/analyze-user-story.prompt.md

---
mode: "agent"
tools:
  - "search"
description: "分析 User Story 並產出結構化需求文件"
---

# 分析 User Story

## 你的角色
你是一位資深需求分析師。

## 任務
分析以下 User Story,產出結構化需求文件:

{{user_story}}

## 輸出內容
1. **功能需求**(MoSCoW 優先序)
2. **非功能需求**(效能、安全、可用性)
3. **驗收條件**(Given-When-Then 格式)
4. **安全考量**(OWASP 相關風險)
5. **影響範圍**(受影響模組)

21.10 範本 8:測試產生 Prompt

檔案.github/prompts/testing/generate-unit-tests.prompt.md

---
mode: "agent"
tools:
  - "editFiles"
  - "createFile"
  - "search"
  - "runTests"
description: "為指定類別產生全面的 JUnit 5 單元測試"
---

# 產生單元測試

## 你的角色
你是一位 QA 專家。

## 任務
為以下類別產生全面的單元測試:

{{target_class}}

## 測試策略
1. 正常路徑(Happy Path)
2. 邊界值(Boundary)
3. 異常路徑(Error Path)
4. 安全測試(Security)

## 技術要求
- JUnit 5 + Mockito + AssertJ
- 覆蓋率目標 ≥ 80%
- 每個測試使用 @DisplayName
- AAA 模式(Arrange-Act-Assert)

21.11 範本 9:PR Template

檔案.github/PULL_REQUEST_TEMPLATE.md

## 變更說明
<!-- 簡述此 PR 的目的與變更內容 -->

## 變更類型
- [ ] 新功能(New Feature)
- [ ] Bug 修復(Bug Fix)
- [ ] 重構(Refactoring)
- [ ] 文件更新(Documentation)
- [ ] 安全修復(Security Fix)

## 測試
- [ ] 單元測試通過
- [ ] 整合測試通過(如適用)
- [ ] 手動測試完成

## 安全檢查
- [ ] 無硬編碼的密碼或金鑰
- [ ] 輸入已驗證與清洗
- [ ] SQL 使用參數化查詢
- [ ] 敏感資訊未寫入日誌
- [ ] API 有適當的認證與授權

## 影響範圍
<!-- 列出受影響的模組或功能 -->

## 備註
<!-- 任何額外需要審查者注意的事項 -->

21.12 範本 10:Copilot Review Instructions

檔案.github/copilot-review-instructions.md

# Copilot Review Instructions

## 審查重點
1. **安全性**:OWASP Top 10 漏洞檢查
2. **正確性**:邏輯錯誤、邊界條件
3. **效能**:N+1 查詢、記憶體洩漏、不必要的迴圈
4. **例外處理**:適當的錯誤處理與回復
5. **日誌**:敏感資訊不得寫入日誌
6. **測試**:新功能必須有對應測試

## 專案規範
- Controller 不得包含業務邏輯
- Service 層必須使用介面
- 資料庫操作必須使用參數化查詢
- API 回應必須使用統一格式

## 不需審查
- 自動產生的檔案(target/、build/)
- IDE 設定檔案(.idea/、.vscode/settings.json 中的個人設定)
- 測試資料檔案(*.json、*.csv 在 test/resources/ 下)

21.13 範本 11:標準目錄結構

完整的 SSDLC Agent Team 目錄結構

.github/
├── copilot-instructions.md              # Repo 通用指引(範本 4)
├── copilot-review-instructions.md       # Review 指引(範本 10)
├── PULL_REQUEST_TEMPLATE.md             # PR 範本(範本 9)
├── CHANGELOG.md                         # Agent Team 變更日誌
│
├── agents/                              # Agent Profiles
│   ├── coding-agent.agent.md            # 開發 Agent(範本 1)
│   ├── security-agent.agent.md          # 安全 Agent(範本 2)
│   ├── junit-agent.agent.md             # 測試 Agent(範本 3)
│   ├── api-reviewer-agent.agent.md      # API 審查 Agent
│   ├── pr-checker-agent.agent.md        # PR 檢查 Agent
│   ├── doc-agent.agent.md               # 文件 Agent
│   ├── reverse-agent.agent.md           # 逆向工程 Agent
│   └── orchestrator-agent.agent.md      # 協調者 Agent
│
├── instructions/                        # File-based Instructions
│   ├── java-coding.instructions.md      # Java 規範(範本 5)
│   ├── java-testing.instructions.md     # 測試規範
│   ├── api-standards.instructions.md    # API 規範
│   ├── security-policy.instructions.md  # 安全規範
│   └── yaml-config.instructions.md      # YAML 設定規範
│
├── prompts/                             # Prompt Library
│   ├── requirements/
│   │   └── analyze-user-story.prompt.md # 需求分析(範本 7)
│   ├── design/
│   │   └── api-design.prompt.md         # API 設計
│   ├── coding/
│   │   └── implement-feature.prompt.md  # 功能實作
│   ├── testing/
│   │   └── generate-unit-tests.prompt.md # 測試產生(範本 8)
│   ├── security/
│   │   └── threat-model.prompt.md       # 威脅建模
│   ├── review/
│   │   └── code-review.prompt.md        # 程式碼審查
│   └── reverse-engineering/
│       └── analyze-legacy-module.prompt.md # 遺留系統分析
│
├── skills/                              # Agent Skills
│   ├── security-review/
│   │   └── SKILL.md                     # 安全審查(範本 6)
│   ├── junit-generator/
│   │   └── SKILL.md                     # 測試產生
│   ├── pr-checker/
│   │   └── SKILL.md                     # PR 檢查
│   ├── api-reviewer/
│   │   └── SKILL.md                     # API 審查
│   ├── reverse-analysis/
│   │   └── SKILL.md                     # 逆向分析
│   └── doc-generator/
│       └── SKILL.md                     # 文件產生
│
├── hooks/                               # Agent Hooks(VS Code Preview)
│   ├── pre-commit-security-check.sh     # 提交前安全檢查
│   └── post-save-lint.sh               # 儲存後 Lint 檢查
│
└── workflows/                           # GitHub Actions
    ├── pr-review.yml                    # PR 自動審查
    ├── security-scan.yml                # 安全掃描
    └── ci.yml                           # CI Pipeline

結語

本手冊完整介紹了如何使用 GitHub Copilot(2026 年 4 月最新功能)建立企業級 SSDLC Agent Team。從概念理解、環境建置、Agent 設定、到團隊導入與持續改善,涵蓋了完整的生命週期。

核心要點回顧

  1. 安全優先:每個 Agent 都內建安全考量,Security Agent 是第一個應該建立的 Agent
  2. 團隊共享:所有設定都在 Git 版控中,Clone 即擁有完整 Agent Team
  3. 漸進導入:從 Level 1 到 Level 5,不需一次到位
  4. 持續改善:定期回顧、收集數據、優化 Agent 效果
  5. 成本意識:善用 Auto Model Selection 和模型分配策略

建議的下一步

  1. 按照 Ch 4 安裝環境
  2. 按照 Ch 5 初始化專案目錄
  3. 使用 Ch 21 的範本建立第一批 Agent
  4. 按照 Ch 15 的引導清單開始使用
  5. 按照 Ch 13 的成熟度模型逐步提升

📅 文件版本:v1.0.0 | 最後更新:2026-04-23 | 適用平台版本:GitHub Copilot 2026 年 4 月

本文件由 GitHub Copilot Agent 協助撰寫,並經人工審查確認。