If your work lives inside GitHub โ repos, issues, PRs, actions โ this agent plays on home turf. Copilot CLI is not a standalone package; it's a GitHub CLI (gh) extension that brings Copilot's power to the terminal.
โ ๏ธ Important: This is NOT the IDE extension!
|
IDE Extension |
CLI Extension |
| Name |
GitHub Copilot |
gh-copilot |
| Install |
VS Code / JetBrains plugin |
gh extension install github/gh-copilot |
| Usage |
Inside editor |
Inside terminal |
| API |
Same API |
Same API |
Installation & Setup
| Command |
What it does |
brew install gh |
Install GitHub CLI (macOS/Linux) |
gh auth login |
Authenticate with GitHub |
gh extension install github/gh-copilot |
Install Copilot extension |
gh extension upgrade github/gh-copilot |
Update the extension |
gh copilot --version |
Verify installation |
All Commands
| Command |
What it does |
Scenario |
gh copilot suggest "<query>" |
Generate command from natural language |
"The bread and butter" โ turn description into shell command |
gh copilot suggest |
Open interactive mode |
For multi-step conversations |
gh copilot explain "<command>" |
Explain a command in plain English |
Understand a complex command from StackOverflow |
gh copilot explain |
Interactive explain mode |
Explain multiple commands |
gh copilot --help |
All commands and flags |
|
gh copilot --version |
Installed version |
|
All Flags
suggest flags
| Flag |
Alias |
What it does |
Example |
--target <shell> |
-t |
Target specific shell |
-t bash, -t zsh, -t powershell, -t fish, -t git, -t gh |
--no-confirm |
โ |
Skip y/n prompt (for scripting) |
gh copilot suggest --no-confirm "commit all" | bash |
--debug |
โ |
Show API calls and context |
Understand why a weird suggestion was generated |
--help |
-h |
Help for suggest |
|
explain flags
| Flag |
Alias |
What it does |
Example |
--target <shell> |
-t |
Shell-specific explanation |
gh copilot explain -t powershell "Get-Process" |
--debug |
โ |
Debug mode |
|
--help |
-h |
Help for explain |
|
Keyboard Shortcuts (in interactive mode)
| Key |
Context |
Action |
y or Enter |
After suggest |
Accept and execute |
n |
After suggest |
Reject |
Tab |
Interactive mode |
Show alternative suggestion |
โ/โ |
Interactive mode |
Navigate options |
Ctrl+C |
Anytime |
Cancel |
Escape |
Confirmation |
Cancel |
Practical Scenarios
Scenario 1: Natural language โ shell command
gh copilot suggest "find all .txt files modified in the last 24 hours"
gh copilot suggest "backup my home directory excluding node_modules"
gh copilot suggest "show git log with graph and one line per commit"
Scenario 2: Target specific shell
# PowerShell
gh copilot suggest -t powershell "list all running services"
# Git commands
gh copilot suggest -t git "undo last commit but keep changes"
gh copilot suggest -t git "create branch from old commit"
# GitHub CLI
gh copilot suggest -t gh "create issue with labels bug,urgent"
Scenario 3: Pipe to shell directly (automation)
#!/bin/bash
# One-liner: generate + execute without confirmation
gh copilot suggest --no-confirm -t bash "restart nginx" | bash
# In script: capture command
CMD=$(gh copilot suggest --no-confirm -t bash "deploy to staging")
$CMD
Scenario 4: Explain complex commands
# Understand a command from StackOverflow
grep -r 'TODO' . --include='*.js' | wc -l
gh copilot explain "awk '{print $1}' access.log | sort | uniq -c | sort -nr"
gh copilot explain "docker ps -a --filter 'status=exited'"
Scenario 5: Debug weird suggestions
gh copilot suggest --debug "delete old logs"
# Shows the exact prompt and context sent to the API
Scenario 6: Full Git workflow
# Triage issues
git copilot suggest -t gh "list open issues labeled bug sorted by oldest"
# PR review
git copilot suggest -t gh "show files changed in last PR"
# CI diagnosis
git copilot suggest "check why CI failed on my last push"
MCP Support
- Copilot CLI supports Model Context Protocol (MCP) servers
- Connect to external tools: databases, documentation, APIs
- Configured via GitHub Copilot settings or workspace configs
- Extends CLI beyond shell commands
Hidden Features & Pro Tips
| # |
Tip |
How |
| 1 |
Tab cycles alternatives |
Not just autocomplete โ gets a completely different suggestion |
| 2 |
Pipe to any shell |
` |
| 3 |
No-confirm for scripting |
--no-confirm + pipe = fully automated |
| 4 |
Debug mode reveals the magic |
--debug shows the actual prompt |
| 5 |
Target = context aware |
-t git understands Git, -t gh understands GitHub CLI |
| 6 |
Independent updates |
gh extension upgrade doesn't need gh core update |
| 7 |
Works offline? No |
Relies on GitHub Copilot API โ needs internet |
Troubleshooting
| Issue |
Solution |
| "command not found: gh" |
brew install gh or apt install gh |
| "Copilot is not enabled" |
gh auth login + check active subscription |
| "No suggestions returned" |
--debug to see API call |
| Weird suggestion |
Tab to try alternative |
| Permission denied when piping |
Ensure the command itself doesn't need sudo |
The Verdict
Best for: GitHub-centric workflows โ issue triage, quick PR understanding, CI failure diagnosis. For deep multi-file code surgery, compare against Claude Code and opencode โ all the cheat sheets are here, and the comparison lives on the Models page.
The key difference: Copilot CLI = "What do I want to do?" โ generates command. Claude Code = "Fix this bug" โ reads, edits, and tests until done.