copilot-sdk

A set of instructions for integrating GitHub Copilot into an application through its software development kit, or SDK. It covers AI chat sessions, streamed responses, tool calls, conversation state, and approval steps.

In plain words
What is it for?
Use it when adding Copilot chat, streaming output, function-calling tools, conversation management, or user approval to an application.
Why use it?
It provides patterns for connecting an app to Copilot and handling responses and actions without designing the integration from scratch.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/macromania/agentop/copilot-sdk
Any agent
npx skills add macromania/agentop --skill copilot-sdk
Clone the repo
git clone --depth 1 https://github.com/macromania/agentop

Made for: Claude Code, Codex.

Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,261 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00064 $0.04261
Opus 5 $0.00032 $0.02131
Sonnet 5 $0.00013 $0.00852
Haiku 4.5 $0.00006 $0.00426

Measured 2d ago against content hash 4c5370ce7914, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

copilot-sdk scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

import { exec } from 'child_process';
.github/skills/copilot-sdk/SKILL.md · 730 lines

How it starts

The opening of the file, as written. The whole thing — 730 lines — stays where its author put it; the contents beside it link to each section on GitHub.

GitHub Copilot SDK Integration

Integrate @github/copilot-sdk for AI-powered agent sessions with streaming responses and tool calling.

When to Use This Skill

  • Setting up Copilot SDK in Electron main process
  • Implementing streaming chat completions
  • Defining tools for agent function calling
  • Managing conversation context
  • Handling tool execution results
  • Building decision points with user approval

SDK Setup

Installation and Authentication

// src/main/copilot/client.ts
import { CopilotClient } from '@github/copilot-sdk';

let client: CopilotClient | null = null;

export async function initializeCopilotClient(): Promise<CopilotClient> {
  if (client) return client;

  // The SDK handles GitHub authentication automatically
  // User must be authenticated with GitHub Copilot
  client = new CopilotClient({
    // Optional: Custom endpoint for GitHub Enterprise
    // baseUrl: 'https://api.github.com',
  });

  return client;
}

export function getCopilotClient(): CopilotClient {
  if (!client) {
    throw new Error('Copilot client not initialized. Call initializeCopilotClient first.');
  }
  return client;
}

Tool Definitions

// src/main/copilot/tools.ts
import type { Tool, ToolResult } from '@github/copilot-sdk';

// Define tools the agent can use
export const agentTools: Tool[] = [
  {
    name: 'create_file',
    description: 'Create a new file with the specified content',
    parameters: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'The file path relative to the project root',
        },
        content: {
          type: 'string',
          description: 'The content to write to the file',
        },
      },
      required: ['path', 'content'],
    },
  },
  {
    name: 'edit_file',
    description: 'Edit an existing file by replacing content',
    parameters: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'The file path relative to the project root',
        },
        search: {
          type: 'string',
          description: 'The exact text to find and replace',
        },
        replace: {
          type: 'string',
          description: 'The replacement text',
        },
      },
      required: ['path', 'search', 'replace'],
    },
  },
  {
    name: 'run_command',
    description: 'Execute a shell command in the project directory',
    parameters: {
      type: 'object',
      properties: {
        command: {
          type: 'string',
          description: 'The shell command to execute',
        },
        cwd: {
          type: 'string',
          description: 'Working directory (optional)',
        },
      },
      required: ['command'],
    },
  },
  {
    name: 'read_file',
    description: 'Read the contents of a file',
    parameters: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'The file path to read',
        },
      },
      required: ['path'],
    },
  },
  {
    name: 'request_approval',
    description: 'Request user approval before proceeding with a sensitive action',
    parameters: {
      type: 'object',
      properties: {
        action: {
          type: 'string',
          description: 'Description of the action requiring approval',
        },
        details: {
          type: 'string',
          description: 'Detailed explanation of what will happen',
        },
        risk_level: {
          type: 'string',
          enum: ['low', 'medium', 'high'],
          description: 'Risk level of the action',
        },
      },
      required: ['action', 'details'],
    },
  },
];

Read the full file on GitHub · 730 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 730 lines · 64 tokens per session scan A 4c5370ce7914

Subscribe to this mod's changes

copilot-sdk is a skill published in the GitHub repository macromania/agentop (10 stars, last pushed 5mo ago), licensed MIT. It adds 64 tokens to every session and 4,261 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.