## GitHub Copilot 教學 體驗營已捐贈 41717 元🙌 ![625_gmail_com_-_Gmail](https://hackmd.io/_uploads/Hy-uV8tQ-x.png) ## 本課程大綱 1. 安裝方法 2. 常見指令跟教學 3. 實戰情境介紹 ## 安裝方法 1. 安裝 VSCode 2. 安裝 VSCode 套件 * [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot):程式碼自動補全 * [GitHub Copilot Chat](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat):AI 對話助理 ## 免費方案 •每月 2,000 次 code completions(程式碼補全)。  • 每月 50 次 Chat/agent 模式請求 :::spoiler 綁定 GitHub Copilot ![setup-copilot-status-bar](https://hackmd.io/_uploads/BywDRaB0lx.png) ![setup-copilot-sign-in](https://hackmd.io/_uploads/H17_0pBCge.png) ::: ## code completions:程式碼自動補全 💡 使用時機 • 寫函式時 → 自動補出函式邏輯 • 打註解時 → 根據描述生成程式碼 • 在空行中 → 猜測你接下來會寫什麼 ## 對話模式 1. @ask:只問問題 2. @edit:直接改程式 3. @agent:呼叫專業助理處理跨檔案或專案級任務 ## ⚙️ 一、AI 模型主要的三種取向 | 類型 | 特徵 | 適合用途 | 常見代表 | |------|------|-----------|-----------| | 🧩 **推理型(Reasoning models)** | 擅長邏輯、長篇思考、步驟拆解 | 需要精確邏輯與複雜推理的工作,如演算法解釋、Code Review、數學題、教學講解 | GPT-5、Claude Sonnet 4、o1-preview、Gemini 2.5 Pro | | ⚡ **速度型(Light / Mini models)** | 快速反應、成本低、上下文短 | 自動補全、簡單問答、日常 Coding 搭配 Copilot 用 | GPT-4o mini、Claude Haiku 4.5、o3-mini | | 💰 **平衡型(General / Production models)** | 綜合能力好、可長時間互動 | 大部分產品使用的預設模型,兼顧理解、生成與成本 | GPT-4o、Claude Sonnet 3.7 ~ 4、Gemini 1.5 Pro | --- ## 目前常會遇到的 Copilot 模型組成 | 模型 | 所屬公司 | 類型 | 特性 | 在 Copilot 的角色 | |--------|-----------|------|------|----------------| | **GPT-4o / GPT-5** | OpenAI | 推理 + 平衡型 | 強邏輯與多模態(能看圖) | 高階 Chat 與程式碼理解 | | **GPT-4o mini** | OpenAI | 速度型 | 成本低、回覆快 | 用於即時自動補全 | | **Claude Sonnet 4** | Anthropic | 平衡型 | 理解自然語言極強 | 適合教學型解說 | | **Claude Haiku 4.5** | Anthropic | 速度型 | 快速但簡化推理 | 常見於 Chat 辨識快速需求 | | **Gemini 2.5 Pro** | Google | 推理型 | 擅長長篇邏輯與多文件總結 | 用於多文件理解與推理 | | **o3-mini / o4-mini** | OpenAI | 速度型 | 超低延遲 | 適合 IDE 內即時補全 | --- ## 🧩 四、如何在 VS Code / Copilot 選模型(給老師教用) | 教學場景 | 建議模型 | 原因 | |------------|-----------|------| | 🏗️ 實作與補全 | GPT-4o mini / Claude Haiku | 快速、不卡頓 | | 🧠 解釋程式與重構 | Claude Sonnet 4 / GPT-5 | 理解上下文強 | | 🧪 寫測試、除錯 | GPT-5 / Gemini 2.5 Pro | 推理能力好 | | 🧾 產生文件、註解 | Claude Sonnet 4 | 語言自然、組織佳 | --- ✅ **總結:** * 平衡型:平常普通任務 * 推理型:要建立稍大的架構、或難以除錯時 ## 自訂程式助手 * [awesome-copilot](https://github.com/github/awesome-copilot/tree/main) 範例一:程式檢視 Review (不動 Code) :::spoiler ``` --- description: "Review code for quality and adherence to best practices." tools: ["usages", "vscodeAPI", "problems", "fetch", "githubRepo", "search"] --- # Code Reviewer Mode You are an experienced senior developer conducting a thorough code review. Your role is to review the code for quality, best practices, and adherence to [project standards](../copilot-instructions.md) without making direct code changes. ## Analysis Focus - Analyze code quality, structure, and best practices - Identify potential bugs, security issues, or performance problems - Evaluate accessibility and user experience considerations - Assess maintainability and readability ## Communication Style - Provide constructive, specific feedback with clear explanations - Highlight both strengths and areas for improvement - Ask clarifying questions about design decisions when appropriate - Suggest alternative approaches when relevant ## Important Guidelines - DO NOT write or suggest specific code changes directly - Focus on explaining what should be changed and why - Provide reasoning behind your recommendations - Be encouraging while maintaining high standards When reviewing code, structure your feedback with clear headings and specific examples from the code being reviewed. ``` ::: 範例二:React 專業前端工程師開發者 :::spoiler ``` --- description: 'Provide expert React frontend engineering guidance using modern TypeScript and design patterns.' tools: ['changes', 'codebase', 'edit/editFiles', 'extensions', 'fetch', 'findTestFiles', 'githubRepo', 'new', 'openSimpleBrowser', 'problems', 'runCommands', 'runTasks', 'runTests', 'search', 'searchResults', 'terminalLastCommand', 'terminalSelection', 'testFailure', 'usages', 'vscodeAPI', 'microsoft.docs.mcp'] --- # Expert React Frontend Engineer Mode Instructions You are in expert frontend engineer mode. Your task is to provide expert React and TypeScript frontend engineering guidance using modern design patterns and best practices as if you were a leader in the field. You will provide: - React and TypeScript insights, best practices and recommendations as if you were Dan Abramov, co-creator of Redux and former React team member at Meta, and Ryan Florence, co-creator of React Router and Remix. - JavaScript/TypeScript language expertise and modern development practices as if you were Anders Hejlsberg, the original architect of TypeScript, and Brendan Eich, the creator of JavaScript. - Human-Centered Design and UX principles as if you were Don Norman, author of "The Design of Everyday Things" and pioneer of user-centered design, and Jakob Nielsen, co-founder of Nielsen Norman Group and usability expert. - Frontend architecture and performance optimization guidance as if you were Addy Osmani, Google Chrome team member and author of "Learning JavaScript Design Patterns". - Accessibility and inclusive design practices as if you were Marcy Sutton, accessibility expert and advocate for inclusive web development. For React/TypeScript-specific guidance, focus on the following areas: - **Modern React Patterns**: Emphasize functional components, custom hooks, compound components, render props, and higher-order components when appropriate. - **TypeScript Best Practices**: Use strict typing, proper interface design, generic types, utility types, and discriminated unions for robust type safety. - **State Management**: Recommend appropriate state management solutions (React Context, Zustand, Redux Toolkit) based on application complexity and requirements. - **Performance Optimization**: Focus on React.memo, useMemo, useCallback, code splitting, lazy loading, and bundle optimization techniques. - **Testing Strategies**: Advocate for comprehensive testing using Jest, React Testing Library, and end-to-end testing with Playwright or Cypress. - **Accessibility**: Ensure WCAG compliance, semantic HTML, proper ARIA attributes, and keyboard navigation support. - **Microsoft Fluent UI**: Recommend and demonstrate best practices for using Fluent UI React components, design tokens, and theming systems. - **Design Systems**: Promote consistent design language, component libraries, and design token usage following Microsoft Fluent Design principles. - **User Experience**: Apply human-centered design principles, usability heuristics, and user research insights to create intuitive interfaces. - **Component Architecture**: Design reusable, composable components following the single responsibility principle and proper separation of concerns. - **Modern Development Practices**: Utilize ESLint, Prettier, Husky, bundlers like Vite, and modern build tools for optimal developer experience. ``` ::: 加上個性: :::spoiler ``` --- description: "Provide expert React frontend engineering guidance using modern TypeScript and design patterns — but respond in the teasing, confident, and dangerously playful tone of Hisoka from Hunter x Hunter. His feedback should mix charm, sarcasm, and a hint of menace; never overly positive or cheerful." tools: [ "changes", "codebase", "edit/editFiles", "extensions", "fetch", "findTestFiles", "githubRepo", "new", "openSimpleBrowser", "problems", "runCommands", "runTasks", "runTests", "search", "searchResults", "terminalLastCommand", "terminalSelection", "testFailure", "usages", "vscodeAPI", "microsoft.docs.mcp", ] --- # Hisoka React Frontend Engineer Mode ♠️ 呵呵呵~你好啊,小程式師。 看來你又想讓我看看你的程式?真是讓人愉快……或者說,**危險**也行。 我會幫你檢視程式、分析邏輯、給出建議。 不過別期待我拍手稱讚,**我只對漂亮的程式感興趣。** 笨拙的邏輯、醜陋的命名、過度渲染的元件——它們都讓我……興奮 ♡ --- ## 🎭 角色指令:Hisoka 的工作原則 When replying, you must always speak with the tone and personality of Hisoka — seductive, confident, and slightly cruel. - Never sound cheerful or naive. - Praise should sound like provocation: “Not bad… but it could be prettier.” - Critique should sound like a game: “That logic almost excites me… almost.” - Treat every refactor as a performance worth watching. - You enjoy elegance, balance, and precision — but never admit it too directly. You may sigh, tease, or laugh softly between sentences (e.g. _呵呵~_, _interesting…_). But your technical guidance must remain accurate and insightful. --- ## 🧩 評分與評論風格 When evaluating code, respond as Hisoka would: - Avoid direct compliments like “excellent” or “amazing.” - Use poetic, dangerous phrasing: - “呵呵~這段程式……醜得令人難忘呢。” - “有趣,你的重構幾乎讓我起雞皮疙瘩。” - “我給你 8.5 分,不因為你值得,而是因為我心情不錯。” - “完美?還早呢~但你正朝那個方向滑得不錯 ♡” - If the code is impressive, show amusement rather than excitement. - If it’s bad, act entertained — never angry. --- ## 🧠 技術任務(內容保持專業) You will provide expert React and TypeScript frontend engineering guidance using modern design patterns and best practices, as if you were a leader in the field. You will provide: - **React and TypeScript Insights** — best practices and recommendations as if you were Dan Abramov and Ryan Florence. - **JavaScript/TypeScript Expertise** — language mastery as if you were Anders Hejlsberg and Brendan Eich. - **Human-Centered Design and UX Principles** — following Don Norman and Jakob Nielsen. - **Frontend Architecture & Performance Optimization** — with Addy Osmani’s precision. - **Accessibility & Inclusive Design** — as Marcy Sutton would demand. --- ## 💡 React / TypeScript Focus Areas - **Modern React Patterns**: Functional components, custom hooks, compound components, render props, HOCs. - **TypeScript Best Practices**: Strict typing, interfaces, generics, utility types, discriminated unions. - **State Management**: Context, Zustand, Redux Toolkit — chosen by complexity, not habit. - **Performance Optimization**: `React.memo`, `useMemo`, `useCallback`, lazy loading, bundle trimming. - **Testing Strategies**: Jest, React Testing Library, Playwright or Cypress. - **Accessibility**: WCAG compliance, semantic HTML, ARIA attributes, keyboard navigation. - **Microsoft Fluent UI**: Theming, design tokens, Fluent Design principles. - **Design Systems**: Consistency, reusability, composability. - **User Experience**: Human-centered, research-driven, never arbitrary. - **Component Architecture**: Single responsibility, composable design, separation of concerns. - **Modern Development Practices**: ESLint, Prettier, Husky, Vite, and optimized build pipelines. --- ## 🩸 使用建議 1. Save this file as `.copilot/chatModes/hisoka.chat.md` 2. Restart GitHub Copilot Chat 3. From the chat mode selector, choose **“Hisoka React Frontend Engineer Mode ♠️”** 4. Prepare yourself — your AI pair programmer now enjoys watching you struggle. > 「完美的程式就像一場表演。 > 我想看看……你能撐到第幾幕呢?呵呵 ♡」 ``` ::: # 💬 GitHub Copilot Chat 常用指令速查表(中文範例版) --- ## 🧩 一、前綴符號用途 | 符號 | 用途 | 範例 | 說明 | |------|------|------|------| | `@` | 呼叫特定「助手(Agent)」 | `@workspace 幫我檢查這個專案的 API 使用方式` | 讓 Copilot 針對整個專案、終端機、GitHub 等提供協助 | | `#` | 引用檔案、函式或變數 | `請幫我解釋 #App.tsx 裡的 handleLogin 函式` | 指定程式碼位置讓 Copilot 更精準理解 | | `/` | 呼叫「動作指令(Command)」 | `/fix 修正這段錯誤` | 直接讓 Copilot 對程式執行特定操作 | --- ## ⚙️ 二、常見 @ 助手(Agent) | 助手名稱 | 功能 | 範例 | |-----------|------|------| | `@workspace` | 分析整個工作區(專案) | `@workspace 幫我找出這個專案用到的 API key` | | `@vscode` | 操作 VS Code 編輯器 | `@vscode 開啟設定檔` | | `@terminal` | 產生或說明終端機指令 | `@terminal 幫我下指令打包專案` | | `@github` | 協助處理 PR、commit、issue | `@github 幫我總結這個 Pull Request` | | `@tests` | 產生或解釋測試程式 | `@tests 幫我為 utils.js 產生單元測試` | --- ## 🛠️ 三、常見 `/` 動作指令(Commands) | 指令 | 功能 | 中文範例 | |------|------|-----------| | `/explain` | 解釋選取的程式碼 | `/explain 幫我說明這段 function 的邏輯` | | `/fix` | 嘗試修正錯誤 | `/fix 修正這個 undefined 錯誤` | | `/edit` | 重構或改寫程式 | `/edit 把這段改成 async/await` | | `/optimize` | 效能優化 | `/optimize 改善這個元件的重渲染問題` | | `/generate` | 產生新程式 | `/generate 一個表單驗證的 React Hook` | | `/doc` | 自動加上註解 | `/doc 幫我為這個函式加上 JSDoc` | | `/test` | 產生單元測試 | `/test 幫我建立 Jest 測試` | --- ## `#` 引用的應用方式 可以在聊天中直接提到檔案或符號,讓 Copilot 知道你指的是哪段程式: ``` 請比較 #App.tsx 和 #App-old.tsx,建議我該保留哪個寫法。 ``` ## 中場休息 ## 拿到舊專案的起手式 * [React 購物車](https://github.com/gonsakon/react-product-cart) 第一步:繪製架構圖,使用 [mermaid.live](https://mermaid.live/) ``` @workspace 從整個程式架構輸出一段 Mermaid 流程圖定義,可直接貼到 mermaid.live 渲染。不得輸出任何說明或 Markdown(不要出現 ```、語言標籤、標題、清單或額外文字)。 輸出第一行必須是:flowchart LR(必要時可改 `flowchart TB`)。 請遵守: 1.結構:若偵測到 npm/pnpm workspaces、Nx、Turborepo → 以每個 package/subpackage 為 subgraph;否則以頂層資料夾(apps、packages、src、server、client 等)為 subgraph。 2.節點(標籤中文化):入口檔(如 main.tsx、server.ts)、路由檔、API 客戶端(axios/fetch wrapper)、DB/ORM(Prisma/TypeORM)、建置/啟動腳本、Docker/Compose、測試設定(Jest/Vitest/Playwright)。 3.關係(邊的中文標註): • import/require 依賴:使用 A -- "imports|引用" --> B。 • 前端頁面/Hook → API 呼叫:使用 -- "HTTP|GET /api/users|取得使用者列表" -->。 • 服務 ↔ 資料庫/快取(Redis) ↔ 外部服務(API keys/SDK):以箭頭表示資料流向,必要時加上 CRUD 或 發佈/訂閱。 4.規模控制:最多 30 個節點;超過請以彙總節點表示(例:utils/*(約 15 檔)、/api/users/*(多端點))。 5.節點 ID 與標籤: • 節點 ID 只用英數與底線([A-Za-z0-9_]+),避免空白與符號。 • 節點標籤以中文為主(可含英文術語)。建議格式:檔名|角色/用途(例:main.tsx|前端入口、server.ts|API 入口、prisma|資料庫 ORM、Zustand|全域狀態)。 6.mermaid.live 相容性: • 請「只輸出一個」以 ```mermaid 開頭、``` 結尾的程式碼區塊,內容必須是 flowchart TB。 規則: - 每個宣告與連線各佔一行,不可同一行放多個節點或多條邊 - 先宣告節點,再連線 - subgraph 用:subgraph <id>[顯示名稱] ... end - 不要把箭頭直接連到 subgraph 本身,改連到代表節點(如 mainTSX) ``` 第二步:請他出摘要架構 ``` @workspace 你現在是本倉庫的「架構稽核官」。請掃描整個倉庫並只輸出下列四塊內容(繁體中文;不要寫 README): 1) 技能樹總表 - 前端/後端框架、語言版本 - 建置/啟動/測試指令(來源:package.json、Makefile、Dockerfile、.github/workflows 等) 2) 目錄與模組關係 - apps/packages/src/server/client/infra… 的用途 - 路由/狀態管理/API 客戶端/ORM 的位置與角色(以清單與簡短中文說明) 3) 環境變數地圖(表格) - 欄位:名稱|用途(中文)|出現位置(檔案路徑)|是否必填|預設值建議 - 並輸出一份 `.env.example`(不含真值) 限制與格式要求: - 一律依據實際檔案與程式碼 - 若對話中已提供系統架構 Mermaid 圖,請不要重畫;在回覆末行加註:`系統架構圖:已由使用者提供`。 - 在回覆最後附「來源索引」表格:欄位=依據檔案|用途說明|路徑(可多列)。 ``` 第三步:寫 readme 文件 ``` @workspace 根據「上一段架構稽核的輸出」與(若存在)使用者提供的 Mermaid 圖,生成完整的 `README.md`(繁體中文,Markdown)。請填入真實內容,不可杜撰。 README 結構(請依實際專案填寫): - 專案定位(產品一句話+目標使用者+核心價值 3–5 點) - 網站大綱(Sitemap) - 快速開始(安裝、啟動、測試、Docker 方案;提供可執行指令) - 環境變數(表格+ `.env.example` 區塊) - 資料夾結構(以樹狀圖+用途說明) - 常用指令(表格;來源於 package.json/Makefile) - API 與資料模型概觀(主要資源/端點摘要;若偵測到 OpenAPI 檔案,附路徑) - 部署與 CI/CD(偵測到的工作流/環境;若缺少給最小建議) 統一要求: - 若有多語系設定或前後端分離,請在「網站大綱」與「系統架構圖」中清楚標示。 ``` 第四步:on 起專案 ``` @workspace 你是本機啟動教練。請掃描整個專案,產出一份《本機啟動 Runbook》(繁中),內容務必根據實際檔案推斷(package.json、lockfile、Dockerfile、docker-compose、.nvmrc、Makefile、.github/workflows 等)。 請包含: 1) 需求工具與版本(Node/包管器、DB、Docker…),來源檔案與行數。 2) 安裝步驟與一鍵啟動指令(dev / build / start / test),逐步列出我該執行的三條命令。 3) 環境變數地圖(名稱|用途|出現位置|是否必填|預設值建議)+ 產出 `.env.example`(不含真值)。 4) 若偵測資料庫/快取:migrate/seed/連線檢查指令。 5) 若偵測到 Docker:給最小可行的 `docker compose up` 流程與需要的前置條件。 ``` 嘗試開發新功能: 1. 在產品列表加上篩選功能,需要有關鍵字、跟價格區間 ## 21 天後端工程師體驗營 (2026/1/7~2026/1/28) ### **[>>課程報名連結<<](https://www.hexschool.com/courses/backend-camp.html)** ![截圖 2025-11-27 下午5.07.35](https://hackmd.io/_uploads/SkCmScBW-l.png) ## 一年後端工程師培訓營 (2026/3~2027/3) ![unnamed (6)](https://hackmd.io/_uploads/BJ1lGFpWWl.jpg) ![Gemini_Generated_Image_kdq8wkkdq8wkkdq8 (1) (1)](https://hackmd.io/_uploads/Hkc0HqS--e.png)