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-plugin3description: 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<!-- Generated from harness/github-copilot/skills/typespec-create-api-plugin/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# TypeSpec API plugin creation910Create 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.1112## When to invoke1314- "Create a TypeSpec API plugin for this REST API."15- "Generate main.tsp and actions.tsp for a Microsoft 365 Copilot agent."16- "Add API key or OAuth2 auth to a TypeSpec action plugin."17- "Return API results with an Adaptive Card."18- "Model these CRUD operations as Copilot plugin actions."1920## Inputs2122Use 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.2324## TypeSpec file map2526| File | Required content |27| --- | --- |28| `main.tsp` | Imports `@typespec/http`, `@typespec/openapi3`, `@microsoft/typespec-m365-copilot`, and `./actions.tsp`; defines `@agent`, `@instructions`, namespace, and operation references. |29| `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. |30| `cards/card.json` | Optional Adaptive Card template referenced by `@card` when rich visual responses are required. |3132Use these skeletons as the minimum shape:3334```typescript35// main.tsp36import "@typespec/http";37import "@typespec/openapi3";38import "@microsoft/typespec-m365-copilot";39import "./actions.tsp";4041using TypeSpec.Http;42using TypeSpec.M365.Copilot.Agents;43using TypeSpec.M365.Copilot.Actions;4445@agent({ name: "[Agent Name]", description: "[Description]" })46@instructions("""47 [Instructions for using the API operations]48""")49namespace [AgentName] {50 op operation1 is [APINamespace].operationName;51}52```5354```typescript55// actions.tsp56import "@typespec/http";57import "@microsoft/typespec-m365-copilot";5859using TypeSpec.Http;60using TypeSpec.M365.Copilot.Actions;6162@service63@actions(#{64 nameForHuman: "[API Display Name]",65 descriptionForModel: "[Model description]",66 descriptionForHuman: "[User description]"67})68@server("[API_BASE_URL]", "[API Name]")69@useAuth([AuthType])70namespace [APINamespace] {71 @route("[/path]")72 @get73 @action74 op operationName(@path param1: string, @query param2?: string): ResponseModel;7576 model ResponseModel {77 // Response structure78 }79}80```8182## Authentication patterns8384| API requirement | TypeSpec pattern |85| --- | --- |86| Public API | Omit `@useAuth`; do not create placeholder auth models. |87| API key in header | `@useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">)` |88| 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"]; }]>)` |89| Registered auth reference | Define `@authReferenceId("registration-id-here") model Auth is ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">` and call `@useAuth(Auth)`. |9091## Operation design rules9293| Area | Rule |94| --- | --- |95| Operation names | Use clear action-oriented names such as `listProjects` or `createTicket`. |96| Models | Define TypeScript-like request and response models instead of anonymous blobs. |97| HTTP methods | Use `@get`, `@post`, `@patch`, and `@delete` to match the API contract. |98| Routes | Use RESTful paths with `@route`; bind variables with `@path`, `@query`, `@header`, and `@body`. |99| Descriptions | Fill `nameForHuman`, `descriptionForModel`, and `descriptionForHuman` with concrete language for model understanding. |100| Confirmations | Add confirmation dialogs for `delete`, critical `update`, payment, or irreversible operations. |101| Cards | Use `@card` for rich visual responses with multiple data items. |102103## Capability decorators104105```typescript106@capabilities(#{107 confirmation: #{108 type: "AdaptiveCard",109 title: "Confirm Action",110 body: """111 Are you sure you want to perform this action?112 * **Parameter**: {{ function.parameters.paramName }}113 """114 }115})116```117118```typescript119@card(#{120 dataPath: "$.items",121 title: "$.title",122 url: "$.link",123 file: "cards/card.json"124})125```126127```typescript128@reasoning("""129 Consider user's context when calling this operation.130 Prioritize recent items over older ones.131""")132@responding("""133 Present results in a clear table format with columns: ID, Title, Status.134 Include a summary count at the end.135""")136```137138## Procedure1391401. Ask or infer the API base URL, API purpose, required CRUD operations, authentication method, confirmation needs, and Adaptive Card needs.1412. Generate `main.tsp` with the agent definition and operation references.1423. Generate `actions.tsp` with service metadata, server, auth, routes, parameters, and request/response models.1434. Add `cards/card.json` only when the response design uses `@card`.1445. Review the generated TypeSpec for concrete names, no unresolved placeholders except user-approved placeholders, and correct auth decorators.145146## Gotchas147148- **Do not leave `[API_BASE_URL]` unresolved in final code** unless the user explicitly asks for a template.149- **Do not add `@useAuth` for public APIs**; placeholder auth breaks plugin setup.150- **Do not skip confirmations on destructive operations**; deletion and critical updates need `@capabilities` confirmation.151- **Do not model response bodies as untyped `object` when fields are known**; TypeSpec models improve action planning and OpenAPI output.152153## Output template154155```markdown156## TypeSpec API plugin157158**Status:** complete | needs input | blocked159**Agent:** <agent name>160**API base URL:** <base URL or unresolved placeholder>161162### Files163- `main.tsp`: <summary>164- `actions.tsp`: <summary>165- `cards/card.json`: <created | not needed>166167### Operations168| Operation | Method | Route | Auth | Confirmation | Response |169| --- | --- | --- | --- | --- | --- |170| `<operationName>` | `<GET|POST|PATCH|DELETE>` | `<route>` | `<auth>` | `<yes|no>` | `<model/card>` |171172### Validation173- Placeholder review: <pass|fail and evidence>174- Auth mapping: <pass|fail and evidence>175- Adaptive Card mapping: <pass|not applicable and evidence>176```177178## Quality gate179180- [ ] `main.tsp` imports required TypeSpec and Microsoft 365 Copilot libraries and references operations from `actions.tsp`.181- [ ] `actions.tsp` defines `@service`, `@actions`, `@server`, operations, models, and only the needed `@useAuth` pattern.182- [ ] Every operation has an HTTP verb, `@route`, parameter decorators, and a typed response model.183- [ ] Destructive operations include an Adaptive Card confirmation.184- [ ] `@card`, `@reasoning`, and `@responding` are used only when they add concrete behavior.185- [ ] Any remaining placeholder such as `[AgentName]` or `[API_BASE_URL]` is intentional and reported.
Run npx skillmds@latest add paulasilvatech/typespec-create-api-plugin 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.