选项
首页首页 Skill 开发运营和 CI/CD declarative-agent-developer

declarative-agent-developer

microsoft/skills microsoft/skills

创建、构建、部署和本地化 M365 Copilot 和 Teams 的声明式代理,包括生成脚手架、编辑清单、添加功能以及本地化处理。

...展开全部
1
更新时间 2026-09-19

M365 智能体开发者

遥测标记

在运行任何 atk CLI 命令之前,设置会话环境变量,以便将所有 CLI 调用标记为技能发起:

export ATK_CLI_SKILL=true

在会话开始时运行一次。同一终端中的后续 atk 命令将继承该变量。

⛔ 工作区检查 — 强制第一步

在执行任何操作之前,检查工作区文件以获取项目指纹:

  1. 运行 npx -y --package @microsoft/m365agentstoolkit-cli atk --version 以确认已安装 ATK CLI。如果未找到 → 停止。告知用户安装 ATK。
  2. 检查工作区根目录是否存在 m365agents.ymlteamsApp.yml
  3. 检查是否存在 appPackage/declarativeAgent.json
  4. 检查是否存在非智能体指示器(带有 express/react/next 的 package.jsonsrc/index.jsapp.py 等)。

然后遵循决策门控:

条件门控操作
非智能体项目文件,无 `appPackage/`**拒绝**纯文本响应。不生成文件,不执行命令。
无清单,用户希望编辑/部署**拒绝**纯文本响应。解释缺少清单。
无清单,用户希望新建项目**脚手架**→ 脚手架工作流
清单存在但包含错误**修复**检测 → 告知 → 询问(见下文)。不要部署。
有效项目,用户报告行为问题**审查**→ 指令审查 — 运行完整的 5 阶段审查工作流
有效智能体项目**编辑**→ 编辑工作流

详细的门控规则、示例和反模式: 工作区门控

🚫 硬拒绝规则 — 无例外

这些规则覆盖所有其他指令。 如果适用任何规则,你必须立即停止。

  1. 切勿自行创建 declarativeAgent.json 如果清单缺失且用户请求编辑/修改/部署,请仅以文本响应:解释清单缺失,建议 npx -y --package @microsoft/m365agentstoolkit-cli atk new 或从头开始。不要创建文件,不要创建 appPackage/,不要通过隐式脚手架“帮助”。
  2. 切勿在非智能体项目中创建文件。 如果工作区是缺少 appPackage/ 的 Express/React/Django 等应用,你的响应必须是纯文本。不要创建任何文件,不要运行任何命令。
  3. 存在错误时切勿部署。 如果智能体清单包含错误,停止。不要运行 npx -y --package @microsoft/m365agentstoolkit-cli atk provision — 不是“为了测试”,不是“为了演示错误”,也不是“为了看看会发生什么”。报告错误并询问用户如何继续。

🔍 检测 → 告知 → 询问(错误处理协议)

当你遇到任何问题(文件缺失、JSON 格式错误、验证错误、不兼容功能)时,你必须按顺序遵循此序列:

  1. 检测 — 识别具体问题。对于 JSON 问题,尝试解析文件并报告语法错误。对于缺失字段,根据 Schema 检查清单。
  2. 告知 — 在采取任何行动之前告知用户。准确描述问题所在(“declarativeAgent.json 包含格式错误的 JSON:第 12 行缺少逗号,第 18 行数组未闭合”)。
  3. 询问 — 在做出更改之前等待用户响应。不要静默修复、自动纠正或绕过问题。

此协议适用于:

  • 缺少 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.jsonappPackage/ 不存在,不要创建它们 — 这是拒绝场景,不是“通过创建来提供帮助”的场景
  • 如果缺少必填字段,报告差距并询问用户
  • 如果 JSON 格式错误,遵循检测 → 告知 → 询问:首先解析文件,告诉用户哪里出了问题,然后在修复前询问。使用精确编辑(而非重写)
  • ⛔ 切勿为由自动化填充的环境变量设置占位符值(例如 <prefix>_MCP_AUTH_ID</prefix>TEAMS_APP_ID)。将它们留空(VAR_NAME=)。占位符将被视为真实值,并且不会被配置过程覆盖。

3. Schema 版本兼容性

在添加任何功能之前,读取 declarativeAgent.json 中的 version 字段并检查 Schema 功能矩阵。如果该版本不支持此功能,拒绝并提供升级选项。

关键版本门控:

  • sensitivity_labelworker_agentsEmbeddedKnowledge仅限 v1.6
  • Meetingsv1.5+
  • ScenarioModelsbehavior_overridesdisclaimerv1.4+
  • DataverseTeamsMessagesEmailPeoplev1.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. 更改后始终更新指令和启动器

添加功能或插件而不更新指令是不完整的。在任何更改之后:

  1. 更新指令以描述新增/更改的功能 — 每个数据源都应根据指令审查质量标准具有清晰的意图覆盖(何时以及为何使用)。内置功能不需要确切名称;应命名操作/插件。
  2. 不要在指令中列出工具名称、描述或参数 — 这些已在插件元数据(ai-plugin.json、MCP 清单、功能配置)中。指令应仅包含决策逻辑:何时使用每个工具、链式规则和故障处理。
  3. 保持在 8,000 个字符的指令限制内 — 如果接近限制,首先削减工具描述
  4. 为每个新增功能/插件添加至少 1 个对话启动器
  5. 删除引用已移除功能的启动器
  6. 针对更新后的指令运行诊断清单以验证质量

7. 应用名称要求

始终将应用名称和描述更新为有意义的名称。切勿保留“我的智能体”等默认值。

参考

共享

  • 身份验证 — OAuth 发现、凭据、oauth/register 生命周期、OAuthPluginVault
  • 最佳实践 — 安全性、性能、测试、合规性
  • 对话设计 — 从头开始编写指令和对话启动器
  • 指令审查 — 审核、诊断和改进现有指令;反模式检测;修改前后重写
  • 部署 — ATK CLI 工作流、环境、CI/CD
  • 本地化 — 多语言支持、令牌化清单、语言文件
  • 工作区门控 — 详细的门控规则、示例、反模式

脚手架

  • 脚手架工作流 — 逐步脚手架指令、命名规则、错误处理

JSON 开发

  • 编辑工作流 — 逐步 JSON 开发指令
  • Schema — 智能体清单的官方 JSON Schema
  • API 插件 — 用于 JSON 智能体的 OpenAPI 集成
  • MCP 插件 — 带有 RemoteMCPServer、OAuth、响应语义、徽标处理的 MCP 服务器集成
  • 示例 — JSON 清单示例
在 GitHub 上查看
---
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

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ 目录。Claude 将自动检测并使用该技能。

相关技能

klingai-upgrade-migration
更新时间 2026-07-03
Verification &amp; Quality Assurance
更新时间 2026-06-29
base44-cli
更新时间 2026-06-29
Railway CLI Management
更新时间 2026-07-02
OR