TechSummary 2025-10-13
· 閱讀時間約 8 分鐘
🚀 GitHub Copilot CLI 入門
Source: https://github.blog/ai-and-ml/github-copilot/github-copilot-cli-how-to-get-started/
- GitHub Copilot CLI 將 AI 輔助直接帶入終端機,讓開發者無需切換編輯器或瀏覽器,即可在 CLI 中完成程式碼撰寫、除錯、環境設定等工作,保持開發流程的連續性。
- 快速安裝與驗證:
- 全域安裝
@github/copilot-cli套件,要求 Node v22+ 和 npm v10+。 - 啟動
copilot並使用/login透過現有的 GitHub Copilot Pro/Business 帳戶進行身份驗證。
npm install -g @github/copilot-cli
copilot
/login - 全域安裝
- 多樣化的 使用情境:
- 新專案上手: 詢問
Explain the layout of this project.以理解專案結構。 - 環境準備: 透過
Make sure my environment is ready to build this project.自動檢查並安裝依賴。 - 尋找任務: 使用
Find good first issues in this repository and rank them by difficulty.篩選合適的入門級問題。 - 實作與提交: 透過
Start implementing issue #1234. Show me the diff before applying.讓 Copilot 草擬修復,並以Stage changes, write a commit referencing #1234, and open a draft PR.快速提交並開啟草稿 Pull Request。 - 解決常見問題: 應對埠佔用等問題,如
What process is using port 8080? Kill it and verify the port is free.
- 新專案上手: 詢問
- 使用者控制與安全性: Copilot CLI 在執行任何指令或存取目錄前,都會先提示使用者(Allow once, Allow always, Deny),確保使用者對 AI 的操作保持完全控制。
- 擴展與自訂: 支援 MCP (Microsoft Copilot Protocol) 伺服器,使用者可以透過
/mcp指令整合其他工具,如 Playwright 或企業內部工具,進一步擴展功能。