GitHub Copilot 與 VS Code
VS Code 中的 GitHub Copilot 支援全儲存庫指令、限定路徑的 .instructions.md 檔案,以及宣告於 .vscode/mcp.json 中的 Streamable HTTP MCP 伺服器。
DESIGN.md 與指令檔案的放置位置
my-app/
├── DESIGN.md
├── .github/
│ ├── copilot-instructions.md
│ └── instructions/
│ └── design.instructions.md
└── .vscode/
└── mcp.json將 DESIGN.md 接入 Copilot 指令
限定路徑的指令檔案(.github/instructions/design.instructions.md)
使用 applyTo glob 規則,讓 Copilot 僅在編輯 UI 程式碼時附加設計系統規則:
---
applyTo: "src/components/**/*.{tsx,jsx,css},src/app/**/*.{tsx,jsx,css}"
---
Read `DESIGN.md` at the repository root before creating or editing UI components.
Use only the colors, typography, spacing, corner radii, and component states specified there, and follow its Do's and Don'ts.全儲存庫備援設定(.github/copilot-instructions.md)
## Design System
Visual tokens and UI layout constraints live in `DESIGN.md`. Apply them on every frontend component, page, and CSS update.在 VS Code 中連線 DesignMD Pro MCP 伺服器
VS Code 在 .vscode/mcp.json(或使用者層級設定)中使用 "servers" 作為根鍵名並搭配 "type": "http":
{
"servers": {
"designmdpro": {
"type": "http",
"url": "https://designmdpro.app/mcp"
}
}
}若使用 Pro API 金鑰(dmdp_…,來自 帳戶 → API 金鑰),建議使用 VS Code 輸入變數,避免將機密資訊提交至 git:
{
"inputs": [
{
"type": "promptString",
"id": "designmdpro-api-key",
"description": "DesignMD Pro API Key (dmdp_...)",
"password": true
}
],
"servers": {
"designmdpro": {
"type": "http",
"url": "https://designmdpro.app/mcp",
"headers": {
"Authorization": "Bearer ${input:designmdpro-api-key}"
}
}
}
}若要在不使用 inputs 的情況下進行快速本機測試,您也可以直接在使用者設定中填入 "Authorization": "Bearer dmdp_your_api_key"。
提示詞範本
#file:DESIGN.md Build a billing status banner component in src/components/.
Match the exact colors, spacing, and Shapes rules in DESIGN.md.Use #designmdpro to search for fintech design systems, pull the Colors and
Typography sections, and propose an accessible dark-mode token block for our DESIGN.md.常見陷阱
- 在
.vscode/mcp.json中誤用"mcpServers"而非"servers":與 Cursor 或 Windsurf 不同,VS Code 必須使用"servers"並指定"type": "http"。 - 將明文 API 金鑰提交至
.vscode/mcp.json:.vscode/mcp.json通常會納入 git 版控;對於dmdp_…金鑰,請務必使用${input:...}或使用者層級設定。
下一步
- MCP 伺服器設定頁 — 複製所有四種用戶端的組態片段
- 驗證器與 Lint 規則 — 依對比度規則驗證產生的變更
Last updated on