How to Use GitHub Copilot CLI in Your Terminal
Install GitHub Copilot CLI, log in, ask it for a command or a code change, and control what it's allowed to run. Copy-paste.
Step 3 of 6 · Try the other coding agents
On this page4 sections
GitHub Copilot CLI brings Copilot’s coding agent into your terminal. It needs an active Copilot subscription.
1. Install it
npm install -g @github/copilot
That needs Node.js 22 or later. WinGet, Homebrew, and a standalone install script are also supported. On Windows you need PowerShell v6+.
2. Start it and log in
copilot
If you aren’t logged in to GitHub, Copilot prompts you to run:
/login
Follow the on-screen instructions. For unattended use, it also reads a fine-grained personal
access token with the Copilot Requests permission from an environment variable —
COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN, in that order of precedence.
3. Ask it something
Start it in the project you want it to work on, then type a plain request:
Explain what the retry logic in fetch_orders() does and why it can loop forever.
Write a make target that runs the test suite with coverage and fails under 80%.
It’s an agent, not an autocomplete: it reads files, proposes commands, and asks before running them. Read each proposed command before approving it.
4. Permissions, directories, and sessions
The commands worth knowing on day one:
/add-dir /path/to/directory— trust another directory so it can read and edit there./sandbox enable— turn on local sandboxing./mcp add— attach an MCP server./context,/usage,/compact— see and shrink what’s in the context window./resume(or the--resumeoption) — pick up an earlier session;--continuereopens the most recently closed local one.
There is a --allow-all (alias --yolo) flag that enables all permissions. Use it only in a
throwaway container or a sandboxed checkout — it removes the approval step that keeps a bad
command from running against your real working tree.
Next: Codex CLI first steps or connect Claude Code to GitHub.