---
featureId: custom-agents
title: 建置您自己的自訂 Agent
area: GitHub Copilot
thumbnailImage: ../media/custom-agents-thumbnail.png
devComUrl: https://developercommunity.visualstudio.com/t/Custom-modes-for-Copilot-Chat/10950930?q=custom+agents
description: 使用存放庫或使用者設定檔中的 .agent.md 檔案，定義符合您團隊工作流程的自訂 Agent。

---


自訂 Agent 可協助您為團隊工作流程建立專門的 Copilot Agent。 它們可使用工作區感知、程式碼理解、工具、您所選取的模型，以及連線到內部文件、設計系統、API 和資料庫等外部知識來源的 MCP 連線。

自訂 Agent 會定義為存放庫或使用者設定檔中的 `.agent.md` 檔案。
工作區或專案專屬 Agent 會儲存在您存放庫的 `.github/agents/` 之下。 例如：

```text
your-repo/
└── .github/
    └── agents/
        └── code-reviewer.agent.md
```

使用者層級 Agent 預設會儲存在`%USERPROFILE%/.github/agents/`。 您可以在**工具 > 選項 > Copilot Chat > 自訂 Agent 使用者目錄**中變更此位置。

若要建立自訂 Agent，請直接在上述其中一個位置建立 `.agent.md` 檔案，或按一下 Agent 選擇器中的 **+** 按鈕，然後依照提示操作。

![顯示 CSharp 專家自訂 Agent 的 Agent 選擇器](../media/custom-agents.png)

建立自訂 Agent 後，它就會顯示在 Agent 選擇器中，讓您隨時都能使用。

有幾點需要注意：

- 如果您未指定模型，Agent 會使用目前在模型選擇器中選取的模型。
- 不同 GitHub Copilot 平台的工具名稱各不相同，請查看 Visual Studio 中可用的工具，以確保您的 Agent 能如預期運作。
- [awesome-copilot](https://github.com/github/awesome-copilot) 存放庫提供社群貢獻的 Agent 組態，可作為您的起點。 在 Visual Studio 中使用工具名稱之前，請先確認。
