Generate TypeSpec API plugins for Microsoft 365 Copilot with REST operations, authentication, confirmations, Adaptive Cards, and response instructions. Use when asked to create a TypeSpec API plugin, define main.tsp and actions.tsp, model API operations, add @useAuth, or build Adaptive Card responses for Microsoft 365 Copilot agents.
Create a complete Microsoft 365 Copilot API plugin from API requirements by producing main.tsp, actions.tsp, optional cards/card.json, and implementation notes for operations, authentication, confirmations, and response shaping.
When to invoke
"Create a TypeSpec API plugin for this REST API."
"Generate main.tsp and actions.tsp for a Microsoft 365 Copilot agent."
"Add API key or OAuth2 auth to a TypeSpec action plugin."
"Return API results with an Adaptive Card."
"Model these CRUD operations as Copilot plugin actions."
Inputs
Use the user's API description as the source of truth. Capture API base URL, purpose, operations, request and response schema, authentication method, destructive operations that need confirmation, and whether responses need Adaptive Cards.
TypeSpec file map
File
Required content
main.tsp
Imports @typespec/http, @typespec/openapi3, @microsoft/typespec-m365-copilot, and ./actions.tsp; defines @agent, @instructions, namespace, and operation references.
actions.tsp
Imports @typespec/http and @microsoft/typespec-m365-copilot; defines @service, @actions, @server("[API_BASE_URL]", "[API Name]"), optional @useAuth, REST operations, and models.
cards/card.json
Optional Adaptive Card template referenced by @card when rich visual responses are required.
Use these skeletons as the minimum shape:
// main.tsp
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
import "./actions.tsp";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
using TypeSpec.M365.Copilot.Actions;
@agent({ name: "[Agent Name]", description: "[Description]" })
@instructions("""
[Instructions for using the API operations]
""")
namespace [AgentName] {
op operation1 is [APINamespace].operationName;
}
@reasoning("""
Consider user's context when calling this operation.
Prioritize recent items over older ones.
""")
@responding("""
Present results in a clear table format with columns: ID, Title, Status.
Include a summary count at the end.
""")
Procedure
Ask or infer the API base URL, API purpose, required CRUD operations, authentication method, confirmation needs, and Adaptive Card needs.
Generate main.tsp with the agent definition and operation references.
Generate actions.tsp with service metadata, server, auth, routes, parameters, and request/response models.
Add cards/card.json only when the response design uses @card.
Review the generated TypeSpec for concrete names, no unresolved placeholders except user-approved placeholders, and correct auth decorators.
Gotchas
Do not leave [API_BASE_URL] unresolved in final code unless the user explicitly asks for a template.
Do not add @useAuth for public APIs; placeholder auth breaks plugin setup.
Do not skip confirmations on destructive operations; deletion and critical updates need @capabilities confirmation.
Do not model response bodies as untyped object when fields are known; TypeSpec models improve action planning and OpenAPI output.
main.tsp imports required TypeSpec and Microsoft 365 Copilot libraries and references operations from actions.tsp.
actions.tsp defines @service, @actions, @server, operations, models, and only the needed @useAuth pattern.
Every operation has an HTTP verb, @route, parameter decorators, and a typed response model.
Destructive operations include an Adaptive Card confirmation.
@card, @reasoning, and @responding are used only when they add concrete behavior.
Any remaining placeholder such as [AgentName] or [API_BASE_URL] is intentional and reported.
1---2name: typespec-create-api-plugin-23description: Generate TypeSpec API plugins for Microsoft 365 Copilot with REST operations, authentication, confirmations, Adaptive Cards, and response instructions. Use when asked to create a TypeSpec API plugin, define main.tsp and actions.tsp, model API operations, add @useAuth, or build Adaptive Card responses for Microsoft 365 Copilot agents.4---56# TypeSpec API plugin creation78Create a complete Microsoft 365 Copilot API plugin from API requirements by producing `main.tsp`, `actions.tsp`, optional `cards/card.json`, and implementation notes for operations, authentication, confirmations, and response shaping.910## When to invoke1112- "Create a TypeSpec API plugin for this REST API."13- "Generate main.tsp and actions.tsp for a Microsoft 365 Copilot agent."14- "Add API key or OAuth2 auth to a TypeSpec action plugin."15- "Return API results with an Adaptive Card."16- "Model these CRUD operations as Copilot plugin actions."1718## Inputs1920Use the user's API description as the source of truth. Capture API base URL, purpose, operations, request and response schema, authentication method, destructive operations that need confirmation, and whether responses need Adaptive Cards.2122## TypeSpec file map2324| File | Required content |25| --- | --- |26| `main.tsp` | Imports `@typespec/http`, `@typespec/openapi3`, `@microsoft/typespec-m365-copilot`, and `./actions.tsp`; defines `@agent`, `@instructions`, namespace, and operation references. |27| `actions.tsp` | Imports `@typespec/http` and `@microsoft/typespec-m365-copilot`; defines `@service`, `@actions`, `@server("[API_BASE_URL]", "[API Name]")`, optional `@useAuth`, REST operations, and models. |28| `cards/card.json` | Optional Adaptive Card template referenced by `@card` when rich visual responses are required. |2930Use these skeletons as the minimum shape:3132```typescript33// main.tsp34import "@typespec/http";35import "@typespec/openapi3";36import "@microsoft/typespec-m365-copilot";37import "./actions.tsp";3839using TypeSpec.Http;40using TypeSpec.M365.Copilot.Agents;41using TypeSpec.M365.Copilot.Actions;4243@agent({ name: "[Agent Name]", description: "[Description]" })44@instructions("""45 [Instructions for using the API operations]46""")47namespace [AgentName] {48 op operation1 is [APINamespace].operationName;49}50```5152```typescript53// actions.tsp54import "@typespec/http";55import "@microsoft/typespec-m365-copilot";5657using TypeSpec.Http;58using TypeSpec.M365.Copilot.Actions;5960@service61@actions(#{62 nameForHuman: "[API Display Name]",63 descriptionForModel: "[Model description]",64 descriptionForHuman: "[User description]"65})66@server("[API_BASE_URL]", "[API Name]")67@useAuth([AuthType])68namespace [APINamespace] {69 @route("[/path]")70 @get71 @action72 op operationName(@path param1: string, @query param2?: string): ResponseModel;7374 model ResponseModel {75 // Response structure76 }77}78```7980## Authentication patterns8182| API requirement | TypeSpec pattern |83| --- | --- |84| Public API | Omit `@useAuth`; do not create placeholder auth models. |85| API key in header | `@useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">)` |86| OAuth2 authorization code | `@useAuth(OAuth2Auth<[{ type: OAuth2FlowType.authorizationCode; authorizationUrl: "https://oauth.example.com/authorize"; tokenUrl: "https://oauth.example.com/token"; refreshUrl: "https://oauth.example.com/token"; scopes: ["read", "write"]; }]>)` |87| Registered auth reference | Define `@authReferenceId("registration-id-here") model Auth is ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">` and call `@useAuth(Auth)`. |8889## Operation design rules9091| Area | Rule |92| --- | --- |93| Operation names | Use clear action-oriented names such as `listProjects` or `createTicket`. |94| Models | Define TypeScript-like request and response models instead of anonymous blobs. |95| HTTP methods | Use `@get`, `@post`, `@patch`, and `@delete` to match the API contract. |96| Routes | Use RESTful paths with `@route`; bind variables with `@path`, `@query`, `@header`, and `@body`. |97| Descriptions | Fill `nameForHuman`, `descriptionForModel`, and `descriptionForHuman` with concrete language for model understanding. |98| Confirmations | Add confirmation dialogs for `delete`, critical `update`, payment, or irreversible operations. |99| Cards | Use `@card` for rich visual responses with multiple data items. |100101## Capability decorators102103```typescript104@capabilities(#{105 confirmation: #{106 type: "AdaptiveCard",107 title: "Confirm Action",108 body: """109 Are you sure you want to perform this action?110 * **Parameter**: {{ function.parameters.paramName }}111 """112 }113})114```115116```typescript117@card(#{118 dataPath: "$.items",119 title: "$.title",120 url: "$.link",121 file: "cards/card.json"122})123```124125```typescript126@reasoning("""127 Consider user's context when calling this operation.128 Prioritize recent items over older ones.129""")130@responding("""131 Present results in a clear table format with columns: ID, Title, Status.132 Include a summary count at the end.133""")134```135136## Procedure1371381. Ask or infer the API base URL, API purpose, required CRUD operations, authentication method, confirmation needs, and Adaptive Card needs.1392. Generate `main.tsp` with the agent definition and operation references.1403. Generate `actions.tsp` with service metadata, server, auth, routes, parameters, and request/response models.1414. Add `cards/card.json` only when the response design uses `@card`.1425. Review the generated TypeSpec for concrete names, no unresolved placeholders except user-approved placeholders, and correct auth decorators.143144## Gotchas145146- **Do not leave `[API_BASE_URL]` unresolved in final code** unless the user explicitly asks for a template.147- **Do not add `@useAuth` for public APIs**; placeholder auth breaks plugin setup.148- **Do not skip confirmations on destructive operations**; deletion and critical updates need `@capabilities` confirmation.149- **Do not model response bodies as untyped `object` when fields are known**; TypeSpec models improve action planning and OpenAPI output.150151## Output template152153```markdown154## TypeSpec API plugin155156**Status:** complete | needs input | blocked157**Agent:** <agent name>158**API base URL:** <base URL or unresolved placeholder>159160### Files161- `main.tsp`: <summary>162- `actions.tsp`: <summary>163- `cards/card.json`: <created | not needed>164165### Operations166| Operation | Method | Route | Auth | Confirmation | Response |167| --- | --- | --- | --- | --- | --- |168| `<operationName>` | `<GET|POST|PATCH|DELETE>` | `<route>` | `<auth>` | `<yes|no>` | `<model/card>` |169170### Validation171- Placeholder review: <pass|fail and evidence>172- Auth mapping: <pass|fail and evidence>173- Adaptive Card mapping: <pass|not applicable and evidence>174```175176## Quality gate177178- [ ] `main.tsp` imports required TypeSpec and Microsoft 365 Copilot libraries and references operations from `actions.tsp`.179- [ ] `actions.tsp` defines `@service`, `@actions`, `@server`, operations, models, and only the needed `@useAuth` pattern.180- [ ] Every operation has an HTTP verb, `@route`, parameter decorators, and a typed response model.181- [ ] Destructive operations include an Adaptive Card confirmation.182- [ ] `@card`, `@reasoning`, and `@responding` are used only when they add concrete behavior.183- [ ] Any remaining placeholder such as `[AgentName]` or `[API_BASE_URL]` is intentional and reported.
Run npx skillmds@latest add paulasilvatech/typespec-create-api-plugin-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Generate TypeSpec API plugins for Microsoft 365 Copilot with REST operations, authentication, confirmations, Adaptive Cards, and response instructions. Use when asked to create a TypeSpec API plugin, define main.tsp and actions.tsp, model API operations, add @useAuth, or build Adaptive Card responses for Microsoft 365 Copilot agents. It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
paulasilvatech (@paulasilvatech) published this skill. Their other Agent Skills are listed on their SkillMD profile.