Skip to content

sirluky/copilot-cli

Β 
Β 

Repository files navigation

GitHub Copilot CLI (Public Preview)

The power of GitHub Copilot, now in your terminal.

GitHub Copilot CLI brings AI-powered coding assistance directly to your command line, enabling you to build, debug, and understand code through natural language conversations. Powered by the same agentic harness as GitHub's Copilot coding agent, it provides intelligent assistance while staying deeply integrated with your GitHub workflow.

See our official documentation for more information.

Image of the splash screen for the Copilot CLI

πŸš€ Introduction and Overview

We're bringing the power of GitHub Copilot coding agent directly to your terminal. With GitHub Copilot CLI, you can work locally and synchronously with an AI agent that understands your code and GitHub context.

  • Terminal-native development: Work with Copilot coding agent directly in your command line β€” no context switching required.
  • GitHub integration out of the box: Access your repositories, issues, and pull requests using natural language, all authenticated with your existing GitHub account.
  • Agentic capabilities: Build, edit, debug, and refactor code with an AI collaborator that can plan and execute complex tasks.
  • MCP-powered extensibility: Take advantage of the fact that the coding agent ships with GitHub's MCP server by default and supports custom MCP servers to extend capabilities.
  • Full control: Preview every action before execution β€” nothing happens without your explicit approval.

We're still early in our journey, but with your feedback, we're rapidly iterating to make the GitHub Copilot CLI the best possible companion in your terminal.

πŸ“¦ Getting Started

Supported Platforms

  • Linux
  • macOS
  • Windows

Prerequisites

  • (On Windows) PowerShell v6 or higher
  • An active Copilot subscription. See Copilot plans.

If you have access to GitHub Copilot via your organization or enterprise, you cannot use GitHub Copilot CLI if your organization owner or enterprise administrator has disabled it in the organization or enterprise settings. See Managing policies and features for GitHub Copilot in your organization for more information.

Installation

Install with WinGet (Windows):

winget install GitHub.Copilot
winget install GitHub.Copilot.Prerelease

Install with Homebrew (macOS and Linux):

brew install copilot-cli
brew install copilot-cli@prerelease

Install with npm (macOS, Linux, and Windows):

npm install -g @github/copilot
npm install -g @github/copilot@prerelease

Install with the install script (macOS and Linux):

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

Or

wget -qO- https://gh.io/copilot-install | bash

Use | sudo bash to run as root and install to /usr/local/bin.

Set PREFIX to install to $PREFIX/bin/ directory. Defaults to /usr/local when run as root or $HOME/.local when run as a non-root user.

Set VERSION to install a specific version. Defaults to the latest version.

For example, to install version v0.0.369 to a custom directory:

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

Launching the CLI

copilot

On first launch, you'll be greeted with our adorable animated banner! If you'd like to see this banner again, launch copilot with the --banner flag.

If you're not currently logged in to GitHub, you'll be prompted to use the /login slash command. Enter this command and follow the on-screen instructions to authenticate.

Authenticate with a Personal Access Token (PAT)

You can also authenticate using a fine-grained PAT with the "Copilot Requests" permission enabled.

  1. Visit https://github.com/settings/personal-access-tokens/new
  2. Under "Permissions," click "add permissions" and select "Copilot Requests"
  3. Generate your token
  4. Add the token to your environment via the environment variable GH_TOKEN or GITHUB_TOKEN (in order of precedence)

Using the CLI

Launch copilot in a folder that contains code you want to work with.

By default, copilot utilizes Claude Sonnet 4.5. Run the /model slash command to choose from other available models, including Claude Sonnet 4 and GPT-5.

copilot-play (tmux wrapper - recommended)

This repo includes a tmux-based wrapper that runs Copilot CLI in a dedicated window alongside a game/visual in another window. When Copilot is busy working, it automatically switches to the game window. When Copilot is idle waiting for input, it switches back. This approach keeps both copilot and the game in full terminal space without any UI corruption.

Setup:

  1. Make scripts executable:
chmod +x copilot-tmux.sh tmux-controller.sh scripts/copilot-hook.sh
  1. Set the shared state file path:
export COPILOT_HOOKS_STATE="$HOME/.copilot/hooks-state.json"
  1. Install cmatrix (or set a different GAME_COMMAND):
# macOS
brew install cmatrix

# Ubuntu/Debian
sudo apt install cmatrix
  1. In the repo where you run Copilot, add .github/hooks/hooks.json:
{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": "/path/to/copilot-cli/scripts/copilot-hook.sh idle",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "userPromptSubmitted": [
      {
        "type": "command",
        "bash": "/path/to/copilot-cli/scripts/copilot-hook.sh busy",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "preToolUse": [
      {
        "type": "command",
        "bash": "/path/to/copilot-cli/scripts/copilot-hook.sh busy",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "postToolUse": [
      {
        "type": "command",
        "bash": "/path/to/copilot-cli/scripts/copilot-hook.sh busy",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "errorOccurred": [
      {
        "type": "command",
        "bash": "/path/to/copilot-cli/scripts/copilot-hook.sh idle",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "sessionEnd": [
      {
        "type": "command",
        "bash": "/path/to/copilot-cli/scripts/copilot-hook.sh idle",
        "cwd": ".",
        "timeoutSec": 5
      }
    ]
  }
}

Run:

npm run play:tmux -- --experimental

Or run directly:

./copilot-tmux.sh --experimental

Controls:

  • Auto-switches: Game view when busy β†’ Copilot view when idle
  • Manual toggle: Ctrl+G (or tmux prefix + 0/1)
  • Debug pane: Shows state changes at bottom of copilot window
  • Game: Continues running in background (no pause)

Configuration:

# Use a different visual/game
export GAME_COMMAND="asciiquarium"

# Custom state file
export COPILOT_HOOKS_STATE="/tmp/copilot-hooks.json"

copilot-play (TypeScript TUI wrapper - legacy)

A blessed-based wrapper that embeds copilot in a split UI. This can have UI issues due to embedding copilot's rich TUI inside a box. Use the tmux wrapper above for better compatibility.

Install and build:

npm install
npm run build

Run:

node dist/copilot-play.js

Pass Copilot CLI flags after --:

node dist/copilot-play.js -- --experimental

Override the hooks state file if needed:

node dist/copilot-play.js --state-file /tmp/copilot-hooks.json -- --experimental

Controls: arrows/WASD to move, Ctrl+G to toggle focus if detection is off, Ctrl+Q to quit.

Hooks-based busy/idle state (recommended)

  1. Make the hook script executable:
chmod +x scripts/copilot-hook.sh
  1. Set a shared state file path:
export COPILOT_HOOKS_STATE="$HOME/.copilot/hooks-state.json"
  1. In the repo where you run Copilot, add .github/hooks/hooks.json:
{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": "/path/to/copilot-hook.sh idle",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "userPromptSubmitted": [
      {
        "type": "command",
        "bash": "/path/to/copilot-hook.sh busy",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "preToolUse": [
      {
        "type": "command",
        "bash": "/path/to/copilot-hook.sh busy",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "postToolUse": [
      {
        "type": "command",
        "bash": "/path/to/copilot-hook.sh busy",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "errorOccurred": [
      {
        "type": "command",
        "bash": "/path/to/copilot-hook.sh idle",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "sessionEnd": [
      {
        "type": "command",
        "bash": "/path/to/copilot-hook.sh idle",
        "cwd": ".",
        "timeoutSec": 5
      }
    ]
  }
}

The hooks set busy when work starts, and the wrapper uses prompt detection to flip back to idle when Copilot is ready for your next input.

Experimental Mode

Experimental mode enables access to new features that are still in development. You can activate experimental mode by:

  • Launching with the --experimental flag: copilot --experimental
  • Using the /experimental slash command from within the CLI

Once activated, the setting is persisted in your config, so the --experimental flag is no longer needed on subsequent launches.

Experimental Features

  • Autopilot mode: Autopilot is a new mode (press Shift+Tab to cycle through modes), which encourages the agent to continue working until a task is completed.

Each time you submit a prompt to GitHub Copilot CLI, your monthly quota of premium requests is reduced by one. For information about premium requests, see About premium requests.

For more information about how to use the GitHub Copilot CLI, see our official documentation.

πŸ”§ Configuring LSP Servers

GitHub Copilot CLI supports Language Server Protocol (LSP) for enhanced code intelligence. This feature provides intelligent code features like go-to-definition, hover information, and diagnostics.

Installing Language Servers

Copilot CLI does not bundle LSP servers. You need to install them separately. For example, to set up TypeScript support:

npm install -g typescript-language-server

For other languages, install the corresponding LSP server and configure it following the same pattern shown below.

Configuring LSP Servers

LSP servers are configured through a dedicated LSP configuration file. You can configure LSP servers at the user level or repository level:

User-level configuration (applies to all projects): Edit ~/.copilot/lsp-config.json

Repository-level configuration (applies to specific project): Create .github/lsp.json in your repository root

Example configuration:

{
  "lspServers": {
    "typescript": {
      "command": "typescript-language-server",
      "args": ["--stdio"],
      "fileExtensions": {
        ".ts": "typescript",
        ".tsx": "typescript"
      }
    }
  }
}

Viewing LSP Server Status

Check configured LSP servers using the /lsp command in an interactive session, or view your configuration files directly.

For more information, see the changelog.

πŸ“’ Feedback and Participation

We're excited to have you join us early in the Copilot CLI journey.

This is an early-stage preview, and we're building quickly. Expect frequent updates--please keep your client up to date for the latest features and fixes!

Your insights are invaluable! Open issue in this repo, join Discussions, and run /feedback from the CLI to submit a confidential feedback survey!

About

GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 50.3%
  • Shell 49.7%