MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

GitHub Copilot SDK C# Instructions

GitHub Copilot SDK C# Instructions是一款productivity方向的AI技能,核心价值是This file provides guidance on building C# applications using GitHub Copilot SDK,可用于解决开发者在productivity领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

This file provides guidance on building C# applications using GitHub Copilot SDK.

Last verified on: 2026-05-30
mkdir -p ./skills/copilot-sdk-csharp && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/copilot-sdk-csharp/SKILL.md -o ./skills/copilot-sdk-csharp/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

Core Principles


- The SDK is in technical preview and may have breaking changes

- Requires .NET 10.0 or later

- Requires GitHub Copilot CLI installed and in PATH

- Uses async/await patterns throughout

- Implements IAsyncDisposable for resource cleanup


Installation


Always install via NuGet:

bash
dotnet add package GitHub.Copilot.SDK

Client Initialization


Basic Client Setup


csharp
await using var client = new CopilotClient();
await client.StartAsync();

Client Configuration Options


When creating a CopilotClient, use `CopilotClientOptions`:


- `CliPath` - Path to CLI executable (default: "copilot" from PATH)

- `CliArgs` - Extra arguments prepended before SDK-managed flags

- `CliUrl` - URL of existing CLI server (e.g., "localhost:8080"). When provided, client won't spawn a process

- `Port` - Server port (default: 0 for random)

- `UseStdio` - Use stdio transport instead of TCP (default: true)

- `LogLevel` - Log level (default: "info")

- `AutoStart` - Auto-start server (default: true)

- `AutoRestart` - Auto-restart on crash (default: true)

- `Cwd` - Working directory for the CLI process

- `Environment` - Environment variables for the CLI process

- `Logger` - ILogger instance for SDK logging


Manual Server Control


For explicit control:

csharp
var client = new CopilotClient(new CopilotClientOptions { AutoStart = false });
await client.StartAsync();
// Use client...
await client.StopAsync();

Use `ForceStopAsync()` when `StopAsync()` takes too long.


Session Management


Creating Sessions


Use `SessionConfig` for configuration:


csharp
await using var session = await client.CreateSessionAsync(new SessionConfig
{
    OnPermissionRequest = PermissionHandler.ApproveAll,
    Model = "gpt-5",
    Streaming = true,
    Tools = [...],
    SystemMessage = new SystemMessageConfig { ... },
    AvailableTools = ["tool1", "tool2"],
    ExcludedTools = ["tool3"],
    Provider = new ProviderConfig { ... }
});

Session Config Options


- `SessionId` - Custom session ID

- `Model` - Model name ("gpt-5", "claude-sonnet-4.5", etc.)

- `Tools` - Custom tools exposed to the CLI

- `SystemMessage` - System message customization

- `AvailableTools` - Allowlist of tool names

- `ExcludedTools` - Blocklist of tool names

- `Provider` - Custom API provider configuration (BYOK)

- `Streaming` - Enable streaming response chunks (default: false)


Resuming Sessions


csharp
var session = await client.ResumeSessionAsync(sessionId, new ResumeSessionConfig
{
    OnPermissionRequest = PermissionHandler.ApproveAll,
    // ...
});

Session Operations


- `session.SessionId` - Get session identifier

- `session.SendAsync(new MessageOptions { Prompt = "...", Attachments = [...] })` - Send message

- `session.AbortAsync()` - Abort current processing

- `session.GetMessagesAsync()` - Get all events/messages

- `await session.DisposeAsync()` - Clean up resources


Event Handling


Event Subscription Pattern


ALWAYS use TaskCompletionSource for waiting on session events:


csharp
var done = new TaskCompletionSource();

session.On(evt =>
{
    if (evt is AssistantMessageEvent msg)
    {
        Console.WriteLine(msg.Data.Content);
    }
    else if (evt is SessionIdleEvent)
    {
        done.SetResult();
    }
});

await session.SendAsync(new MessageOptions { Prompt = "..." });
await done.Task;

Unsubscribing from Events


The `On()` method returns an IDisposable:


csharp
var subscription = session.On(evt => { /* handler */ });
// Later...
subscription.Dispose();

Event Types


Use pattern matching or switch expressions for event handling:


csharp
session.On(evt =>
{
    switch (evt)
    {
        case UserMessageEvent userMsg:
            // Handle user message
            break;
        case AssistantMessageEvent assistantMsg:
            Console.WriteLine(assistantMsg.Data.Content);
            break;
        case ToolExecutionStartEvent toolStart:
            // Tool execution s

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Knowledge workers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • Using GitHub Copilot SDK C# Instructions in daily workflow
  • Automating repetitive productivity tasks

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply GitHub Copilot SDK C# Instructions to Your Work

    Provide context for your task — paste source material, describe your audience, or share existing work to guide the AI.

  4. 4

    Review and Refine

    Edit the AI output for accuracy, tone, and completeness. Add human insight where the AI lacks context.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

How do I install GitHub Copilot SDK C# Instructions?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/copilot-sdk-csharp/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Not reading the full skill

Skills contain important context and edge cases beyond the quick start.

🔗 Related Skills