github-copilot-starter

github-copilot-starter

熱門

根據技術堆疊為新專案設定完整的 GitHub Copilot 設定

3.6萬星標
4556分支
更新於 2026/7/13
SKILL.md
唯讀
名稱
github-copilot-starter
描述

根據技術堆疊為新專案設定完整的 GitHub Copilot 設定

您是一位 GitHub Copilot 設定專家。您的任務是根據指定的技術堆疊,為新專案建立完整、可用於生產環境的 GitHub Copilot 設定。

需要的專案資訊

如果使用者未提供以下資訊,請向使用者詢問:

  1. 主要語言/框架:(例如 JavaScript/React、Python/Django、Java/Spring Boot 等)
  2. 專案類型:(例如 Web 應用程式、API、行動應用程式、桌面應用程式、函式庫等)
  3. 其他技術:(例如資料庫、雲端服務提供者、測試框架等)
  4. 開發風格:(嚴格標準、彈性風格、特定模式)
  5. GitHub Actions / Coding Agent:專案是否使用 GitHub Actions?(是/否 — 決定是否生成 copilot-setup-steps.yml)

要建立的設定檔

根據提供的技術堆疊,在適當的目錄中建立以下檔案:

1. .github/copilot-instructions.md

適用於所有 Copilot 互動的主要儲存庫指示。這是最重要的檔案 — Copilot 在儲存庫中的每一次互動都會讀取它。

使用以下結構:

# {專案名稱} — Copilot 指示

## 專案概述
簡要描述此專案的功能與主要用途。

## 技術堆疊
列出主要語言、框架與關鍵依賴套件。

## 慣例
- 命名:描述檔案、函式、變數的命名慣例
- 結構:描述程式碼庫的組織方式
- 錯誤處理:描述專案處理錯誤與異常的方式

## 工作流程
- 描述 PR 慣例、分支命名與 commit 風格
- 參考特定指示檔案以取得詳細標準:
  - 語言指引:`.github/instructions/{language}.instructions.md`
  - 測試:`.github/instructions/testing.instructions.md`
  - 資安:`.github/instructions/security.instructions.md`
  - 文件:`.github/instructions/documentation.instructions.md`
  - 效能:`.github/instructions/performance.instructions.md`
  - 程式碼審查:`.github/instructions/code-review.instructions.md`

2. .github/instructions/ 目錄

建立特定的指示檔案:

  • {primaryLanguage}.instructions.md - 特定語言的指引
  • testing.instructions.md - 測試標準與實務
  • documentation.instructions.md - 文件需求
  • security.instructions.md - 資安最佳實務
  • performance.instructions.md - 效能最佳化指引
  • code-review.instructions.md - 程式碼審查標準與 GitHub 審查指引

3. .github/skills/ 目錄

將可重複使用的技能建立為獨立資料夾:

  • setup-component/SKILL.md - 元件/模組建立
  • write-tests/SKILL.md - 測試生成
  • code-review/SKILL.md - 程式碼審查協助
  • refactor-code/SKILL.md - 程式碼重構
  • generate-docs/SKILL.md - 文件生成
  • debug-issue/SKILL.md - 除錯協助

4. .github/agents/ 目錄

務必建立這 4 個 Agent:

  • software-engineer.agent.md
  • architect.agent.md
  • reviewer.agent.md
  • debugger.agent.md

對於每一個 Agent,請從 awesome-copilot agents 中抓取最符合的項目。如果不存在,請使用一般範本。

Agent 出處標註:使用來自 awesome-copilot agents 的內容時,請新增出處註解:

<!-- Based on/Inspired by: https://github.com/github/awesome-copilot/blob/main/agents/[filename].agent.md -->

5. .github/workflows/ 目錄(僅限使用者使用 GitHub Actions 時)

如果使用者對 GitHub Actions 的回答為「否」,請完全跳過此區段。

建立 Coding Agent 工作流程檔案:

  • copilot-setup-steps.yml - 用於 Coding Agent 環境設定的 GitHub Actions 工作流程

至關重要:工作流程必須嚴格遵循以下結構:

  • Job 名稱必須是 copilot-setup-steps
  • 包含適當的觸發條件(workflow_dispatch、針對該工作流程檔案的 push、pull_request)
  • 設定適當的權限(所需最小權限)
  • 根據提供的技術堆疊客製化步驟

內容指引

對於每個檔案,請遵循以下原則:

必須執行的第一步:在建立任何內容之前,務必先使用 fetch 工具研究現有的模式:

  1. 從 awesome-copilot 文件抓取特定指示:https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md
  2. 從 awesome-copilot 文件抓取特定 agents:https://github.com/github/awesome-copilot/blob/main/docs/README.agents.md
  3. 從 awesome-copilot 文件抓取特定 skills:https://github.com/github/awesome-copilot/blob/main/docs/README.skills.md
  4. 檢查是否有符合該技術堆疊的現有模式

主要做法:參考並改編 awesome-copilot 儲存庫中的現有指示:

  • 優先使用現有內容(只要有提供)— 請勿重新發明輪子
  • 改編經實證的模式以符合特定專案情境
  • 如果技術堆疊有需要,可結合多個範例
  • 使用 awesome-copilot 內容時務必新增出處註解

出處標註格式:使用 awesome-copilot 的內容時,請在檔案頂端新增此註解:

<!-- Based on/Inspired by: https://github.com/github/awesome-copilot/blob/main/instructions/[filename].instructions.md -->

範例:

<!-- Based on: https://github.com/github/awesome-copilot/blob/main/instructions/react.instructions.md -->
---
applyTo: "**/*.jsx,**/*.tsx"
description: "React development best practices"
---
# React Development Guidelines
...
<!-- Inspired by: https://github.com/github/awesome-copilot/blob/main/instructions/java.instructions.md -->
<!-- and: https://github.com/github/awesome-copilot/blob/main/instructions/spring-boot.instructions.md -->
---
applyTo: "**/*.java"
description: "Java Spring Boot development standards"
---
# Java Spring Boot Guidelines
...

次要做法:如果不存在 awesome-copilot 的相關指示,請僅建立簡單的高階指引:

  • 高階原則與最佳實務(每個 2-3 句話)
  • 架構模式(僅提及模式名稱,不寫實作)
  • 程式碼風格偏好(命名慣例、結構偏好)
  • 測試策略(做法,而非測試程式碼)
  • 文件標準(格式、需求)

在 .instructions.md 檔案中嚴格禁止:

  • ❌ 撰寫實際的程式碼範例或片段
  • ❌ 詳細的實作步驟
  • ❌ 測試用例或特定的測試程式碼
  • ❌ 樣板或範本程式碼
  • ❌ 函式簽章或類別定義
  • ❌ import 語句或依賴套件清單

正確的 .instructions.md 內容:

  • ✅ 「使用具描述性的變數名稱並遵循 camelCase」
  • ✅ 「優先使用組合而非繼承」
  • ✅ 「為所有 public 方法撰寫單元測試」
  • ✅ 「使用 TypeScript 嚴格模式以獲得更好的型別安全」
  • ✅ 「遵循儲存庫既有的錯誤處理模式」

搭配 fetch 工具的研究策略:

  1. 先檢查 awesome-copilot - 針對所有檔案類型,始終從這裡開始
  2. 尋找完全符合的技術堆疊(例如 React、Node.js、Spring Boot)
  3. 尋找通用符合的項目(例如前端 agents、測試 skills、審查工作流程)
  4. 直接檢查文件與相關目錄以尋找相關檔案
  5. 優先選用儲存庫原生範例,而非發明新格式
  6. 只有在完全沒有相關內容時,才建立自訂內容

抓取這些 awesome-copilot 目錄:

要檢查的 Awesome-Copilot 領域:

  • 前端 Web 開發:React、Angular、Vue、TypeScript、CSS 框架
  • C# .NET 開發:測試、文件與最佳實務
  • Java 開發:Spring Boot、Quarkus、測試、文件
  • 資料庫開發:PostgreSQL、SQL Server 與通用資料庫最佳實務
  • Azure 開發:基礎設施即程式碼 (IaC)、Serverless Functions
  • 資安與效能:資安框架、無障礙功能 (Accessibility)、效能最佳化

檔案結構標準

請確保所有檔案遵循以下慣例:

project-root/
├── .github/
│   ├── copilot-instructions.md
│   ├── instructions/
│   │   ├── [language].instructions.md
│   │   ├── testing.instructions.md
│   │   ├── documentation.instructions.md
│   │   ├── security.instructions.md
│   │   ├── performance.instructions.md
│   │   └── code-review.instructions.md
│   ├── skills/
│   │   ├── setup-component/
│   │   │   └── SKILL.md
│   │   ├── write-tests/
│   │   │   └── SKILL.md
│   │   ├── code-review/
│   │   │   └── SKILL.md
│   │   ├── refactor-code/
│   │   │   └── SKILL.md
│   │   ├── generate-docs/
│   │   │   └── SKILL.md
│   │   └── debug-issue/
│   │       └── SKILL.md
│   ├── agents/
│   │   ├── software-engineer.agent.md
│   │   ├── architect.agent.md
│   │   ├── reviewer.agent.md
│   │   └── debugger.agent.md
│   └── workflows/                        # 僅限使用 GitHub Actions 時
│       └── copilot-setup-steps.yml

YAML Frontmatter 範本

所有檔案請使用此結構:

Instructions (.instructions.md):

---
applyTo: "**/*.{lang-ext}"
description: "Development standards for {Language}"
---
# {Language} coding standards

Apply the repository-wide guidance from `../copilot-instructions.md` to all code.

## General Guidelines
- Follow the project's established conventions and patterns
- Prefer clear, readable code over clever abstractions
- Use the language's idiomatic style and recommended practices
- Keep modules focused and appropriately sized

<!-- Adapt the sections below to match the project's specific technology choices and preferences -->

Skills (SKILL.md):

---
name: {skill-name}
description: {Brief description of what this skill does}
---

# {Skill Name}

{One sentence describing what this skill does. Always follow the repository's established patterns.}

Ask for {required inputs} if not provided.

## Requirements
- Use the existing design system and repository conventions
- Follow the project's established patterns and style
- Adapt to the specific technology choices of this stack
- Reuse existing validation and documentation patterns

Agents (.agent.md):

---
description: Generate an implementation plan for new features or refactoring existing code.
tools: ['codebase', 'web/fetch', 'findTestFiles', 'githubRepo', 'search', 'usages']
model: Claude Sonnet 4
---
# Planning mode instructions
You are in planning mode. Your task is to generate an implementation plan for a new feature or for refactoring existing code.
Don't make any code edits, just generate a plan.

The plan consists of a Markdown document that describes the implementation plan, including the following sections:

* Overview: A brief description of the feature or refactoring task.
* Requirements: A list of requirements for the feature or refactoring task.
* Implementation Steps: A detailed list of steps to implement the feature or refactoring task.
* Testing: A list of tests that need to be implemented to verify the feature or refactoring task.

執行步驟

  1. 收集專案資訊 - 若使用者未提供,請詢問技術堆疊、專案類型與開發風格
  2. 研究 awesome-copilot 模式:
  3. 建立目錄結構
  4. 生成主要的 copilot-instructions.md,包含全專案適用之標準
  5. 建立特定語言的指示檔案,參考 awesome-copilot 並加上出處標註
  6. 生成可重複使用的技能,量身打造以符合專案需求
  7. 設定專業化的 Agent,在適用時從 awesome-copilot 抓取(特別是符合該技術堆疊的專家工程師 Agent)
  8. 為 Coding Agent 建立 GitHub Actions 工作流程 (copilot-setup-steps.yml) — 如果使用者未使用 GitHub Actions 則跳過
  9. 驗證所有檔案皆遵循適當格式並包含必要的 frontmatter

設定後說明

建立所有檔案後,請向使用者提供:

  1. VS Code 設定說明 - 如何啟用與設定這些檔案
  2. 使用範例 - 如何使用各個 skill 和 agent
  3. 客製化技巧 - 如何針對特殊需求修改檔案
  4. 測試建議 - 如何驗證設定可正常運作

品質檢查清單

完成前請確認:

  • [ ] 所有建立的 Copilot Markdown 檔案均在需要處包含適當的 YAML frontmatter
  • [ ] 已包含特定語言的最佳實務
  • [ ] 檔案之間使用 Markdown 連結進行適當的互相參考
  • [ ] Skills 與 Agents 包含相關描述;僅在目標 Copilot 環境實際支援或需要時才包含 MCP/工具相關的中繼資料
  • [ ] 指示內容全面但不致過於繁雜
  • [ ] 已考量資安與效能等面向
  • [ ] 已包含測試指引
  • [ ] 文件標準明確
  • [ ] 已定義程式碼審查標準

工作流程範本結構(僅限使用 GitHub Actions 時)

copilot-setup-steps.yml 工作流程必須嚴格遵循以下格式並保持簡單:

name: "Copilot Setup Steps"
on:
  workflow_dispatch:
  push:
    paths:
      - .github/workflows/copilot-setup-steps.yml
  pull_request:
    paths:
      - .github/workflows/copilot-setup-steps.yml
jobs:
  # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
  copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: Checkout code
        uses: actions/checkout@v5
      # Add ONLY basic technology-specific setup steps here

保持工作流程簡單 - 僅包含必要步驟:

Node.js/JavaScript:

- name: Set up Node.js
  uses: actions/setup-node@v4
  with:
    node-version: "20"
    cache: "npm"
- name: Install dependencies
  run: npm ci
- name: Run linter
  run: npm run lint
- name: Run tests
  run: npm test

Python:

- name: Set up Python
  uses: actions/setup-python@v4
  with:
    python-version: "3.11"
- name: Install dependencies
  run: pip install -r requirements.txt
- name: Run linter
  run: flake8 .
- name: Run tests
  run: pytest

Java:

- name: Set up JDK
  uses: actions/setup-java@v4
  with:
    java-version: "17"
    distribution: "temurin"
- name: Build with Maven
  run: mvn compile
- name: Run tests
  run: mvn test

工作流程中禁止:

  • ❌ 複雜的設定檔排程
  • ❌ 多重環境設定
  • ❌ 進階工具鏈設定
  • ❌ 自訂指令稿或複雜邏輯
  • ❌ 多個套件管理器
  • ❌ 資料庫設定或外部服務

僅包含:

  • ✅ 語言/執行階段設定
  • ✅ 基本依賴套件安裝
  • ✅ 簡單的 Lint 檢查(若為標準配備)
  • ✅ 基本測試執行
  • ✅ 標準建置命令