Create TypeSpec declarative agent
GitHub Copilot uses this skill to generate a main.tsp file for a Microsoft 365 Copilot declarative agent by translating the user's purpose, knowledge sources, and interaction examples into TypeSpec decorators and scoped AgentCapabilities operations.
When to invoke
- "Create a TypeSpec declarative agent."
- "Generate main.tsp for a Microsoft 365 Copilot agent."
- "Add WebSearch and OneDrive capabilities to an agent."
- "Scaffold a TypeSpec M365 Copilot declarative agent."
Inputs
Ask or infer these facts before writing main.tsp:
| Input |
Required |
Rule |
| Agent purpose and role |
Yes |
Convert to a descriptive role-based name and behavior. |
| Capabilities needed |
Yes |
Include only capabilities the agent actually needs. |
| Knowledge sources |
Conditional |
Capture sites, folders, Teams areas, connectors, Dataverse tables, or meeting scope when relevant. |
| Typical user interactions |
Yes |
Use them to write 2-4 diverse conversation starters. |
| Limits and safety behavior |
Yes |
Put refusals, escalation, and boundaries in @instructions. |
TypeSpec structure
Generate one main.tsp file with these pieces:
| Part |
TypeSpec construct |
Constraint |
| Imports |
import "@typespec/http";, import "@typespec/openapi3";, import "@microsoft/typespec-m365-copilot"; |
Keep imports at the top. |
| Usings |
using TypeSpec.Http;, using TypeSpec.M365.Copilot.Agents; |
Required for agent decorators and capabilities. |
| Agent declaration |
@agent({ name, description }) |
Name is 100 characters or less; description is 1,000 characters or less. |
| Instructions |
@instructions("""...""") |
Under 8,000 characters; define role, expertise, personality, do and do not rules. |
| Conversation starters |
@conversationStarter(#{ title, text }) |
Include 2-4 starters with diverse user intents. |
| Namespace |
namespace [AgentName] { ... } |
Use a valid TypeSpec identifier, usually PascalCase without spaces. |
| Capabilities |
op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>; |
Scope URLs, folders, and content where possible. |
Capability selection
| Capability |
Use when |
Scoping guidance |
WebSearch |
The agent needs public web content. |
Add site scoping when the domain is known. |
OneDriveAndSharePoint |
The agent answers from user or organization documents. |
Filter by URL, folder, or site when possible. |
TeamsMessages |
The agent needs Teams channels or chats. |
Limit to relevant channel/chat contexts. |
Email |
Mailbox content is part of the task. |
Prefer folder or sender filters over broad mailbox access. |
People |
The agent searches organization people or roles. |
Use for expertise and directory lookup, not document search. |
CodeInterpreter |
The agent needs Python analysis, calculation, or file processing. |
Describe data boundaries in instructions. |
GraphicArt |
The agent generates images. |
Include style and brand limitations. |
GraphConnectors |
The agent uses Microsoft 365 Copilot connector content. |
Name the connector content domain. |
Dataverse |
The agent reads Dataverse data. |
Scope to relevant tables or business objects. |
Meetings |
The agent uses meeting content. |
State whether summaries, transcripts, or action items are expected. |
Template
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent({
name: "[Agent Name]",
description: "[Agent Description]"
})
@instructions("""
[Detailed instructions about agent behavior, role, and guidelines]
""")
@conversationStarter(#{
title: "[Starter Title 1]",
text: "[Example query 1]"
})
@conversationStarter(#{
title: "[Starter Title 2]",
text: "[Example query 2]"
})
namespace [AgentName] {
op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>;
}
Authoring rules
- Use descriptive role-based agent names such as
Customer Support Assistant or Research Helper.
- Write instructions in second person: "You are...".
- Be specific about expertise, limitations, escalation, data sources, and unsupported tasks.
- Include 2-4 conversation starters that showcase different capabilities rather than duplicates.
- Use triple-quoted strings for multi-line instructions.
- Scope capabilities for performance and least privilege.
- Do not include broad capabilities just because they exist.
Gotchas
- Agent names and namespace identifiers are different: the display name may contain spaces, but the namespace must be a valid TypeSpec identifier.
- Broad knowledge sources reduce quality: scoped
WebSearch, OneDriveAndSharePoint, TeamsMessages, and Email capabilities are usually better than unbounded access.
- Conversation starters are examples, not tests: they should be realistic user prompts and cover the agent's primary use cases.
Output template
## TypeSpec declarative agent
**Status:** generated | needs input | blocked
**File:** `main.tsp`
**Agent name:** <display name>
**Namespace:** <TypeSpec namespace>
### Capabilities
| Operation | AgentCapabilities type | Scope |
| --- | --- | --- |
| `<operation>` | `<CapabilityType>` | `<parameters or none>` |
### Conversation starters
- `<title>` — `<text>`
### Validation
- Name length: <pass/fail>
- Description length: <pass/fail>
- Instructions length: <pass/fail>
Quality gate
1---2name: typespec-create-agent3description: Generate a complete TypeSpec declarative agent for Microsoft 365 Copilot with agent metadata, instructions, capabilities, and conversation starters. Use when the user asks to create a TypeSpec declarative agent, main.tsp, Microsoft 365 Copilot agent, or TypeSpec M365 capability scaffold.4---56<!-- Generated from harness/github-copilot/skills/typespec-create-agent/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Create TypeSpec declarative agent910GitHub Copilot uses this skill to generate a `main.tsp` file for a Microsoft 365 Copilot declarative agent by translating the user's purpose, knowledge sources, and interaction examples into TypeSpec decorators and scoped AgentCapabilities operations.1112## When to invoke1314- "Create a TypeSpec declarative agent."15- "Generate main.tsp for a Microsoft 365 Copilot agent."16- "Add WebSearch and OneDrive capabilities to an agent."17- "Scaffold a TypeSpec M365 Copilot declarative agent."1819## Inputs2021Ask or infer these facts before writing `main.tsp`:2223| Input | Required | Rule |24| --- | --- | --- |25| Agent purpose and role | Yes | Convert to a descriptive role-based name and behavior. |26| Capabilities needed | Yes | Include only capabilities the agent actually needs. |27| Knowledge sources | Conditional | Capture sites, folders, Teams areas, connectors, Dataverse tables, or meeting scope when relevant. |28| Typical user interactions | Yes | Use them to write 2-4 diverse conversation starters. |29| Limits and safety behavior | Yes | Put refusals, escalation, and boundaries in `@instructions`. |3031## TypeSpec structure3233Generate one `main.tsp` file with these pieces:3435| Part | TypeSpec construct | Constraint |36| --- | --- | --- |37| Imports | `import "@typespec/http";`, `import "@typespec/openapi3";`, `import "@microsoft/typespec-m365-copilot";` | Keep imports at the top. |38| Usings | `using TypeSpec.Http;`, `using TypeSpec.M365.Copilot.Agents;` | Required for agent decorators and capabilities. |39| Agent declaration | `@agent({ name, description })` | Name is 100 characters or less; description is 1,000 characters or less. |40| Instructions | `@instructions("""...""")` | Under 8,000 characters; define role, expertise, personality, do and do not rules. |41| Conversation starters | `@conversationStarter(#{ title, text })` | Include 2-4 starters with diverse user intents. |42| Namespace | `namespace [AgentName] { ... }` | Use a valid TypeSpec identifier, usually PascalCase without spaces. |43| Capabilities | `op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>;` | Scope URLs, folders, and content where possible. |4445## Capability selection4647| Capability | Use when | Scoping guidance |48| --- | --- | --- |49| `WebSearch` | The agent needs public web content. | Add site scoping when the domain is known. |50| `OneDriveAndSharePoint` | The agent answers from user or organization documents. | Filter by URL, folder, or site when possible. |51| `TeamsMessages` | The agent needs Teams channels or chats. | Limit to relevant channel/chat contexts. |52| `Email` | Mailbox content is part of the task. | Prefer folder or sender filters over broad mailbox access. |53| `People` | The agent searches organization people or roles. | Use for expertise and directory lookup, not document search. |54| `CodeInterpreter` | The agent needs Python analysis, calculation, or file processing. | Describe data boundaries in instructions. |55| `GraphicArt` | The agent generates images. | Include style and brand limitations. |56| `GraphConnectors` | The agent uses Microsoft 365 Copilot connector content. | Name the connector content domain. |57| `Dataverse` | The agent reads Dataverse data. | Scope to relevant tables or business objects. |58| `Meetings` | The agent uses meeting content. | State whether summaries, transcripts, or action items are expected. |5960## Template6162```typespec63import "@typespec/http";64import "@typespec/openapi3";65import "@microsoft/typespec-m365-copilot";6667using TypeSpec.Http;68using TypeSpec.M365.Copilot.Agents;6970@agent({71 name: "[Agent Name]",72 description: "[Agent Description]"73})74@instructions("""75 [Detailed instructions about agent behavior, role, and guidelines]76""")77@conversationStarter(#{78 title: "[Starter Title 1]",79 text: "[Example query 1]"80})81@conversationStarter(#{82 title: "[Starter Title 2]",83 text: "[Example query 2]"84})85namespace [AgentName] {86 op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>;87}88```8990## Authoring rules9192- Use descriptive role-based agent names such as `Customer Support Assistant` or `Research Helper`.93- Write instructions in second person: "You are...".94- Be specific about expertise, limitations, escalation, data sources, and unsupported tasks.95- Include 2-4 conversation starters that showcase different capabilities rather than duplicates.96- Use triple-quoted strings for multi-line instructions.97- Scope capabilities for performance and least privilege.98- Do not include broad capabilities just because they exist.99100## Gotchas101102- **Agent names and namespace identifiers are different**: the display name may contain spaces, but the namespace must be a valid TypeSpec identifier.103- **Broad knowledge sources reduce quality**: scoped `WebSearch`, `OneDriveAndSharePoint`, `TeamsMessages`, and `Email` capabilities are usually better than unbounded access.104- **Conversation starters are examples, not tests**: they should be realistic user prompts and cover the agent's primary use cases.105106## Output template107108```markdown109## TypeSpec declarative agent110111**Status:** generated | needs input | blocked112**File:** `main.tsp`113**Agent name:** <display name>114**Namespace:** <TypeSpec namespace>115116### Capabilities117| Operation | AgentCapabilities type | Scope |118| --- | --- | --- |119| `<operation>` | `<CapabilityType>` | `<parameters or none>` |120121### Conversation starters122- `<title>` — `<text>`123124### Validation125- Name length: <pass/fail>126- Description length: <pass/fail>127- Instructions length: <pass/fail>128```129130## Quality gate131132- [ ] `main.tsp` includes the three required imports and two required `using` statements.133- [ ] `@agent` has a descriptive name no longer than 100 characters and description no longer than 1,000 characters.134- [ ] `@instructions` defines role, expertise, personality, allowed behavior, and limits in fewer than 8,000 characters.135- [ ] The file includes 2-4 diverse `@conversationStarter` decorators.136- [ ] Capabilities are limited to actual user needs and scoped when possible.137- [ ] The namespace is a valid TypeSpec identifier.