К основному содержанию
скилл CX Codex

copilot-sdk · intellectronica — скилл для Claude Code: работа с GitHub Copilot SDK

Подсказывает агенту, как правильно работать с GitHub Copilot SDK: установка, авторизация, разрешения, события и сессии на пяти языках.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add intellectronica/agent-skills --skill copilot-sdk -a claude-code
Открыть на GitHub

Что делает copilot-sdk

Скилл добавляет агенту справочник по GitHub Copilot SDK — публичному превью, которое выставляет рантайм Copilot CLI наружу через JSON-RPC. Схема простая: приложение обращается к клиенту SDK, тот шлёт JSON-RPC в Copilot CLI. Внутри — навигация по официальной документации и README для Node.js/TypeScript, Python, Go, .NET и Java, чтобы агент не сочинял поведение по памяти.

Отдельно разобраны авторизация и разрешения. Модель разрешений — deny-by-default, поэтому в сценариях создания и возобновления сессии нужен явный обработчик: approveAll в TypeScript, PermissionHandler.approve_all в Python, PermissionHandler.ApproveAll в Go и .NET, PermissionHandler.APPROVE_ALL в Java. Для очистки сессии используется disconnect(), а не устаревший destroy(). Чтобы сессию можно было надёжно возобновить, свой sessionId задают при создании, а конфигурацию BYOK при возобновлении передают заново — ключи не сохраняются.

Для обычной работы нужна подписка GitHub Copilot. BYOK её не требует. Node.js, Python и .NET кладут Copilot CLI в комплект, Go умеет брать установленный CLI или встраивать свой через go tool bundler, а Java ждёт отдельно установленный CLI. Транспорт по умолчанию — stdio с процессом CLI под управлением SDK; к внешнему headless-серверу подключаются через cliUrl. Список моделей лучше не хардкодить: есть client.listModels().

Какие задачи решает

  • поднять клиент Copilot SDK и открыть сессию с обработчиком разрешений
  • разобраться, почему сессия не возобновляется после перезапуска
  • подключиться к внешнему headless-серверу Copilot CLI через cliUrl
  • настроить BYOK с короткоживущими токенами Azure вместо статичных ключей
  • выбрать способ установки CLI: локальный, встроенный или серверный

Примеры запросов агенту

  • помоги настроить GitHub Copilot SDK на Python: клиент, сессия, обработчик разрешений
  • почему при возобновлении сессии теряется конфигурация BYOK и как это обойти
  • покажи, как подключиться к Copilot CLI в headless-режиме через cliUrl

Как установить copilot-sdk

1Через Skills CLI (Vercel)

npx skills add intellectronica/agent-skills --skill copilot-sdk -a claude-code

2Вручную: положить файлы

~/.claude/skills/copilot-sdk/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/copilot-sdk/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о copilot-sdk

Как установить copilot-sdk в Claude?

Выполните npx skills add intellectronica/agent-skills --skill copilot-sdk -a claude-code. Скилл окажется в ~/.claude/skills/copilot-sdk/SKILL.md.

Что делает скилл copilot-sdk?

Даёт агенту актуальную справку по GitHub Copilot SDK: установка, авторизация, разрешения, потоковые события, свои инструменты и агенты, MCP-серверы, хуки и сохранение сессий.

Нужна ли подписка GitHub Copilot для работы с SDK?

Для обычного использования — да. Режим BYOK подписку не требует: ключи провайдера передаются напрямую, а при возобновлении сессии их нужно указать снова.

Исходный текст

SKILL.md · CC0-1.0
---
name: copilot-sdk
description: This skill helps with GitHub Copilot SDK work across Node.js/TypeScript, Python, Go, .NET, and Java. It covers setup, authentication, permissions, streaming events, custom tools, custom agents, MCP servers, hooks, skills, and session persistence.
---

# GitHub Copilot SDK

## Overview

The GitHub Copilot SDK exposes the same Copilot CLI agent runtime over JSON-RPC, so apps can drive Copilot programmatically instead of building their own orchestration layer.

**Status:** Public preview  
**SDKs:** Node.js/TypeScript, Python, Go, .NET, Java  
**Architecture:** Application -> SDK client -> JSON-RPC -> Copilot CLI

## How to use this skill

When helping with the Copilot SDK:

1. Prefer the official docs index and the language-specific README over memory.
2. Treat the top-level SDK README plus `docs/` as the source of truth for shared behavior.
3. Call out preview status when stability or breaking changes matter.
4. Avoid hardcoding model lists when runtime discovery via `listModels()` is available.
5. Watch for stale guidance around permissions, lifecycle methods, and event names.

## Current source of truth

### Core SDK docs

- [GitHub Copilot SDK repository](https://github.com/github/copilot-sdk)
- [Documentation index](https://github.com/github/copilot-sdk/blob/main/docs/index.md)
- [Getting started guide](https://github.com/github/copilot-sdk/blob/main/docs/getting-started.md)
- [Setup guides](https://github.com/github/copilot-sdk/blob/main/docs/setup/index.md)
- [Local CLI setup](https://github.com/github/copilot-sdk/blob/main/docs/setup/local-cli.md)
- [Bundled CLI setup](https://github.com/github/copilot-sdk/blob/main/docs/setup/bundled-cli.md)
- [Backend services setup](https://github.com/github/copilot-sdk/blob/main/docs/setup/backend-services.md)
- [Scaling and multi-tenancy](https://github.com/github/copilot-sdk/blob/main/docs/setup/scaling.md)
- [Azure Managed Identity with BYOK](https://github.com/github/copilot-sdk/blob/main/docs/setup/azure-managed-identity.md)
- [Authentication](https://github.com/github/copilot-sdk/blob/main/docs/auth/index.md)
- [BYOK](https://github.com/github/copilot-sdk/blob/main/docs/auth/byok.md)
- [Features index](https://github.com/github/copilot-sdk/blob/main/docs/features/index.md)
- [Image input](https://github.com/github/copilot-sdk/blob/main/docs/features/image-input.md)
- [Steering and queueing](https://github.com/github/copilot-sdk/blob/main/docs/features/steering-and-queueing.md)
- [OpenTelemetry instrumentation](https://github.com/github/copilot-sdk/blob/main/docs/observability/opentelemetry.md)
- [Troubleshooting](https://github.com/github/copilot-sdk/blob/main/docs/troubleshooting/debugging.md)
- [SDK/CLI compatibility](https://github.com/github/copilot-sdk/blob/main/docs/troubleshooting/compatibility.md)

### Language-specific docs

- [Node.js / TypeScript README](https://github.com/github/copilot-sdk/blob/main/nodejs/README.md)
- [Python README](https://github.com/github/copilot-sdk/blob/main/python/README.md)
- [Go README](https://github.com/github/copilot-sdk/blob/main/go/README.md)
- [.NET README](https://github.com/github/copilot-sdk/blob/main/dotnet/README.md)
- [Java SDK repository](https://github.com/github/copilot-sdk-java)

### Copilot CLI and GitHub Docs

- [About GitHub Copilot CLI](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli)
- [Using GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli)
- [Custom agents configuration reference](https://docs.github.com/en/copilot/reference/custom-agents-configuration)
- [Enhancing agent mode with MCP](https://docs.github.com/en/copilot/tutorials/enhance-agent-mode-with-mcp)
- [Supported models](https://docs.github.com/en/copilot/reference/ai-models/supported-models)

### Recipes and examples

- [Copilot SDK cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/README.md)
- [Node.js samples](https://github.com/github/copilot-sdk/tree/main/nodejs/samples)
- [Go samples](https://github.com/github/copilot-sdk/tree/main/go/samples)
- [.NET samples](https://github.com/github/copilot-sdk/tree/main/dotnet/samples)

---

## High-value facts

### Authentication and prerequisites

- A GitHub Copilot subscription is required for normal SDK use.
- BYOK is supported and does **not** require GitHub Copilot authentication.
- Node.js, Python, and .NET bundle the Copilot CLI automatically.
- Go can use an installed CLI or embed/bundle one with the `go tool bundler` workflow.
- Java currently lives in `github/copilot-sdk-java` and expects the CLI to be installed separately.
- Azure Managed Identity / Entra auth is supported as a documented BYOK pattern by passing short-lived bearer tokens from `DefaultAzureCredential`.

### Permissions

- The SDK uses a deny-by-default permission model.
- In practice, create/resume flows should provide an explicit permission handler such as:
  - TypeScript: `approveAll`
  - Python: `PermissionHandler.approve_all`
  - Go: `copilot.PermissionHandler.ApproveAll`
  - .NET: `PermissionHandler.ApproveAll`
  - Java: `PermissionHandler.APPROVE_ALL`

### Session lifecycle

- Preferred cleanup method: `disconnect()`
- Deprecated cleanup method: `destroy()`
- To resume sessions reliably, provide your own `sessionId` when creating them.
- BYOK provider configuration must be provided again when resuming because keys are not persisted.

### Transport and deployment

- Default transport is stdio with an SDK-managed CLI process.
- You can connect to an external headless CLI server via `cliUrl`.
- Current external server docs use:

```bash
copilot --headless --port 4321
```

### Models

- Do not hardcode model support unless the user specifically needs a fixed list.
- Prefer `client.listModels()` and the official supported-models page.
- `reasoningEffort` exists for models that support it.

---

## Installation

| SDK | Install |
| --- | --- |
| Node.js / TypeScript | `npm install @github/copilot-sdk` |
| Python | `pip install github-copilot-sdk` |
| Go | `go get github.com/github/copilot-sdk/go` |
| .NET | `dotnet add package GitHub.Copilot.SDK` |
| Java | Maven/Gradle package `com.github:copilot-sdk-java` |

## Setup and deployment choices

Pick the setup that matches the application shape:

- **Local CLI** - simplest path for personal tools and development.
- **Bundled CLI** - ship a CLI binary with your app for desktop/distributable tooling.
- **Backend services** - run the CLI in headless mode and connect with `cliUrl`.
- **Scaling and multi-tenancy** - shared CLI vs CLI-per-user, shared storage, and session locking.
- **Azure Managed Identity** - use BYOK with short-lived bearer tokens instead of static API keys when Azure auth is the real requirement.

## Quick start pattern

Use the same mental model in every language:

1. Create/start the client.
2. Create a session with a permission handler.
3. Register event handlers before `send()` if you need streaming or progress.
4. Send with `send()` or `sendAndWait()`.
5. Wait for `session.idle` or the returned final message.
6. `disconnect()` the session and stop/dispose the client.

### TypeScript example

```typescript
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
await client.start();

const session = await client.createSession({
  model: "gpt-5",
  streaming: true,
  onPermissionRequest: approveAll,
});

session.on("assistant.message_delta", (event) => {
  process.stdout.write(event.data.deltaContent ?? "");
});

await session.sendAndWait({ prompt: "What is 2+2?" });

await session.disconnect();
await client.stop();
```

---

## Core capabilities to remember

### Client and session APIs

Common operations across SDKs:

- Client lifecycle: `start()`, `stop()`, `forceStop()`
- Session lifecycle: `createSession()`, `resumeSession()`, `disconnect()`
- Messaging: `send()`, `sendAndWait()`, `abort()`, `getMessages()`
- Discovery: `listModels()`, `listSessions()`, `getStatus()` / `ping()`

### Events and streaming

- Final assistant output arrives in `assistant.message`.
- Streaming text arrives in `assistant.message_delta`.
- `session.idle` is the reliable "turn complete" signal.
- The event system now includes reasoning, tool progress, permission, elicitation, sub-agent, and skill events.

See `references/event-system.md`.

### Custom tools

- Node uses `defineTool(...)` with Zod or raw JSON Schema.
- Python uses `@define_tool` with Pydantic models.
- Go prefers `DefineTool(...)`.
- .NET uses `AIFunctionFactory.Create(...)`.
- Overriding built-ins always requires explicit opt-in:
  - TypeScript: `overridesBuiltInTool: true`
  - Python: `overrides_built_in_tool=True`
  - Go: `OverridesBuiltInTool = true`
  - .NET: `AdditionalProperties["is_override"] = true`
- Custom tools can also opt into `skipPermission`.

### Custom agents, MCP, hooks, and skills

- `customAgents` lets you define sub-agents per session.
- `mcpServers` attaches local or remote MCP servers.
- Hooks provide control points such as `onPreToolUse`, `onPostToolUse`, `onUserPromptSubmitted`, and lifecycle/error hooks.
- Skills are loaded with `skillDirectories`; disable selectively with `disabledSkills`.

See `references/cli-agents-mcp.md`.

### Attachments, commands, and interaction

- Sessions can send file, directory, and image attachments.
- Image input supports both file and blob attachments, and vision should be checked through model capabilities.
- In-flight messaging supports `mode: "immediate"` for steering and `mode: "enqueue"` for queueing.
- The SDK can register custom slash `commands`.
- Apps can answer user questions with `onUserInputRequest`.
- Rich UI prompts are available through elicitation handlers and `session.ui` when the connected client supports them.

### Telemetry and observability

- The SDK supports OpenTelemetry configuration through `TelemetryConfig`.
- Trace context propagation is built in, with Node using an explicit `onGetTraceContext` callback for outbound propagation.

### Persistence and long-running work

- Use a stable `sessionId` for resumable sessions.
- Use `infiniteSessions` for long-running workflows that may need compaction.
- Session state is stored under `~/.copilot/session-state/` unless configuration overrides it.

### SDK vs. CLI-only features

- The SDK exposes programmatic surfaces for sessions, models, plans, mode switching, workspace files, custom agents, hooks, MCP, skills, and telemetry.
- Many terminal UX features remain CLI-only, such as most slash-command workflows, interactive pickers, and export/share commands.
- When translating a CLI workflow into app code, check the compatibility guide before assuming a slash command has an SDK equivalent.

---

## Language conventions

| Concept | TypeScript | Python | Go | .NET | Java |
| --- | --- | --- | --- | --- | --- |
| Create session | `createSession()` | `create_session()` | `CreateSession()` | `CreateSessionAsync()` | `createSession()` |
| Resume session | `resumeSession()` | `resume_session()` | `ResumeSession()` | `ResumeSessionAsync()` | `resumeSession()` |
| Final content | `event.data.content` | `event.data.content` | `*event.Data.Content` | `evt.Data.Content` | `event.getData().content()` |
| Delta content | `event.data.deltaContent` | `event.data.delta_content` | `*event.Data.DeltaContent` | `evt.Data.DeltaContent` | `event.getData().deltaContent()` |
| Skills field | `skillDirectories` | `skill_directories` | `SkillDirectories` | `SkillDirectories` | `setSkillDirectories(...)` |

---

## Common gotchas

- The SDK is **public preview**, so older examples drift quickly.
- Hardcoded model tables get stale; prefer runtime discovery.
- `destroy()` still appears in older examples but `disconnect()` is the current method.
- A missing permission handler causes confusion fast; treat it as required for real sessions.
- `assistant.message` and `assistant.message_delta` use `event.data.*`, not top-level `event.content`.
- Streaming/event subscriptions should be attached before `send()`.
- Session resumption without a caller-provided `sessionId` is awkward to operationalize.

---

## Local reference files in this skill

- `references/working-examples.md` - current starter examples, including tools and resume patterns
- `references/event-system.md` - event names, lifecycle, and language access patterns
- `references/cli-agents-mcp.md` - custom agents, skills, MCP, headless CLI, and config locations
- `references/troubleshooting.md` - common failures, debug logging, auth, permissions, and transport issues

© intellectronica · CC0-1.0 · intellectronica/agent-skills

Похожие скиллы

Все скиллы по теме «Настройка агента: память, контекст, субагенты» →

Сначала — copilot-sdk от других авторов.

copilot-sdk официальный github Скилл помогает встраивать агентные сценарии GitHub Copilot в приложения, добавлять свои инструменты и получать ответы потоком. Подойдёт для программируемых агентов. 9 395установок copilot-sdk microsoft Помогает создавать приложения на базе GitHub Copilot SDK для Node.js, Python, Go и .NET. Пригодится для программной интеграции Copilot в бэкенд или CLI-инструменты. 76установок mcp-copilot-studio-server-generator официальный github Генерирует MCP-сервер и файлы Power Platform для интеграции с Copilot Studio. Нужен при создании custom connector со streamable HTTP. 8 700установок copilot-sdk-java официальный github Правило подсказывает Copilot, как писать Java-приложения на GitHub Copilot SDK: инициализация клиента, сессии, асинхронные вызовы. ★ 40 418звёзд репо cline-sdk cline Скилл помогает писать агентов на базе Cline SDK: выбирать между Agent и ClineCore, настраивать инструменты и подписываться на события. CX Codex +1 4 700установок sentry-node-sdk getsentry Скилл сканирует проект и ведёт по шагам подключения Sentry к серверному JavaScript и TypeScript: ошибки, трейсинг, логи, кроны. CX Codex +1 3 300установок weixin-agent-sdk reason-machines Скилл подключает любой ИИ-бэкенд к WeChat через TypeScript-фреймворк weixin-agent-sdk: вход по QR-коду и цикл приёма сообщений. CX Codex +1 1 100установок mcp-developer https://github.com/Jeffallan Скилл для сборки и отладки MCP-серверов и клиентов на TypeScript или Python: схемы инструментов, транспорт, проверка протокола в инспекторе. CX Codex +1 4 200установок

Из того же набора20

promptify Превращает краткие запросы пользователя в строгие markdown-спецификации для нейросетей без лишней вежливости и вступительных комментариев. CX Codex +1 643установок tavily Находит данные в сети, извлекает текст со страниц, строит карту сайта и запускает глубокие исследования через REST API Tavily. CX Codex +1 627установок mgrep-code-search Скилл подключает семантический поиск по кодовой базе через утилиту mgrep. Он находит нужные места по смысловому описанию задачи, если в проекте больше 30 файлов. CX Codex +1 620установок gpt-image-1-5 Генерирует и редактирует изображения через модель GPT Image 1.5 от OpenAI. Пригодится для создания графики по описанию, замены фона и точечного инпейнтинга по маске. CX Codex +1 615установок here-be-git Разворачивает git в текущей папке, добавляет инструкции для агента о коммитах и настраивает .gitignore. CX Codex +1 527установок ray-so-code-snippet Скилл делает из фрагмента кода аккуратную картинку через ray.so и сохраняет её в текущую папку. Пригодится, когда нужно показать код в чате или посте. CX Codex +1 518установок lorem-ipsum Генерирует текст-рыбу через готовый Python-скрипт с точным контролем структуры, длины и формата. Помогает наполнить макеты интерфейсов или тестовые документы реалистичным контентом. CX Codex +1 511установок upstash-redis-kv Скилл для работы с базой Upstash Redis через REST API. Позволяет читать и записывать ключи, списки, хэши и множества прямо из чата с агентом. CX Codex +1 469установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой