copilot-sdk

Build applications that programmatically interact with GitHub Copilot via the Copilot SDK.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/lettucebo/Skills --skill copilot-sdk-lettucebo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: copilot-sdk
Source: https://github.com/lettucebo/Skills/tree/main/skills/microsoft/copilot-sdk
Command: npx skills add https://github.com/lettucebo/Skills --skill copilot-sdk-lettucebo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers who want to embed GitHub Copilot's agentic capabilities into their own applications lack a structured way to manage sessions, tools, and model providers programmatically. This Skill provides the patterns and API references needed to integrate Copilot into Node.js, Python, Go, or .NET applications without reverse-engineering the CLI. ## Core Features & Use Cases - Session Management: Create, resume, and persist sessions with custom IDs, streaming responses, and infinite-session auto-compaction for long-running workflows. - Extensibility: Define custom tools, lifecycle hooks (pre/post tool use, prompt submission, error handling), custom agents, and connect MCP servers over stdio or HTTP. - Flexible Authentication & BYOK: Use GitHub tokens, OAuth apps, or bring your own keys for OpenAI, Azure OpenAI, Anthropic, or local Ollama providers without a Copilot subscription. - Use Case: Build a multi-tenant SaaS backend that runs a headless Copilot CLI server over TCP, isolates sessions per tenant, enforces tool permissions via hooks, and tracks token usage through events. ## Quick Start Ask the agent to create a Node.js script using the Copilot SDK that starts a session with the gpt-4.1 model, registers a custom weather tool, and prints the streamed response.

Frequently Asked Questions about copilot-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the GitHub Copilot SDK in Node.js?▼

Install @github/copilot-sdk, create a CopilotClient, then call createSession with a model like gpt-4.1 and use sendAndWait to send prompts. The SDK spawns the Copilot CLI as a subprocess and communicates over JSON-RPC via stdio.

Can I use the Copilot SDK without a GitHub Copilot subscription?▼

Yes, through BYOK (Bring Your Own Key). Configure a provider for OpenAI, Azure OpenAI, Anthropic, or a local Ollama endpoint with your own API key, and the CLI acts only as the agent runtime.

Does the Copilot SDK support Python, Go, and .NET?▼

Yes. Python uses the github-copilot-sdk package, Go uses github.com/github/copilot-sdk/go, and .NET uses the GitHub.Copilot.SDK NuGet package. All follow the same client-session-message pattern.

How do I resume a Copilot SDK session after restart?▼

Create the session with an explicit sessionId, then call resumeSession with that ID later, even from a different client instance. Conversation history and tool results persist in ~/.copilot/session-state/, but provider credentials must be re-supplied.

Why are my MCP server tools not appearing in a session?▼

The MCP server may not be initialized or tools may not be enabled. Set tools to ["*"] in the server config, verify the server responds to tools/list, and test it independently with the MCP Inspector before integrating.

What are the limitations of BYOK in the Copilot SDK?▼

BYOK supports only static credentials with no native Entra ID or managed identity integration. Tokens are not auto-refreshed, keys are not persisted across session resumes, and available models are limited to what your provider offers.