github

Building AI-powered GitHub issue triage with the Copilot SDK (opens in new tab)

The post demonstrates how to build IssueCrush, an AI-powered GitHub issue triage app using the GitHub Copilot SDK. The app presents issues as swipeable cards and uses Copilot to generate concise summaries and recommended actions. Because the SDK depends on Node.js and the Copilot CLI, the integration runs on a server rather than directly inside the React Native client.

IssueCrush: Faster Issue Triage

  • IssueCrush displays GitHub issues as swipeable cards:
    • Swipe left to close an issue.
    • Swipe right to keep it.
    • Use “Get AI Summary” to receive actionable context.
  • Copilot summarizes lengthy issue descriptions and suggests actions such as:
    • Investigate the problem.
    • Implement the request.
    • Assign it to a relevant team.
    • Close it as a duplicate.
  • The goal is to reduce the cognitive load of reviewing many issues across active repositories.

Server-Side Architecture

  • React Native cannot directly use the Node.js-based Copilot SDK.
  • The SDK launches a local Copilot CLI process and communicates with it through JSON-RPC.
  • The recommended architecture is:
    • React Native or web client communicates with a Node.js server over HTTPS.
    • The server runs the Copilot SDK and manages the Copilot CLI.
    • Clients separately use GitHub OAuth and the GitHub REST API for issue data.
  • Server-side integration provides:
    • A shared SDK instance for multiple clients.
    • Secure storage of Copilot credentials and API tokens.
    • Graceful fallback summaries when AI services are unavailable.
    • Centralized logging for latency, failures, prompts, and responses.

Required Setup

  • Install the Copilot CLI on the server and ensure it is on the system PATH.
  • Use either:
    • A GitHub Copilot subscription, or
    • A BYOK configuration with personal API keys.
  • Authenticate the CLI with copilot auth or the COPILOT_GITHUB_TOKEN environment variable.

Copilot SDK Lifecycle

The SDK uses a session-based workflow:

  • Import CopilotClient and approveAll.
  • Create and start a CopilotClient, which launches the CLI.
  • Create a session with a selected model such as gpt-4.1.
  • Send a prompt using session.sendAndWait().
  • Read the response from response.data.content.
  • Disconnect the session and stop the client.

The required lifecycle is:

start() → createSession() → sendAndWait() → disconnect() → stop()

Sessions should always be cleaned up in a finally block. Missing disconnect() calls can leak resources and cause memory issues, while suppressed cleanup errors prevent them from hiding the original failure.

Prompt Design for Triage

  • The prompt provides structured issue information instead of only passing raw text.
  • Context includes:
    • Title and issue number.
    • Repository name.
    • State and labels.
    • Creation date.
    • Author.
    • Full issue body.
  • The model is instructed to produce a concise two- or three-sentence summary that:
    • Explains the issue.
    • Identifies the key problem or request.
    • Recommends a practical next step.
  • The response should be clear, actionable, and free of Markdown formatting.

A server-side Copilot integration offers a practical way to add AI-assisted triage while keeping credentials secure, maintaining fallback behavior, and preserving reliable resource management.