Building Module 6 · CLI Tools Setup

GitHub Copilot CLI

What you'll learn

~15 min
  • Install the standalone Copilot CLI
  • Authenticate with your GitHub account
  • Run your first task in interactive mode
  • Understand programmatic mode and tool approval
Cloud Equivalent

Copilot in VS Code works inside GitHub Codespaces — get the full Copilot experience (autocomplete, chat, and CLI) without any local install. See the Cloud Sandbox Cheat Sheet for current pricing, or set up your sandbox.

By the end of this lesson, you’ll have the new standalone Copilot CLI installed and working — a full agentic coding tool comparable to Claude Code and Gemini CLI, not just a helper for looking up commands.

What is GitHub Copilot CLI?

GitHub Copilot CLI is GitHub’s standalone agentic AI tool for the terminal. It is a complete rewrite — the old gh copilot extension (with its suggest and explain commands) has been retired. The new Copilot CLI is a fully autonomous agent that reads your codebase, edits files, runs commands, and iterates on errors, just like Claude Code and Gemini CLI.

Key features:

  • Full agentic coding — reads, writes, and edits files across your project
  • Powered by Claude Sonnet 4.5 by default (changeable via /model)
  • Plan modeShift+Tab toggles structured planning before execution
  • Tool approval controls — fine-grained control over what the agent can do
  • MCP support — connects to external tools and services
  • Context management/compact to free up context, /context to see token usage
  • Deep GitHub integration — works seamlessly with Issues, PRs, and Actions
  • Free tier available — works with Copilot Free (no credit card required)

Prerequisites

💡Copilot Free — $0, no credit card

Copilot Free is available to anyone with a GitHub account at no cost. It includes CLI access, 2,000 code completions per month, and 50 chat messages per month. No credit card, no application, no waiting — just sign in. This makes Copilot CLI the lowest-barrier entry point of any AI CLI tool.

All you need is a GitHub account. If you don’t have one, create one at github.com — it’s free.

Copilot plans at a glance:

PlanPriceCLI AccessNotes
Copilot Free$0Yes50 chat messages/mo, 2,000 completions/mo
Copilot Pro$10/moYesUnlimited chat, more completions
Copilot Pro+$39/moYesPremium models, higher limits
Copilot Business$19/user/moYesOrg-managed, admin controls
Copilot Enterprise$39/user/moYesKnowledge bases, fine-tuning

Education access:

  • Students: Verified students get the Copilot Student plan free through the GitHub Student Developer Pack
  • Educators: Verified teachers and supervisors who teach may qualify for free Copilot Pro (unlimited usage)
  • Institutions: Free GitHub Enterprise is available through the GitHub Campus Program, but Enterprise access alone does not include Copilot licenses — those must be assigned separately
🧬In Your Field: Biotechclick to expand

UW-Madison staff: Copilot Free works immediately for anyone with a personal GitHub account — no institutional approval needed. If you teach or supervise students in your core facility, you may also qualify for the free educator Copilot Pro plan. Check with your GitHub Campus Program administrator about whether UW has Copilot Business licenses available through the institutional agreement.

Installation

The new Copilot CLI is a standalone tool — it does not require the GitHub CLI (gh). Choose whichever install method works for your system:

Terminal window
npm install -g @github/copilot

Option B: Homebrew (macOS / Linux)

Terminal window
brew install copilot-cli

Option C: winget (Windows native)

Terminal window
winget install GitHub.Copilot

Option D: Quick install script (macOS / Linux / WSL)

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

Verify the installation

Terminal window
copilot --version

You should see a version number. If you get “command not found,” restart your terminal and try again — the installer may have updated your PATH.

Authentication

First launch

Terminal window
copilot

On first launch, Copilot CLI will prompt you to authenticate. Run /login if prompted, or it will open the GitHub device flow automatically — you’ll see a URL and a one-time code to enter in your browser. This works even from remote servers over SSH.

Once authenticated, you’ll see the interactive prompt:

> copilot
Welcome to GitHub Copilot CLI!
Type your request, or /help for commands.

You’re in.

How Copilot CLI works

Copilot CLI operates in two modes: interactive and programmatic. Both are fully agentic — the tool reads your project, plans changes, edits files, and runs commands.

Interactive mode (default)

Terminal window
copilot

This opens a persistent session where you type requests, review the agent’s plan, and approve actions. It’s the mode you’ll use most often — just like using Claude Code or Gemini CLI interactively.

Programmatic mode

Terminal window
copilot -p "add error handling to all API routes"

The -p flag runs a single prompt non-interactively and exits. Useful for scripting, CI pipelines, or quick one-off tasks.

Your first interaction

Navigate to a project directory (or create one) and launch Copilot:

Terminal window
mkdir copilot-test && cd copilot-test
copilot

Try a simple request:

Create an index.html file with a "Hello World" page that has a centered heading and a dark background

Copilot will plan the task, create the file, and show you the result. Review the output and approve any file writes.

Plan mode

Press Shift+Tab to toggle plan mode. In plan mode, Copilot creates a structured plan for your request and waits for your approval before executing. This is especially useful for multi-step tasks where you want to review the strategy first.

Key commands

CommandWhat it does
/helpShow available commands
/modelSwitch the underlying AI model
/compactCompress conversation to free up context
/contextShow current token usage
/loginAuthenticate with GitHub
/clearClear the conversation
Shift+TabToggle plan mode

Tool approval

Copilot CLI asks for permission before running commands or writing files. You control this with flags:

Terminal window
# Allow specific tools
copilot --allow-tool='shell(git)'
# Allow all tools (no approval prompts — use with caution)
copilot --allow-all-tools
# Block specific tools
copilot --deny-tool='shell(rm)'
Review before approving

Like all agentic AI tools, Copilot will ask before running commands. Always read what it’s about to do — especially for destructive operations like rm, git reset --hard, or database modifications. When you’re learning, keep the default approval prompts on.

Custom instructions

Create a .github/copilot-instructions.md file in your project root to give Copilot persistent context about your project’s conventions, architecture, and preferences. This works similarly to Claude Code’s CLAUDE.md and Gemini CLI’s GEMINI.md.

🧬In Your Field: Biotechclick to expand

Copilot CLI’s agentic capabilities are powerful for bioinformatics workflows. Instead of memorizing complex tool syntax, describe what you need: “Parse this FASTQ file, filter reads with quality score above 30, and write the results to a new file.” Copilot will plan the approach, choose the right tools (samtools, seqkit, etc.), and execute the pipeline — asking for your approval at each step. For complex multi-step analyses, use plan mode (Shift+Tab) to review the strategy before execution.

🏛️In Your Field: Government / State Devclick to expand

Government developers working across multiple deployment environments will appreciate Copilot’s tool approval controls. You can allow specific tools while blocking risky ones: copilot --allow-tool='shell(git)' --deny-tool='shell(rm)'. The deep GitHub integration also means Copilot understands your Issues and PRs natively — useful for agencies that use GitHub for project tracking and compliance documentation.

Copilot CLI vs the other tools

AspectCopilot CLIClaude CodeGemini CLI
Default modelClaude Sonnet 4.5Claude Sonnet 4Gemini 2.5 Pro
Session modelPersistent conversationPersistent conversationPersistent conversation
File editingReads, writes, edits filesReads, writes, edits filesReads, writes, edits files
Plan modeShift+Tab-Built-in
Free tier50 messages/mo (Copilot Free)Limited (Pro plan)1,000 req/day (Google account)
Best forGitHub-integrated workflowsDeep codebase reasoningLarge context, high daily volume
MCP supportYesYesYes

All three are full agentic coding tools. The biggest differentiator is ecosystem: Copilot CLI integrates deeply with GitHub’s Issues, PRs, and Actions. If your workflow is GitHub-centered, Copilot CLI feels native. If you need the highest daily free usage, Gemini CLI’s 1,000 requests/day is hard to beat. If you want the deepest code reasoning, Claude Code excels.

Copilot Chat in VS Code

While you’re here, it’s worth knowing that Copilot Chat in VS Code now offers four modes:

  • Ask — ask questions about your codebase
  • Edit — make targeted edits to specific files
  • Agent — autonomous multi-file coding (similar to using Copilot CLI)
  • Plan — create and review structured plans before executing

These are complementary to the CLI — use VS Code’s Copilot Chat when you want visual context, and the CLI when you want speed and automation.

Verify it works

Paste this exact command to confirm everything is set up correctly:

Terminal window
copilot --version

You should see a version number printed. If you get an error, make sure copilot is installed and in your PATH (see installation steps above).

💡Your first real prompt

If the version check worked, try this — your first real interaction with the new Copilot CLI:

Terminal window
copilot -p "list all files in the current directory and describe what each one does"

If you see a response, congratulations — you’re ready to use GitHub Copilot CLI for real work starting in Module 9.

🔧

When Things Go Wrong

Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.

Symptom
'copilot' command not found after installation
Evidence
bash: copilot: command not found
What to ask the AI
"I installed Copilot CLI using npm/brew but my terminal can't find the 'copilot' command. How do I verify the installation and check if it's in my PATH? I may need to restart my terminal or add the install location to my PATH."
Symptom
Authentication fails or login loop
Evidence
Error during /login or device flow doesn't complete
What to ask the AI
"I'm trying to authenticate Copilot CLI but the login flow doesn't complete. I'm on a remote server via SSH. How do I complete the device flow authentication, and do I need any special scopes or permissions on my GitHub account?"
Symptom
Copilot says I've exceeded my usage limit
Evidence
Error: You have exceeded your monthly usage limit for Copilot
What to ask the AI
"I'm on the Copilot Free plan and hit the 50 message limit. What are my options? Can I upgrade to Pro, or should I switch to another tool like Gemini CLI (which has 1,000 free requests per day) while I wait for my limit to reset?"

Key Takeaways

  • Copilot CLI is now a full agentic coding tool — the old gh copilot suggest/explain extension has been retired, replaced by a standalone copilot command
  • Free tier with zero friction — Copilot Free gives CLI access to anyone with a GitHub account, no credit card required
  • Interactive and programmatic modescopilot for persistent sessions, copilot -p "prompt" for one-off tasks
  • Tool approval keeps you safe — fine-grained --allow-tool and --deny-tool flags control what the agent can do
  • Deep GitHub integration — the standout advantage over other AI CLI tools, with native understanding of Issues, PRs, and Actions