Copilot CLI

GitHub Copilot CLI puts an agentic coding assistant in the terminal: interactive sessions, one-shot -p prompts, and Issue / PR workflows. Official pages:

You need a valid Copilot entitlement. If an org disabled the CLI, sign-in alone will not help. Commands, slash verbs, and package names follow copilot help / /help on the day you install.


Requirements

PlatformNotes
WindowsGitHub requires PowerShell 6+ (PowerShell 7 recommended). WinGet id GitHub.Copilot
macOS / LinuxHomebrew cask or the official install script
npm (all platforms)Node.js 22+, package @github/copilot

In PowerShell 7:

$PSVersionTable.PSVersion
node -v

macOS:

node -v

Install

npm (all platforms, Node 22+):

npm install -g @github/copilot

If ~/.npmrc has ignore-scripts=true, GitHub requires:

npm_config_ignore_scripts=false npm install -g @github/copilot

Windows (WinGet):

winget install GitHub.Copilot

macOS / Linux (Homebrew):

brew install --cask copilot-cli

macOS / Linux (script):

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

Use | sudo bash to install into /usr/local/bin. Custom prefix: PREFIX. Pin a version: VERSION. You can also download binaries from github/copilot-cli releases.

Verify:

copilot --version

If Windows cannot find the command, open a new terminal and confirm WinGet’s shim directory is on PATH.


First interactive session

Start inside the project directory so the CLI can see the repo:

cd path/to/your-repo
copilot
  1. If you are not logged in, run /login and finish device / browser GitHub auth.
  2. Confirm you trust the current directory for an AI tool. GitHub notes Copilot will not change files without explicit approval.
  3. Try: Give me an overview of this project.

You may instead export a fine-grained PAT with Copilot Requests, using COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN (that precedence). Never commit the token.


Shortcuts and slash commands

From the getting-started guide:

KeyAction
EscCancel the current operation
Ctrl+CCancel if thinking; otherwise clear input or exit
Ctrl+LClear the screen
@Mention files for context
/Slash commands
?Tabbed help
/ History

Full list: /help in a session, or copilot help in the shell. Docs also mention /plan, /pr, /fleet, /research—trust help for your CLI version, not a memorized list.


Non-interactive: -p and scripts

Skip the TUI (good for scripts):

copilot -p "In Git, how can I apply a commit from another branch"

Response only, without extra usage chrome:

copilot -sp "List the test command quoted from this repo's package.json. Do not invent scripts."

More flags: copilot help. For GitHub Actions, follow Running GitHub Copilot CLI programmatically and Using Copilot CLI in GitHub Actions with GITHUB_TOKEN. Do not print a personal PAT in workflow logs.


How it splits with the IDE / Cursor

  • CLI: SSH, CI, keyboard-only, or terminal GitHub flows such as /pr
  • VS Code Chat: watching diffs and clicking files
  • Cursor: AI-native editor—see comparison

You can install Copilot CLI and Cursor’s agent on the same machine; do not let two agents write the same workspace without commits—the merge pain is yours. On Windows, set the default terminal to PowerShell 7 so the CLI does not land in Windows PowerShell 5.1.


Next

评论