Building Module 6 · CLI Tools Setup

GitHub Copilot CLI

Install GitHub's AI assistant for the command line

What is GitHub Copilot CLI?

GitHub Copilot started as an autocomplete tool inside code editors (VS Code, JetBrains). GitHub Copilot CLI extends that intelligence to your terminal, helping you build, explain, and fix things from the command line.

Key features:

  • Tight integration with the GitHub ecosystem
  • Code generation and project scaffolding
  • Command suggestion and explanation
  • Works alongside your existing Copilot subscription
  • Built on OpenAI models, fine-tuned by GitHub

Prerequisites

GitHub Copilot CLI requires GitHub Copilot access — available to GitHub users with a Copilot subscription, verified students, and popular open-source maintainers.

If you don’t have Copilot access, skip this lesson — the other tools are more than enough to get started.

Installation

Step 1: Install the GitHub CLI

Copilot CLI is an extension of the GitHub CLI (gh). Install it first:

Terminal window
# macOS (Homebrew)
brew install gh
# Linux / Ubuntu / WSL (Debian/Ubuntu)
sudo apt install gh
# Or install via conda (useful on HPC/remote servers)
conda install gh --channel conda-forge

Step 2: Authenticate with GitHub

Terminal window
gh auth login

Follow the prompts to log in with your GitHub account. If you’re on a remote server without a browser, select the “Paste an authentication token” option and generate a token at github.com/settings/tokens. Or use the device flow — gh will show you a URL and code to enter on any browser.

Step 3: Install the Copilot extension

Terminal window
gh extension install github/gh-copilot

Step 4: Verify

Terminal window
gh copilot --help

How Copilot CLI works

Copilot CLI has a different interaction model than the other tools. Instead of opening a persistent session, you give it one-off commands:

Suggest a command

Terminal window
gh copilot suggest "find all JavaScript files modified in the last week"

Copilot will suggest the right terminal command:

Terminal window
find . -name "*.js" -mtime -7

Explain a command

Terminal window
gh copilot explain "tar -xzf archive.tar.gz"

Copilot will explain what each part means:

  • tar — archive utility
  • -x — extract
  • -z — decompress gzip
  • -f — specify filename
💡Great for learning

The explain feature is incredibly useful when you encounter unfamiliar commands. Instead of Googling “what does chmod 755 mean,” just ask Copilot to explain it.

Your first interaction

Suggest mode

Terminal window
gh copilot suggest "create a new React project with TypeScript"

It will suggest the appropriate command (like npx create-react-app my-app --template typescript or npm create vite@latest my-app -- --template react-ts).

Get help with git

Terminal window
gh copilot suggest "undo my last commit but keep the changes"

It’ll suggest git reset --soft HEAD~1 and explain what it does.

Copilot CLI vs the other tools

AspectCopilot CLIClaude Code / Gemini / Codex
Interaction styleOne-off commandsPersistent conversation
File editingSuggest commands, you executeDirectly edits files
Best forCommand help, quick suggestionsBuilding, multi-file projects
AutonomyLow (suggests, you approve)High (can plan and execute)

Copilot CLI is more of a terminal assistant than a full autonomous agent. It’s excellent for:

  • Learning terminal commands
  • Getting command suggestions
  • Explaining unfamiliar commands
  • Quick, one-off tasks

For sustained building tasks (creating projects, editing multiple files, debugging), the other three tools are more capable.

Tips

  1. Use suggest when you know what you want but not the command. “List all running Docker containers” → docker ps.

  2. Use explain when you encounter unfamiliar commands. Especially useful for git commands, which can be cryptic.

  3. Combine with other tools. Use Copilot CLI for quick command lookups while using Claude Code or Gemini CLI for actual building.