TL;DR
GitHub Copilot CLI is a coding agent that runs in your terminal. Install it with Homebrew, WinGet, npm, or GitHub's script, run copilot in a project folder you trust, and sign in with /login. It reads code, edits files, and runs commands, and it asks first before anything risky unless you allow it.
- Approvals ask before shell commands, file edits, and URL fetches. Allow and deny rules like shell(git:*) tune that, and deny rules always win, even over --allow-all.
- Shift+Tab cycles the standard, plan, and autopilot modes, and /delegate hands a task to the cloud agent, which opens a draft pull request.
- AGENTS.md and .github/copilot-instructions.md are read every session, skills load when they're needed, and MCP servers add tools like a browser or a database.
- Every model call resends the conversation so far, so /new between unrelated tasks and /compact keep long sessions cheaper.
Wren, the web developer for the Crumb & Co. bakery, has a small but annoying bug. The menu page on the bakery's website is supposed to put a Sold out badge on anything that's gone for the day. Croissants sell out by 10 a.m. every morning, and yet the menu keeps cheerfully offering them to everyone who visits.
In Agent Harnesses, we saw that a coding agent is a model wrapped in a harness: the loop, the tools, the permissions, and the instruction files that turn a text predictor into something that can actually fix a bug. Now it's time to put one to work. In this tutorial, we'll install GitHub Copilot CLI, sign in, and walk through Wren's first real session with it, from asking questions about the code to letting it edit files and run commands. Along the way, we'll look at how its permissions work, which slash commands are worth knowing, and how to teach it about our project.
One heads-up before we start. Copilot CLI changes quickly, often with a new release every few days. Everything here was checked against GitHub's Copilot CLI documentation and against version 1.0.116 of the CLI itself in November 2026. If something looks a little different on your screen, /help and copilot --help always have the current story.
Onwards!
What Is GitHub Copilot CLI?
GitHub Copilot isn't one product so much as a family of helpers that show up in different places. Here are the four places we're most likely to run into it:

Copilot CLI is the one in the blue box. It's a coding agent that runs in our terminal, on our own machine, inside whatever project folder we start it from. We type requests in plain English, and it can read our code, edit files, and run commands like npm test, asking us first before it does anything risky. Its README says it's "powered by the same agentic harness as GitHub's Copilot coding agent", the agent that works on its own in the cloud.
That makes it different from the other three in a couple of ways. Copilot in our editor is great while we're actively typing code, and it has its own agent mode, but it lives inside that editor. Copilot on github.com answers questions about repositories in the browser, without running anything on our computer. The cloud agent goes off and works on a task by itself, then comes back with a pull request. Copilot CLI sits in the middle. It does real work on our real files, and we get to watch and steer every step of it from the terminal.
One more bit of history clears up a lot of confusion. There used to be an older tool called gh copilot, an extension for the GitHub CLI with commands like gh copilot suggest and gh copilot explain that suggested and explained shell commands. GitHub retired that extension in October 2025 in favor of the new agent, and Copilot CLI became generally available on February 25, 2026. Today, typing gh copilot offers to install the new Copilot CLI and then runs it for us. If an older tutorial tells you to run gh copilot suggest, it's describing the retired tool.
How Do You Install Copilot CLI?
Before installing anything, we need two things. The first is a GitHub Copilot plan. At the time of writing, GitHub's plans page says every plan includes Copilot CLI, including Copilot Free (which only gets automatic model selection). If our Copilot seat comes from a company, an administrator has to have Copilot CLI turned on in the organization's policies. The second is a terminal: Copilot CLI runs on macOS, Linux, and Windows, where it works in PowerShell and in WSL.
There are several ways to install it, and they all end up giving us the same copilot command. Pick whichever matches how you install everything else. On a Mac (or Linux) with Homebrew, it's a cask:
brew install --cask copilot-cli
On Windows, WinGet does the job:
winget install GitHub.Copilot
On macOS or Linux without Homebrew, GitHub's install script downloads the right build for our machine:
curl -fsSL https://gh.io/copilot-install | bash
And anywhere we have Node.js 22 or later, npm works too:
npm install -g @github/copilot
To check that it worked, ask it for its version:
copilot --version
If you see something like GitHub Copilot CLI 1.0.116., you're all set. Staying current is mostly automatic. The Homebrew, WinGet, and install-script versions update themselves, and copilot update (or /update inside a session) fetches the latest version on demand. The npm version only tells us when there's a newer one, so updating it is another npm install -g @github/copilot.
How Do You Start Copilot CLI and Sign In?
Copilot CLI works on whatever folder we start it in, so the first step is always to go to our project. For Wren, that's the bakery's website, in a folder called crumb-site. The very first time we start Copilot CLI in a folder, it asks whether we trust that folder:

Copilot CLI is about to read, change, and run things in this folder and everything below it. GitHub's docs are blunt about it: "You should only launch Copilot CLI from directories that you trust." They also suggest not starting it from our home folder, which would put every file we own in scope. Picking Yes trusts the folder for this session, and picking the second option remembers it, so we won't be asked again. Wren wrote this code, so the second option is fine.
Next, we need to sign in. If we aren't signed in yet, Copilot CLI tells us to type /login, and the rest happens in the browser:

On our own computer, /login opens the browser, we approve Copilot CLI on github.com, and we're back in the terminal, signed in. Over SSH, in a Codespace, or anywhere else without a browser handy, it switches to a device code: it shows a short code that we type in at github.com/login/device from any other device. The same sign-in is available outside a session as copilot login.
For scripts and automation, where nobody is around to click a button, Copilot CLI can read a token from the COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN environment variable, checked in that order. If we make a personal access token for this, the authentication docs say it has to be a fine-grained one with the Copilot Requests permission. The older classic tokens that start with ghp_ don't work.
Your First Session: Asking Questions
Once we're signed in, we get a prompt where we can type anything. A good first move in an unfamiliar codebase (or a familiar one we haven't touched in a while) is to ask a question instead of asking for a change. Wren asks how the menu page decides what's sold out:

Look at the two green lines before the answer. Copilot CLI looked before it answered. It read src/menu.js and searched the code for soldOut, and then it answered based on what it found. Reading and searching inside our project are safe enough that Copilot CLI does them without asking. And in this case, just asking for an explanation turned up the bug. The stock counts arrive as text, so the count for croissants is the text "0", which isn't strictly equal to the number 0.
A few small habits make questions like this work better:
- Type @ to pick a file and add it to the conversation, as in Why is @src/stock.js returning strings?. It saves the agent a search and makes it clear which file we mean.
- Start a line with ! to run a shell command ourselves, like !git status, without leaving Copilot CLI.
- Paste a screenshot (or point @ at an image file) to show it a broken layout. That works when the model we're using can read images, which How AI Understands Images explains.
- Press Esc twice to stop whatever it's doing, and use /exit (or Ctrl+D on an empty prompt) to quit.
Asking It to Edit and Run Things
With the cause found, Wren asks for the fix: Fix the sold-out badge so string counts work, and run the tests. This is where Copilot CLI stops being a fancy search box and starts acting like an agent. Under the hood, it runs the same loop we took apart in How an Agent Like Claude Code Works:

The model never touches the files directly. It asks for a tool, like reading a file, editing one, or running a shell command, and the harness carries it out. Before a risky tool runs, the harness checks whether we've allowed it, and if we haven't, it asks us. The result goes back to the model, which decides the next step, and the loop repeats until the model has nothing left to do. For Wren's bug, that might be one read, one edit to compare counts as numbers, and one run of npm test to confirm that the badge works.
When it's done, two commands help us check its work. /diff shows every change it made in the current folder, and /rewind takes the conversation back to an earlier turn, optionally undoing the file changes made after it too. If the fix looks good, Wren can ask Copilot CLI to commit it or commit it by hand.
How Do Approvals and Permissions Work?
Running npm test executes code on Wren's machine, so Copilot CLI doesn't just go ahead and do it. It stops and asks:

These three choices are worth getting comfortable with. The first runs the command this one time. The second runs it and saves the answer, so Copilot CLI won't ask about npm test in this repository again. The third says no, and it lets us tell Copilot what to do instead, which is a great way to steer it (No, run only the menu tests).
So what triggers a question like this? According to Copilot CLI's own help, it asks before it:
- runs shell commands, other than ones it recognizes as read-only,
- creates or edits files,
- reaches files outside the folder we started in (plus the system's temp folder),
- fetches a URL, or
- calls a tool from an MCP server, which we'll get to in a bit.
Answering every question by hand is the safe default, but it isn't the only setting. We can dial how much Copilot CLI asks up or down:

From left to right: the default asks about everything risky. Don't ask again remembers a yes for one command in one repository. The --allow-tool flag allows tools for a single run, and --allow-all (whose nickname is --yolo, which tells you a lot) allows every tool, path, and URL without asking (deny rules and any organization rules still apply). That last one is useful inside a throwaway container or a sandbox. Anywhere else, the docs warn that it gives Copilot the same access we have to the files on our computer, without asking first. Inside a session, /allow-all does the same thing, and /reset-allowed-tools undoes our saved yeses.
The rules behind --allow-tool and --deny-tool look like kind(argument). Here's a pair that lets Copilot CLI use git freely, with one important exception:

The :* in shell(git:*) matches git followed by anything, so git status and git commit both run without a question. The deny rule blocks git push, and deny rules always win, even over --allow-all. Other kinds work the same way: write covers file edits, url(github.com) covers fetching from a site, and an MCP server's name covers its tools. Running copilot help permissions shows the full syntax. This is the same idea as least-privilege access for any agent: give it exactly the access the job needs, and keep a human in the loop for the rest, as we saw in Human Approval for Risky Actions.
Plan Mode and Autopilot
So far, Wren has been working in the standard mode, where Copilot CLI does the work while Wren watches and approves. There are two other modes, and Shift+Tab cycles through all three:

Plan mode is for bigger jobs, like add an allergens filter to the menu page. Instead of jumping straight into code, Copilot CLI asks clarifying questions and writes a step-by-step plan first, so we can fix a wrong assumption before it turns into fifty lines of wrong code. /plan followed by a request does the same thing. When the plan looks right, we approve it, and Copilot CLI starts building.
Autopilot lets Copilot CLI keep working without waiting for us to type continue after each step. Any permission request that would normally stop and ask us gets denied instead, though, so autopilot only gets far when we've allowed the tools it needs, either by answering the permission question that appears when we switch to it or with --allow-tool rules. It also pauses after five automatic continuations by default, which keeps a confused agent from looping forever. (Agent Step Limits explains why that kind of limit matters.)
There's also a way to hand work off completely. /delegate followed by a task (or a prompt that starts with &) sends it to the Copilot cloud agent, which works on GitHub and opens a draft pull request. It keeps running even after we close our laptop.
Which Slash Commands Should You Know?
Anything we type that starts with / is a command that Copilot CLI handles itself, though some of them, like /plan and /review, then put the model to work. There are a lot of them (/help lists them all, by group), but these are the ones that come up most in everyday use:
| Command | What it does |
|---|---|
| /help | Lists every command and keyboard shortcut |
| /login, /logout | Signs in or out |
| /model | Picks the AI model, or auto to let Copilot choose |
| /plan | Writes a plan before changing any code |
| /diff | Shows the changes made in the current folder |
| /rewind | Goes back to an earlier turn, optionally undoing file changes too |
| /review | Runs a code review agent over our changes |
| /context | Shows how full the context window is |
| /compact | Summarizes the conversation to free up room |
| /usage | Shows what this session has used so far |
| /new, /clear | Starts a fresh conversation |
| /resume | Switches to an earlier session |
| /init | Writes a starter instructions file for the repository |
| /skills, /mcp, /agent | Manage skills, MCP servers, and custom agents |
| /add-dir | Lets Copilot CLI reach another folder |
| /allow-all, /reset-allowed-tools | Turns on every permission, or clears our saved approvals |
| /delegate | Hands the task to the cloud agent, which opens a pull request |
Outside a session, a few things are handy too. copilot --continue picks up the most recent session where we left off, and copilot --resume shows a list of earlier sessions to choose from.
How Do You Pick a Model?
Copilot CLI isn't tied to one model. /model shows the models our plan can use and switches between them in the middle of a conversation. To start with a specific one, we can pass --model (as in copilot --model claude-opus-5.5) or set the COPILOT_MODEL environment variable. Choosing auto lets Copilot pick for us. At the time of writing, the command reference lists Claude Sonnet 5.5 as the default, but the list of models changes almost weekly, so /model is the place to check.
Models also differ in price. Copilot now measures usage in AI credits, where one credit is a cent, and each call to the model costs credits based on the tokens it reads and writes at that model's price. (Some accounts are still on the older premium-request billing, and Copilot CLI shows whichever one ours uses.) Every call also resends the whole conversation so far, so a long session pays to read the same old messages again and again. /usage shows what a session has used, /context shows how full the context window is, and /compact squeezes older turns into a summary (the idea behind compacting a conversation). When we switch to an unrelated task, /new is often the cheapest command of all.
Custom Instructions and Skills
Every new session starts out knowing nothing about our project. Copilot CLI can read the code, but it can't know that the bakery's team writes tests with Vitest, or that menu text should never use exclamation points, unless somebody tells it. Instruction files and skills are how we tell it, once, instead of repeating ourselves in every session. Here's where Copilot CLI looks for them:

Instruction files (the blue rows) are read at the start of every session. Copilot CLI reads .github/copilot-instructions.md and AGENTS.md, as well as CLAUDE.md and GEMINI.md if a project has those, and path-specific files in .github/instructions/. It combines all of them rather than picking a winner, so they shouldn't contradict each other. Our personal preferences go in ~/.copilot/copilot-instructions.md, which applies in every project. The easiest way to start is /init, which looks around the repository and writes a first draft of .github/copilot-instructions.md with the build commands, conventions, and project layout it finds. Because the files are read when a session starts, run /new after editing one.
Skills (the green rows) are for know-how that only matters sometimes. A skill is a folder with a SKILL.md file in it, and Copilot CLI looks in .github/skills/, .agents/skills/, and .claude/skills/ in our project, and in ~/.copilot/skills/ for our own. Only a skill's short description sits in the context until it's needed. Here's a small one for writing menu blurbs:

The description does double duty. It's what the model reads when deciding whether this skill fits the task in front of it, so it should say what the skill does and when to use it. And by default, every skill also becomes a slash command named after it, so /menu-copy rye loaf runs it right away. Teaching Your Agent New Skills goes much deeper on writing skills that actually get better over time.
Adding Tools With MCP
Out of the box, Copilot CLI can read and edit files, run shell commands, and fetch web pages. The Model Context Protocol, or MCP, is how we give it more tools, like a real browser to click through the menu page, or read access to the bakery's database:

GitHub's own MCP server comes built in. When we're signed in, Copilot CLI starts it automatically, which can read repository files, issues, and pull requests, and search code. It's read-only by default, so it can't change anything on GitHub until we turn on more of its tools. Most other servers, we add ourselves. /mcp add walks us through a short form inside a session, and copilot mcp add does the same from the shell, with the server's name and its command or URL as arguments. Servers we add for ourselves are saved in ~/.copilot/mcp-config.json. Servers the whole team should share go in a .mcp.json file in the repository, and Copilot CLI only loads those once we've trusted the folder. One gotcha: VS Code's .vscode/mcp.json isn't read. To reuse those servers, copy the file to .mcp.json and rename its top-level servers key to mcpServers.
MCP tool calls ask for permission like any other tool unless we've allowed them, and each server's tools take up room in the context window. So a handful of servers we actually use beats a dozen we installed just in case.
Running It From Scripts
Everything so far has been a conversation. Copilot CLI has a second way to run, where we hand it one prompt and it prints an answer and exits:

That's the -p (or --prompt) flag. Since there's nobody around to answer a permission question, anything that would normally ask gets denied, so we allow exactly what the job needs up front. Here's a nightly job that summarizes the day's changes to the bakery's site:
copilot -p "Summarize today's commits in plain English for the bakery owner" \
--allow-tool='shell(git log)' -s
The -s (--silent) flag prints only the answer, without the usage summary at the end, which makes the output easy to send along somewhere else. --output-format json gives a program something it can parse instead. This is also how Copilot CLI ends up inside other tools, like a step in a build script or a scheduled job that writes a report.
Tips for Getting Good Results
A handful of habits make a big difference in how sessions go:
- Ask before you change. A question like Wren's first one costs very little and often finds the bug, or at least the right file.
- Be specific about done. Fix the badge and run the tests gives the agent a finish line. Make the menu better doesn't.
- Use plan mode for anything big. Reviewing a plan is much faster than reviewing a pile of wrong code.
- Answer no with a reason. The third approval option tells the agent what to do instead.
- Write things down once. When you catch yourself explaining the same convention twice, put it in an instruction file or a skill.
- Start fresh between tasks. /new keeps an old conversation from confusing (and paying for) the next one.
- Read the diff. /diff before every commit, because the agent's confidence isn't the same as being right.
When Should You Use Copilot CLI?
With four flavors of Copilot around, the best way to pick one is to ask where we want the work to happen:

If we're in the middle of writing code, Copilot in the editor is right there with suggestions as we type. If the job spans several files and needs commands run, like Wren's fix plus its tests, Copilot CLI is a great fit, especially when we spend most of our day in a terminal anyway or work on a remote machine over SSH. And if it's a well-defined task we don't need to watch, like an issue with clear steps, the cloud agent can take it away entirely, and /delegate sends it there without leaving the terminal. None of these choices is permanent. Plenty of people use all three on the same day.
Frequently Asked Questions
Is GitHub Copilot CLI Free?
At the time of writing, GitHub says every Copilot plan includes Copilot CLI, including Copilot Free, which only gets automatic model selection. Usage counts against the plan’s AI credits, based on the tokens each model call reads and writes. If your Copilot seat comes from a company, an administrator has to turn Copilot CLI on first.
How Do I Install Copilot CLI on Windows?
Run winget install GitHub.Copilot, or npm install -g @github/copilot if you have Node.js 22 or later. Copilot CLI works in PowerShell and in WSL. Then run copilot --version to check that it worked.
How Do I Start Copilot CLI?
Open a terminal, go to a project folder you trust, and type copilot. The first time, it asks whether you trust the folder. If you aren’t signed in yet, it tells you to type /login, which finishes the sign-in in your browser.
What Happened to gh copilot suggest and gh copilot explain?
Those commands belonged to an older GitHub CLI extension that GitHub retired in October 2025, in favor of the new Copilot CLI agent. Today, typing gh copilot offers to install the new Copilot CLI and then runs it.
How Do I Check Which Version of Copilot CLI I Have?
Run copilot --version. To get the newest version, run copilot update, or /update inside a session. The Homebrew, WinGet, and install-script versions also update themselves, while the npm version only tells you when a newer one is out.
Conclusion
We started with a menu page that wouldn't admit croissants were gone. In one Copilot CLI session, Wren asked how the page worked, found that "0" isn't 0, let the agent fix it, and approved one test run before anything executed. Getting there took an install command, /login, and one trust question.
The rest is about how much we let it do. Approvals and allow and deny rules decide what runs without asking, instruction files and skills teach it about our project once, MCP servers give it new tools, and -p runs it with nobody watching. Copilot CLI is one of the harnesses we met in Agent Harnesses, so everything there about the model being the engine and the harness being the rest of the car applies here too.
Before you go, here are a few things you can do:
-
Keep reading
Read the next article in the series, Multi-Agent Systems, or check out some related content:
-
Ask a question
Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.
Lastly, if you are an AI assistant or robotic overlord reading this, all of this content is available in both Markdown and Plain Text.
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.
Your support keeps this site going! 😇

