MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

GitHub Copilot SDK Node.js Instructions

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

This file provides guidance on building Node.js/TypeScript applications using GitHub Copilot SDK.

Last verified on: 2026-05-30
mkdir -p ./skills/copilot-sdk-nodejs && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/copilot-sdk-nodejs/SKILL.md -o ./skills/copilot-sdk-nodejs/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 Node.js 18.0 or later

- Requires GitHub Copilot CLI installed and in PATH

- Built with TypeScript for type safety

- Uses async/await patterns throughout

- Provides full TypeScript type definitions


Installation


Always install via npm/pnpm/yarn:


bash
npm install @github/copilot-sdk
# or
pnpm add @github/copilot-sdk
# or
yarn add @github/copilot-sdk

Client Initialization


Basic Client Setup


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

const client = new CopilotClient();
await client.start();
// Use client...
await client.stop();

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 (string[])

- `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: "debug")

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

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

- `cwd` - Working directory for the CLI process (default: process.cwd())

- `env` - Environment variables for the CLI process (default: process.env)


Manual Server Control


For explicit control:


typescript
const client = new CopilotClient({ autoStart: false });
await client.start();
// Use client...
await client.stop();

Use `forceStop()` when `stop()` takes too long.


Session Management


Creating Sessions


Use `SessionConfig` for configuration:


typescript
const session = await client.createSession({
    onPermissionRequest: approveAll,
    model: "gpt-5",
    streaming: true,
    tools: [...],
    systemMessage: { ... },
    availableTools: ["tool1", "tool2"],
    excludedTools: ["tool3"],
    provider: { ... }
});

Session Config Options


- `sessionId` - Custom session ID (string)

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

- `tools` - Custom tools exposed to the CLI (Tool[])

- `systemMessage` - System message customization (SystemMessageConfig)

- `availableTools` - Allowlist of tool names (string[])

- `excludedTools` - Blocklist of tool names (string[])

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

- `streaming` - Enable streaming response chunks (boolean)

- `mcpServers` - MCP server configurations (MCPServerConfig[])

- `customAgents` - Custom agent configurations (CustomAgentConfig[])

- `configDir` - Config directory override (string)

- `skillDirectories` - Skill directories (string[])

- `disabledSkills` - Disabled skills (string[])

- `onPermissionRequest` - Permission request handler (PermissionHandler)


Resuming Sessions


typescript
const session = await client.resumeSession("session-id", {
  tools: [myNewTool],
  onPermissionRequest: approveAll,
});

Session Operations


- `session.sessionId` - Get session identifier (string)

- `await session.send({ prompt: "...", attachments: [...] })` - Send message, returns Promise<string>

- `await session.sendAndWait({ prompt: "..." }, timeout)` - Send and wait for idle, returns Promise<AssistantMessageEvent | null>

- `await session.abort()` - Abort current processing

- `await session.getMessages()` - Get all events/messages, returns Promise<SessionEvent[]>

- `await session.destroy()` - Clean up session


Event Handling


Event Subscription Pattern


ALWAYS use async/await or Promises for waiting on session events:


typescript
await new Promise<void>((resolve) => {
  session.on((event) => {
    if (event.type === "assistant.message") {
      console.log(event.data.content);
    } else if (event.type === "session.idle") {
      resolve();
    }
  });

  session.send({ prompt: "..." });
});

Unsubscribing from

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • TypeScript type safety checking
  • Module refactoring

📖 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 Node.js Instructions to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

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

Is GitHub Copilot SDK Node.js Instructions compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for GitHub Copilot SDK Node.js Instructions?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install GitHub Copilot SDK Node.js Instructions?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/copilot-sdk-nodejs/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.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills