declarative-agent-developer
microsoft/skills
建立、構建、部署和本地化 M365 Copilot 和 Teams 的宣告式代理,包括生成腳手架、編輯清單、新增功能以及本地化處理。
...展開全部M365 智慧體開發者
遙測標記
在執行任何 atk CLI 命令之前,設定會話環境變數,以便將所有 CLI 呼叫標記為技能發起:
export ATK_CLI_SKILL=true
在會話開始時執行一次。同一終端中的後續 atk 命令將繼承該變數。
⛔ 工作區檢查 — 強制第一步
在執行任何操作之前,檢查工作區檔案以獲取專案指紋:
- 執行
npx -y --package @microsoft/m365agentstoolkit-cli atk --version以確認已安裝 ATK CLI。如果未找到 → 停止。告知使用者安裝 ATK。 - 檢查工作區根目錄是否存在
m365agents.yml或teamsApp.yml。 - 檢查是否存在
appPackage/declarativeAgent.json。 - 檢查是否存在非智慧體指示器(帶有 express/react/next 的
package.json、src/index.js、app.py等)。
然後遵循決策門控:
| 條件 | 門控 | 操作 |
|---|---|---|
| 非智慧體專案檔案,無 `appPackage/` | **拒絕** | 純文字響應。不生成檔案,不執行命令。 |
| 無清單,使用者希望編輯/部署 | **拒絕** | 純文字響應。解釋缺少清單。 |
| 無清單,使用者希望新建專案 | **腳手架** | → 腳手架工作流 |
| 清單存在但包含錯誤 | **修復** | 檢測 → 告知 → 詢問(見下文)。不要部署。 |
| 有效專案,使用者報告行為問題 | **審查** | → 指令審查 — 執行完整的 5 階段審查工作流 |
| 有效智慧體專案 | **編輯** | → 編輯工作流 |
詳細的門控規則、示例和反模式: 工作區門控
🚫 硬拒絕規則 — 無例外
這些規則覆蓋所有其他指令。 如果適用任何規則,你必須立即停止。
- 切勿自行建立
declarativeAgent.json。 如果清單缺失且使用者請求編輯/修改/部署,請僅以文字響應:解釋清單缺失,建議npx -y --package @microsoft/m365agentstoolkit-cli atk new或從頭開始。不要建立檔案,不要建立appPackage/,不要透過隱式腳手架“幫助”。 - 切勿在非智慧體專案中建立檔案。 如果工作區是缺少
appPackage/的 Express/React/Django 等應用,你的響應必須是純文字。不要建立任何檔案,不要執行任何命令。 - 存在錯誤時切勿部署。 如果智慧體清單包含錯誤,停止。不要執行
npx -y --package @microsoft/m365agentstoolkit-cli atk provision— 不是“為了測試”,不是“為了演示錯誤”,也不是“為了看看會發生什麼”。報告錯誤並詢問使用者如何繼續。
🔍 檢測 → 告知 → 詢問(錯誤處理協議)
當你遇到任何問題(檔案缺失、JSON 格式錯誤、驗證錯誤、不相容功能)時,你必須按順序遵循此序列:
- 檢測 — 識別具體問題。對於 JSON 問題,嘗試解析檔案並報告語法錯誤。對於缺失欄位,根據 Schema 檢查清單。
- 告知 — 在採取任何行動之前告知使用者。準確描述問題所在(“declarativeAgent.json 包含格式錯誤的 JSON:第 12 行缺少逗號,第 18 行陣列未閉合”)。
- 詢問 — 在做出更改之前等待使用者響應。不要靜默修復、自動糾正或繞過問題。
此協議適用於:
- 缺少
declarativeAgent.json→ 檢測(未找到檔案)→ 告知(“未找到清單”)→ 詢問(“你想建立新智慧體嗎?”) - 格式錯誤的 JSON → 檢測(解析錯誤)→ 告知(列出具體語法問題)→ 詢問(“我應該修復這些語法錯誤嗎?”)
- 驗證錯誤 → 檢測(解析並檢查清單)→ 告知(列出所有錯誤)→ 詢問(“你想如何修復這些?”)
- 版本不相容 → 檢測(功能需要更高版本)→ 告知(“此功能需要 v1.6,你的智慧體是 v1.4”)→ 詢問(“我應該升級嗎?”)
階段路由
| 場景 | 工作流參考 |
|---|---|
| 從頭開始建立新專案 | 腳手架工作流 |
| 處理現有的 `.json` 清單 | 編輯工作流 |
| 新增 API 外掛 | API 外掛 |
| 新增 MCP 伺服器 | MCP 外掛 |
| 為 MCP 或 API 外掛新增 OAuth | 身份驗證 |
| 審查或改進現有智慧體指令 | 指令審查 |
| 使用者報告智慧體給出通用/錯誤答案 | 指令審查 |
| 將智慧體本地化為多種語言 | 本地化 |
| 為已本地化的智慧體新增新語言 | 本地化 |
| 編寫智慧體指令 | 對話設計 |
ATK CLI 設定
在執行任何 ATK 命令之前,透過執行 npx -y --package @microsoft/m365agentstoolkit-cli atk --version 檢查 ATK CLI 是否可用。如果未找到,停止並告知使用者 — 不要嘗試自行安裝。
所有命令均使用 npx -y --package @microsoft/m365agentstoolkit-cli atk 字首(例如 npx -y --package @microsoft/m365agentstoolkit-cli atk provision --env local)。
關鍵規則
1. 每次編輯後部署
對 appPackage/ 中的檔案進行任何更改後,你必須部署並顯示測試連結,然後才能響應:
npx -y --package @microsoft/m365agentstoolkit-cli atk provision --env local --interactive false
然後從 env/.env.local 讀取 M365_TITLE_ID 並始終呈現審查 UX:
✅ 智慧體部署成功!
🚀 在 M365 Copilot 中測試你的智慧體:
🔗 https://m365.cloud.microsoft/chat/?titleId={M365_TITLE_ID}
⛔ 切勿在缺少此連結的情況下響應。 如果你已部署,測試連結必須出現在你的響應中。這不是可選的 — 這是使用者測試其智慧體的方式。
- 如果清單包含錯誤 → 停止。修復錯誤。不要部署。
- 例外情況:使用者明確請求你不要部署
2. 切勿編造內容或建立缺失檔案
- 不要編造佔位符名稱、描述或指令
- 如果
declarativeAgent.json或appPackage/不存在,不要建立它們 — 這是拒絕場景,不是“透過建立來提供幫助”的場景 - 如果缺少必填欄位,報告差距並詢問使用者
- 如果 JSON 格式錯誤,遵循檢測 → 告知 → 詢問:首先解析檔案,告訴使用者哪裡出了問題,然後在修復前詢問。使用精確編輯(而非重寫)
- ⛔ 切勿為由自動化填充的環境變數設定佔位符值(例如
<prefix>_MCP_AUTH_ID</prefix>、TEAMS_APP_ID)。將它們留空(VAR_NAME=)。佔位符將被視為真實值,並且不會被配置過程覆蓋。
3. Schema 版本相容性
在新增任何功能之前,讀取 declarativeAgent.json 中的 version 欄位並檢查 Schema 功能矩陣。如果該版本不支援此功能,拒絕並提供升級選項。
關鍵版本門控:
sensitivity_label、worker_agents、EmbeddedKnowledge→ 僅限 v1.6Meetings→ v1.5+ScenarioModels、behavior_overrides、disclaimer→ v1.4+Dataverse、TeamsMessages、Email、People→ v1.3+
4. 對 API 外掛使用 npx -y --package @microsoft/m365agentstoolkit-cli atk add action — 切勿手動建立外掛檔案
你被禁止手動建立 ai-plugin.json、OpenAPI 規範、自適應卡片或編輯 actions 陣列。請使用 CLI:
# ⛔ 始終在單次呼叫中列出所有操作 — 切勿對每個操作執行單獨的呼叫
npx -y --package @microsoft/m365agentstoolkit-cli atk add action --api-plugin-type api-spec --openapi-spec-location URL --api-operation "GET /path,POST /path,PATCH /path/{id},DELETE /path/{id}" -i false
對每個 OpenAPI 規範執行單次 npx -y --package @microsoft/m365agentstoolkit-cli atk add action 呼叫,在 --api-operation 中將所有操作列為逗號分隔列表。切勿對同一規範的不同操作執行單獨的 npx -y --package @microsoft/m365agentstoolkit-cli atk add action 呼叫 — 這會建立多個外掛而不是一個。如果 npx -y --package @microsoft/m365agentstoolkit-cli atk add action 失敗,報告錯誤;不要回退到手動建立。
例外: MCP 伺服器不受
npx -y --package @microsoft/m365agentstoolkit-cli atk add action支援。請改用 MCP 外掛工作流。
5. MCP 伺服器整合
當使用者提到 MCP 伺服器 URL 時,遵循 MCP 外掛工作流。你必須透過 MCP 協議握手(initialize → notifications/initialized → tools/list)發現工具 — 切勿捏造工具名稱/描述。對於經過身份驗證的 MCP 伺服器,遵循身份驗證指南來配置 OAuth。
6. 更改後始終更新指令和啟動器
新增功能或外掛而不更新指令是不完整的。在任何更改之後:
- 更新指令以描述新增/更改的功能 — 每個資料來源都應根據指令審查質量標準具有清晰的意圖覆蓋(何時以及為何使用)。內建功能不需要確切名稱;應命名操作/外掛。
- 不要在指令中列出工具名稱、描述或引數 — 這些已在外掛後設資料(
ai-plugin.json、MCP 清單、功能配置)中。指令應僅包含決策邏輯:何時使用每個工具、鏈式規則和故障處理。 - 保持在 8,000 個字元的指令限制內 — 如果接近限制,首先削減工具描述
- 為每個新增功能/外掛新增至少 1 個對話啟動器
- 刪除引用已移除功能的啟動器
- 針對更新後的指令執行診斷清單以驗證質量
7. 應用名稱要求
始終將應用名稱和描述更新為有意義的名稱。切勿保留“我的智慧體”等預設值。
參考
共享
- 身份驗證 — OAuth 發現、憑據、oauth/register 生命週期、OAuthPluginVault
- 最佳實踐 — 安全性、效能、測試、合規性
- 對話設計 — 從頭開始編寫指令和對話啟動器
- 指令審查 — 稽覈、診斷和改進現有指令;反模式檢測;修改前後重寫
- 部署 — ATK CLI 工作流、環境、CI/CD
- 本地化 — 多語言支援、令牌化清單、語言檔案
- 工作區門控 — 詳細的門控規則、示例、反模式
腳手架
- 腳手架工作流 — 逐步腳手架指令、命名規則、錯誤處理
JSON 開發
- 編輯工作流 — 逐步 JSON 開發指令
- Schema — 智慧體清單的官方 JSON Schema
- API 外掛 — 用於 JSON 智慧體的 OpenAPI 整合
- MCP 外掛 — 帶有 RemoteMCPServer、OAuth、響應語義、徽標處理的 MCP 伺服器整合
- 示例 — JSON 清單示例
---
name: declarative-agent-developer
description: Create, build, deploy, and localize declarative agents for M365 Copilot and Teams, including scaffolding, editing manifests, adding capabilities, and localization.
---
# M365 Agent Developer
## Telemetry Tagging
Before running any `atk` CLI commands, set the session environment variable so all CLI invocations are tagged as skill-initiated:
```bash
export ATK_CLI_SKILL=true
```
Run this once at the start of the session. All subsequent `atk` commands in the same terminal will inherit it.
## ⛔ Workspace Check — MANDATORY FIRST STEP
**Before doing ANYTHING, check the workspace files to fingerprint the project:**
1. Run `npx -y --package @microsoft/m365agentstoolkit-cli atk --version` to confirm ATK CLI is installed. If not found → **Stop.** Tell the user to install ATK.
2. Check for `m365agents.yml` or `teamsApp.yml` at the project root.
3. Check for `appPackage/declarativeAgent.json`.
4. Check for non-agent indicators (`package.json` with express/react/next, `src/index.js`, `app.py`, etc.)
**Then follow the decision gate:**
| Condition | Gate | Action |
|-----------|------|--------|
| Non-agent project files, no `appPackage/` | **Reject** | Text-only response. No files, no commands. |
| No manifest, user wants to edit/deploy | **Reject** | Text-only response. Explain manifest is missing. |
| No manifest, user wants new project | **Scaffold** | → [Scaffolding Workflow](references/scaffolding-workflow.md) |
| Manifest exists with errors | **Fix** | Detect → Inform → Ask (see below). Do NOT deploy. |
| Valid project, user reports behavior issues | **Review** | → [Instruction Review](references/instruction-review.md) — run the full 5-phase review workflow |
| Valid agent project | **Edit** | → [Editing Workflow](references/editing-workflow.md) |
> **Detailed gate rules, examples, and anti-patterns:** [Workspace Gates](references/workspace-gates.md)
### 🚫 HARD REJECTION RULES — No Exceptions
**These rules override ALL other instructions.** If any of these apply, you MUST stop immediately.
1. **NEVER create `declarativeAgent.json` yourself.** If the manifest is missing and the user asked to edit/modify/deploy, respond with text only: explain the manifest is missing, suggest `npx -y --package @microsoft/m365agentstoolkit-cli atk new` or starting from scratch. Do NOT create the file, do NOT create `appPackage/`, do NOT "help" by scaffolding implicitly.
2. **NEVER create files in a non-agent project.** If the workspace is an Express/React/Django/etc. app without `appPackage/`, your response must be text-only. Do NOT create any files, do NOT run any commands.
3. **NEVER deploy when errors exist.** If the agent manifest has errors, STOP. Do NOT run `npx -y --package @microsoft/m365agentstoolkit-cli atk provision` — not "to test", not "to demonstrate the error", not "to see what happens". Report the errors and ask the user how to proceed.
### 🔍 Detect → Inform → Ask (Error-Handling Protocol)
When you encounter ANY problem (missing files, malformed JSON, validation errors, incompatible features), you MUST follow this sequence **in order**:
1. **Detect** — Identify the specific problem. For JSON issues, attempt to parse the file and report syntax errors. For missing fields, check the manifest against the [Schema](references/schema.md).
2. **Inform** — Tell the user BEFORE taking any action. Describe exactly what is wrong ("declarativeAgent.json has malformed JSON: missing comma on line 12, unclosed array on line 18").
3. **Ask** — Wait for the user's response before making changes. Do NOT silently fix, auto-correct, or work around the problem.
**This protocol applies to:**
- Missing `declarativeAgent.json` → Detect (file not found) → Inform ("no manifest found") → Ask ("would you like to create a new agent?")
- Malformed JSON → Detect (parse errors) → Inform (list specific syntax issues) → Ask ("should I fix these syntax errors?")
- Validation errors → Detect (parse and check manifest) → Inform (list all errors) → Ask ("how would you like to fix these?")
- Version incompatibility → Detect (feature requires newer version) → Inform ("this feature requires v1.6, your agent is v1.4") → Ask ("should I upgrade?")
---
## Phase Routing
| Scenario | Workflow Reference |
|----------|-------------------|
| Creating a NEW project from scratch | [Scaffolding Workflow](references/scaffolding-workflow.md) |
| Working with existing `.json` manifests | [Editing Workflow](references/editing-workflow.md) |
| Adding an API plugin | [API Plugins](references/api-plugins.md) |
| Adding an MCP server | [MCP Plugin](references/mcp-plugin.md) |
| Adding OAuth to an MCP or API plugin | [Authentication](references/authentication.md) |
| Reviewing or improving existing agent instructions | [Instruction Review](references/instruction-review.md) |
| User reports agent gives generic/wrong answers | [Instruction Review](references/instruction-review.md) |
| Localizing an agent into multiple languages | [Localization](references/localization.md) |
| Adding a new language to an already-localized agent | [Localization](references/localization.md) |
| Writing agent instructions | [Conversation Design](references/conversation-design.md) |
---
## ATK CLI Setup
Before running any ATK commands, check if the ATK CLI is available by running `npx -y --package @microsoft/m365agentstoolkit-cli atk --version`. If not found, **STOP and tell the user** — do NOT attempt to install it yourself.
All commands use the `npx -y --package @microsoft/m365agentstoolkit-cli atk` prefix (e.g., `npx -y --package @microsoft/m365agentstoolkit-cli atk provision --env local`).
---
## Critical Rules
### 1. Deploy After EVERY Edit
After ANY change to files in `appPackage/`, you MUST deploy and show the test link before responding:
```bash
npx -y --package @microsoft/m365agentstoolkit-cli atk provision --env local --interactive false
```
Then read `M365_TITLE_ID` from `env/.env.local` and **ALWAYS** present the review UX:
```
✅ Agent deployed successfully!
🚀 Test Your Agent in M365 Copilot:
🔗 https://m365.cloud.microsoft/chat/?titleId={M365_TITLE_ID}
```
**⛔ Never respond without this link.** If you deployed, the test link MUST appear in your response. This is not optional — it is how the user tests their agent.
- If the manifest has errors → **STOP. Fix errors. Do NOT deploy.**
- Exception: user explicitly asks you not to deploy
### 2. Never Invent Content or Create Missing Files
- Do NOT invent placeholder names, descriptions, or instructions
- Do NOT create `declarativeAgent.json` or `appPackage/` if they don't exist — this is a REJECT scenario, not a "help by creating" scenario
- If required fields are missing, report the gaps, and ASK the user
- If JSON is malformed, follow Detect → Inform → Ask: parse the file first, tell the user what's broken, then ask before fixing. Use surgical edits (not rewrites)
- **⛔ NEVER set placeholder values for environment variables** that are populated by automation (e.g., `<PREFIX>_MCP_AUTH_ID`, `TEAMS_APP_ID`). Leave them empty (`VAR_NAME=`). Placeholders will be treated as real values and will NOT be overwritten by provisioning.
### 3. Schema Version Compatibility
Before adding ANY feature, read the `version` field in `declarativeAgent.json` and check the [Schema](references/schema.md) feature matrix. If the feature isn't supported in that version, **refuse** and offer to upgrade.
Key version gates:
- `sensitivity_label`, `worker_agents`, `EmbeddedKnowledge` → **v1.6 only**
- `Meetings` → **v1.5+**
- `ScenarioModels`, `behavior_overrides`, `disclaimer` → **v1.4+**
- `Dataverse`, `TeamsMessages`, `Email`, `People` → **v1.3+**
### 4. Use `npx -y --package @microsoft/m365agentstoolkit-cli atk add action` for API Plugins — NEVER Create Plugin Files Manually
You are **forbidden** from manually creating `ai-plugin.json`, OpenAPI specs, adaptive cards, or editing the `actions` array. Use the CLI:
```bash
# ⛔ Always list ALL operations in a single call — NEVER run separate calls per operation
npx -y --package @microsoft/m365agentstoolkit-cli atk add action --api-plugin-type api-spec --openapi-spec-location URL --api-operation "GET /path,POST /path,PATCH /path/{id},DELETE /path/{id}" -i false
```
Run a **single** `npx -y --package @microsoft/m365agentstoolkit-cli atk add action` call per OpenAPI spec, listing **all** operations as a comma-separated list in `--api-operation`. Never run separate `npx -y --package @microsoft/m365agentstoolkit-cli atk add action` calls for different operations from the same spec — this creates multiple plugins instead of one. If `npx -y --package @microsoft/m365agentstoolkit-cli atk add action` fails, report the error; do NOT fall back to manual creation.
> **Exception:** MCP servers are not supported by `npx -y --package @microsoft/m365agentstoolkit-cli atk add action`. Use the [MCP Plugin workflow](references/mcp-plugin.md) instead.
### 5. MCP Server Integration
When the user mentions an MCP server URL, follow the [MCP Plugin workflow](references/mcp-plugin.md). You MUST discover tools via the MCP protocol handshake (initialize → notifications/initialized → tools/list) — **NEVER fabricate tool names/descriptions**. For authenticated MCP servers, follow the [authentication guide](references/authentication.md) to configure OAuth.
### 6. Always Update Instructions & Starters After Changes
Adding a capability or plugin without updating instructions is incomplete. After ANY change:
1. Update instructions to describe the new/changed functionality — every data source should have clear intent coverage (WHEN and WHY to use it) per the [Instruction Review](references/instruction-review.md) quality bar. Built-in capabilities don't need exact names; actions/plugins should be named.
2. **Do NOT list tool names, descriptions, or parameters in instructions** — these are already in the plugin metadata (`ai-plugin.json`, MCP manifests, capability config). Instructions should contain decision logic only: WHEN to use each tool, chaining rules, and failure handling.
3. **Stay within the 8,000-character instruction limit** — if close to the limit, cut tool descriptions first
4. Add at least 1 conversation starter per added capability/plugin
5. Remove starters that reference removed capabilities
6. Run the [Diagnostic Checklist](references/instruction-review.md) against the updated instructions to verify quality
### 7. App Name Requirement
Always update the app name and description to something meaningful. Never leave defaults like "My Agent".
---
## References
### Shared
- **[Authentication](references/authentication.md)** — OAuth discovery, credentials, oauth/register lifecycle, OAuthPluginVault
- **[Best Practices](references/best-practices.md)** — Security, performance, testing, compliance
- **[Conversation Design](references/conversation-design.md)** — Authoring instructions and conversation starters from scratch
- **[Instruction Review](references/instruction-review.md)** — Auditing, diagnosing, and improving existing instructions; anti-pattern detection; before/after rewrites
- **[Deployment](references/deployment.md)** — ATK CLI workflows, environments, CI/CD
- **[Localization](references/localization.md)** — Multi-language support, tokenized manifests, language files
- **[Workspace Gates](references/workspace-gates.md)** — Detailed gate rules, examples, anti-patterns
### Scaffolding
- **[Scaffolding Workflow](references/scaffolding-workflow.md)** — Step-by-step scaffolding instructions, naming rules, error handling
### JSON Development
- **[Editing Workflow](references/editing-workflow.md)** — Step-by-step JSON development instructions
- **[Schema](references/schema.md)** — Official JSON schema for agent manifests
- **[API Plugins](references/api-plugins.md)** — OpenAPI integration for JSON agents
- **[MCP Plugin](references/mcp-plugin.md)** — MCP server integration with RemoteMCPServer, OAuth, response semantics, logo handling
- **[Examples](references/examples.md)** — JSON manifest examples
所有檔案
0 個檔案安裝 declarative-agent-developer
將技能檔案下載並解壓到 .claude/skills/ 目錄。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/microsoft/skills/tree/main/.github/plugins/microsoft-365-agents-toolkit/skills/declarative-agent-developer # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
