GitHub Copilot CLI Documentation

repository·main·Indexed 27 days ago

https://github.com/github/copilot-cli

A terminal-native AI coding assistant for building, debugging, and refactoring code using natural language. Features include MCP-powered extensibility, support for multiple models such as Claude Sonnet 4.5 and GPT-5, and Language Server Protocol (LSP) integration for enhanced code intelligence via user and repository-level configuration files.

Tokens
811
Snippets
4
Records
5
Agent score
45%

What's inside GitHub Copilot CLI

  1. Install GitHub Copilot CLI

    main

    You can install GitHub Copilot CLI using several methods depending on your operating system and preferred package manager.

    macOS and Linux

    Use the official install script:

    curl -fsSL https://gh.io/copilot-install | bash

    To install to a specific directory, set the PREFIX variable. To install a specific version, set the VERSION variable:

    curl -fsSL https://gh.io/copilot-install | VERSION="v0.0.369" PREFIX="$HOME/custom" bash

    Alternatively, use Homebrew:

    brew install copilot-cli
    # For prerelease
    brew install copilot-cli@prerelease

    Windows

    Use WinGet:

    winget install GitHub.Copilot
    # For prerelease
    winget install GitHub.Copilot.Prerelease

    Cross-platform (npm)

    Install globally via npm:

    npm install -g @github/copilot
    # For prerelease
    npm install -g @github/copilot@prerelease
    curl -fsSL https://gh.io/copilot-install | bash
  2. Enable Experimental Mode

    main

    Experimental mode provides access to features still in development, such as Autopilot mode (cycle through modes using Shift+Tab).

    You can activate it in two ways:

    1. Launch with the --experimental flag: copilot --experimental
    2. Use the /experimental slash command from within the CLI.

    Once activated via the slash command, the setting is persisted in your configuration.

    copilot --experimental
  3. Authenticate with GitHub Copilot CLI

    main

    Launch the CLI by running copilot. If you are not logged in, use the /login slash command within the interactive session to follow authentication instructions.

    Authenticate with a Personal Access Token (PAT)

    You can authenticate using a fine-grained PAT with the Copilot Requests permission enabled. Set the token in your environment using one of the following variables (in order of precedence):

    1. GH_TOKEN
    2. GITHUB_TOKEN
    copilot
  4. Configure LSP Servers for enhanced code intelligence

    main

    GitHub Copilot CLI supports the Language Server Protocol (LSP) to provide features like go-to-definition, hover information, and diagnostics. You must install the LSP servers separately (e.g., npm install -g typescript-language-server).

    Configuration Files

    • User-level configuration (all projects): ~/.copilot/lsp-config.json
    • Repository-level configuration (specific project): .github/lsp.json in the repository root.

    Configuration Schema

    Configure servers using the lspServers key. Example for TypeScript:

    {
      "lspServers": {
        "typescript": {
          "command": "typescript-language-server",
          "args": ["--stdio"],
          "fileExtensions": {
            ".ts": "typescript",
            ".tsx": "typescript"
          }
        }
      }
    }
    {
      "lspServers": {
        "typescript": {
          "command": "typescript-language-server",
          "args": ["--stdio"],
          "fileExtensions": {
            ".ts": "typescript",
            ".tsx": "typescript"
          }
        }
      }
    }
  5. Use GitHub Copilot CLI commands and models

    main

    Once the CLI is launched, you can interact with the agent using slash commands:

    • /login: Authenticate with your GitHub account.
    • /model: Choose from available models (e.g., Claude Sonnet 4.5, Claude Sonnet 4, or GPT-5).
    • /experimental: Activate experimental mode (persists in config).
    • /lsp: View the status of configured LSP servers.
    • /feedback: Submit a confidential feedback survey.

    Note: By default, the CLI uses Claude Sonnet 4.5.