跳至主要内容

2 篇文章 含有標籤「GCP」

檢視所有標籤

TechSummary 2025-09-03

· 閱讀時間約 18 分鐘
Gemini
AI Assistant

🤖 撰寫 Copilot 自訂指令的 5 個技巧

Source: https://github.blog/ai-and-ml/github-copilot/5-tips-for-writing-better-custom-instructions-for-copilot/

  • Copilot 指令文件 (copilot-instructions.md) 至關重要,它能為 Copilot 提供專案的必要上下文,如同新人入職時的背景知識,有助於避免混淆和錯誤。
  • 專案概覽: 指令文件應以專案的「電梯簡報」開頭,簡潔描述應用程式的目標、受眾和主要功能。
    # Contoso Companions

    This is a website to support pet adoption agencies. Agencies are onboarded into the application, where they can manage their locations, available pets, and publicize events. Potential adoptors can search for pets available in their area, discover agencies, and submit adoption applications.
  • 技術棧識別: 明確列出專案使用的後端、前端技術、API 和測試套件,並可簡要說明其用途,幫助 Copilot 理解開發環境。
    ## Tech stack in use

    ### Backend

    - Flask is used for the API
    - Data is stored in Postgres, with SQLAlchemy as the ORM
    - There are separate database for dev, staging and prod
    - For end to end testing, a new database is created and populated,
    then removed after tests are complete

    ### Frontend

    - Astro manages the core site and routing
    - Svelte is used for interactivity
    - TypeScript is used for all front-end code

    ### Testing

    - Unittest for Python
    - Vitest for TypeScript
    - Playwright for e2e tests
  • 編碼規範: 詳述專案的編碼風格、標準和測試要求,例如型別提示、分號使用、單元測試和端對端測試的規定等,這部分可獨立成區塊。
    ## Project and code guidelines

    - Always use type hints in any language which supports them
    - JavaScript/TypeScript should use semicolons
    - Unit tests are required, and are required to pass before PR
    - Unit tests should focus on core functionality
    - End-to-end tests are required
    - End-to-end tests should focus on core functionality
    - End-to-end tests should validate accessibility
    - Always follow good security practices
    - Follow RESTful API design principles
    - Use scripts to perform actions when available
  • 專案結構說明: 描述專案的文件夾結構及其內容,可幫助 Copilot 快速定位並理解各部分功能。
    ## Project structure

    - server/ : Flask backend code
    - models/ : SQLAlchemy ORM models
    - routes/ : API endpoints organized by resource
    - tests/ : Unit tests for the API
    - utils/ : Utility functions and helpers, including database calls
    - client/ : Astro/Svelte frontend code
    - src/components/ : Reusable Svelte components
    - src/layouts/ : Astro layout templates
    - src/pages/ : Astro pages and routes
    - src/styles/ : CSS stylesheets
    - scripts/ : Development, deployment and testing scripts
    - docs/ : Project documentation to be kept in sync at all times
  • 指向可用資源: 列出專案中可用的腳本或工具,如開發、部署和測試腳本,或特定的 MCP 伺服器,以提高 Copilot 的準確性和速度。
    ## Resources

    - scripts folder
    - start-app.sh : Installs all libraries and starts the app
    - setup-env.sh : Installs all libraries
    - test-project.sh : Installs all libraries, runs unit and e2e tests
    - MCP servers
    - Playwright: Used for generating Playwright tests or interacting with site
    - GitHub: Used to interact with repository and backlog
  • Copilot 輔助生成指令文件: Copilot 自身也能協助創建 copilot-instructions.md 文件,提供標準化的提示範本,幫助開發者釐清專案目標。
    Your task is to "onboard" this repository to a coding agent by adding a .github/copilot-instructions.md file. It should contain information describing how the agent, seeing the repo for the first time, can work most efficiently.
    ...
    ## Guidance

    Ensure you include the following:

    - A summary of what the app does.
    - The tech stack in use
    - Coding guidelines
    - Project structure
    - Existing tools and resources
  • 強調指令文件無需完美,但有總比沒有好,且應隨著專案演進而更新。

TechSummary 2025-08-19

· 閱讀時間約 15 分鐘
Gemini
AI Assistant

Agents panel: Launch Copilot coding agent tasks anywhere on GitHub 🚀

Source: https://github.blog/news-insights/product-news/agents-panel-launch-copilot-coding-agent-tasks-anywhere-on-github/

  • GitHub Copilot coding agent 是一款非同步、自主的開發者代理,可將 GitHub issue 指派給 Copilot,由其在後台工作並建立草稿拉取請求 (PR) 供審閱。
  • 新推出的 Agents panel 允許開發者從 GitHub.com 上的任何頁面快速將任務委託給 Copilot,並追蹤其進度而無需中斷工作流程。
  • Agents panel 是 GitHub 上代理工作流程的任務控制中心,它是一個輕量級的疊加層,可將新任務交給 Copilot 並追蹤現有任務。
  • 可用的功能包括:無需切換頁面即可分配後台任務、實時監控運行中的任務、以及在準備好審閱時跳轉到拉取請求。
  • 支援從 GitHub.com、GitHub Mobile、Copilot Chat、VS Code 或支援 MCP 的工具發起任務。
  • Copilot coding agent 的近期升級包括:更廣泛的可用性(所有付費 Copilot 訂閱者,如 Pro, Pro+, Business, Enterprise)、每次代理會話僅使用一個高級請求(成本效益提升 20 倍)、以及更智能的代理(內建瀏覽器用於驗證更改、新的遠程 MCP 伺服器配置、自定義指令和防火牆設置)。
  • 範例提示:
    • 描述簡單任務:
      • “Add integration tests for LoginController”
      • “Refactor WidgetGenerator for better code reuse”
      • “Add a dark mode/light mode switcher”
    • 引用 GitHub issue 或 PR 作為上下文:
      • “Fix #877 using pull request #855 as an example”
      • “Fix #1050, and make sure you update the screenshots in the README”
    • 並行執行多個任務:
      • “Add unit test coverage for utils.go” + “Add unit test coverage for helpers.go”