Skip to content

Menu

GitHub Copilot Cheat Sheet: CLI Commands, Flags and Chat

Checked against GitHub Copilot CLI 1.0.117 on 28 November 2026. Each section links to the official docs it was checked against.

This sheet is for developers who use GitHub Copilot from the terminal with the standalone copilot CLI, and from VS Code chat. Commands and flags were checked against the CLI command reference and release v1.0.117 (27 Nov 2026). Chat commands come from GitHub's Copilot Chat cheat sheet.

When to use what

Use the interactive copilot session when you want to steer the work: you see each tool call and approve it. Reach for copilot -p "..." when the task is fixed and you want it in a script or CI job; add -s so you only get the answer back, and --output-format=json if another program reads the result.

For permissions, start with the default prompts and add narrow --allow-tool entries for the commands you trust. --allow-all-tools (or /yolo) is fine in a throwaway container, not on a laptop with your SSH keys on it. /plan is worth the extra turn on anything that touches more than a couple of files, because you can fix a bad plan before it turns into a bad diff.

Put team conventions in .github/copilot-instructions.md and keep personal taste in ~/.copilot/copilot-instructions.md. If your repo already has an AGENTS.md or CLAUDE.md, the CLI reads those too, so you don't need a copy. In VS Code chat, the slash commands like /explain and /tests are quick one-shot helpers; for multi-file work use agent mode instead. If you run Copilot inside workflows, our GitHub Actions generator gets the YAML skeleton right and the post on AI coding agents in GitHub Actions covers the permissions side.

copilot

Start an interactive session in the current directory

From the docs, not run by us
copilot login --device-code

Sign in with a device code, handy over SSH where no browser opens

From the docs, not run by us
copilot init

Create custom instructions for the current repository

From the docs, not run by us
copilot instruction list

Show which instruction files the CLI found for this directory

From the docs, not run by us
copilot mcp

Add, list or remove MCP server configurations outside a session

Try it: MCP Config GeneratorFrom the docs, not run by us
copilot config KEY VALUE

Read or change a setting without opening a session

From the docs, not run by us
copilot completion zsh

Print a shell completion script for bash, zsh or fish

From the docs, not run by us
copilot update

Install the latest CLI release in place

From the docs, not run by us

Flags that take lists want one quoted, comma-separated string. --continue and --resume conflict, so pick one.

copilot -p "PROMPT"

Run one prompt non-interactively and exit when it finishes

From the docs, not run by us
-s, --silent

Print only the agent reply, without the usage statistics footer

From the docs, not run by us
--output-format=json

Emit JSONL events instead of plain text for other programs to parse

From the docs, not run by us
--model=MODEL

Pick the model for this run; auto lets Copilot choose (env var COPILOT_MODEL)

From the docs, not run by us
--effort=high

Set reasoning effort to low, medium, high, xhigh or max

From the docs, not run by us
--allow-tool='shell(git:*)'

Let named tools run without a prompt; everything else still asks

From the docs, not run by us
--deny-tool=TOOL

Block named tools outright, even when other flags allow all

From the docs, not run by us
--allow-all-tools

Skip approval prompts for every tool (deny rules still win)

From the docs, not run by us
--add-dir=PATH

Give the agent file access to another directory and load its skills

From the docs, not run by us
--continue / -r, --resume[=ID]

Reopen the latest session here, or pick a session by ID, prefix or name

From the docs, not run by us

Add MCP servers for this session only, on top of mcp-config.json

Try it: MCP Config ValidatorFrom the docs, not run by us
--share=PATH

Save a programmatic run as a Markdown transcript when it ends

From the docs, not run by us
/model [--global|--repo] MODEL

Switch model for the session, or pin a default for the repo or globally

From the docs, not run by us
/plan PROMPT

Draft an implementation plan before any file is edited

From the docs, not run by us
/compact [FOCUS]

Summarise history to free context, optionally keeping a focus topic

From the docs, not run by us
/context

Show how many tokens the context window is using, with a breakdown

Try it: Token CounterFrom the docs, not run by us
/mcp

Open the MCP dashboard; subcommands add, edit, enable, disable and reload servers

From the docs, not run by us
/permissions allow-all

Switch permission mode; /yolo and /allow-all are aliases for this

From the docs, not run by us
/delegate PROMPT

Hand the change to the cloud agent, which opens a pull request

From the docs, not run by us
/diff

Review changes in the working directory (experimental)

From the docs, not run by us
/instructions

List discovered instruction files and turn each on or off

From the docs, not run by us
/clear (or /new)

Start a fresh conversation in the same terminal

From the docs, not run by us
@ FILENAME

Pull a file's contents into the prompt context

From the docs, not run by us
! COMMAND

Run a shell command yourself without going through the agent

From the docs, not run by us
Shift+Tab

Cycle between standard, plan and autopilot modes

From the docs, not run by us
Esc Esc

Interrupt the turn that is running now

From the docs, not run by us
Ctrl+G

Write a long prompt in $EDITOR instead of the input line

From the docs, not run by us
Ctrl+Q or Ctrl+Enter

Queue the next message while the agent is still busy

From the docs, not run by us
Ctrl+T

Show or hide the model's reasoning output

From the docs, not run by us
Ctrl+C twice

Exit the CLI; once just cancels or clears the input

From the docs, not run by us

Set COPILOT_HOME to move everything under ~/.copilot somewhere else. Instruction edits only apply to a new session (/new or copilot --continue).

~/.copilot/settings.json

User settings; repo overrides live in .github/copilot/settings.json

From the docs, not run by us
~/.copilot/mcp-config.json

User-level MCP server definitions loaded in every session

Try it: MCP Config GeneratorFrom the docs, not run by us
.github/copilot-instructions.md

Repository-wide instructions every Copilot session reads

From the docs, not run by us
.github/instructions/**/*.instructions.md

Path-specific rules that load when files matching applyTo are in use

From the docs, not run by us
AGENTS.md / CLAUDE.md / GEMINI.md

Agent instruction files the CLI also picks up from the repo

From the docs, not run by us
~/.copilot/copilot-instructions.md

Personal instructions applied across all your repositories

From the docs, not run by us
COPILOT_CUSTOM_INSTRUCTIONS_DIRS

Comma-separated extra folders to search for AGENTS.md and instruction files

From the docs, not run by us
/explain

Explain how the code in the active editor works

From the docs, not run by us
/fix

Propose a fix for problems in the selected code

From the docs, not run by us
/tests

Generate unit tests for the selection

From the docs, not run by us
/fixTestFailure

Find a failing test and suggest a fix for it

From the docs, not run by us
#file / #selection

Attach the current file or selected text as context

From the docs, not run by us
@terminal

Ask about the integrated terminal shell and its recent output

From the docs, not run by us

Worked example: Run a scripted review of staged changes and save the transcript

Say you want a quick second opinion on staged changes before every commit, with no prompts and a record you can attach to the PR.

git add -p
copilot -p "Review the staged diff (git diff --cached). List bugs only, no style notes." \
  --allow-tool='shell(git:*)' \
  --deny-tool='shell(git push)' --deny-tool=write \
  --no-ask-user -s \
  --share=./review.md

The -p run exits when the agent is done, so it fits in a pre-push hook or a Makefile target. shell(git:*) lets it run any git subcommand without asking, shell(git push) carves push back out, and denying write means it can read but never edit your files. Deny rules beat allow rules, which is why the push exception works. --no-ask-user stops it from pausing for a question nobody will answer, and -s drops the usage footer so stdout holds just the list of findings. After it finishes, review.md holds the full session, tool calls included, which is what you paste into the PR if someone asks how the review was done. The shell(git:*), shell(git push) and write patterns are the ones GitHub's allowing-tools page shows; we haven't run this exact line ourselves.

Common mistakes

  • Running --allow-all-tools on your own machine to stop the prompts

    Allow only the commands you need with --allow-tool, and save blanket approval for disposable containers or sandboxes.

  • Editing .github/copilot-instructions.md and expecting the open session to follow it

    Instructions load at session start, so run /new or restart with copilot --continue after editing.

  • Duplicating the same rules in AGENTS.md, CLAUDE.md and copilot-instructions.md

    The CLI reads all of them, so keep shared rules in one file and use the others only for tool-specific notes.

  • Passing --continue and --resume together in a script

    They conflict; use --continue for the latest session here, or --resume=ID when you know which session you want.

  • Using bare --resume in CI and watching the job hang

    The picker needs a terminal; pass the session ID or name explicitly in non-interactive runs.