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.
copilotStart an interactive session in the current directory
copilot login --device-codeSign in with a device code, handy over SSH where no browser opens
copilot initCreate custom instructions for the current repository
copilot instruction listShow which instruction files the CLI found for this directory
copilot mcpAdd, list or remove MCP server configurations outside a session
copilot config KEY VALUERead or change a setting without opening a session
copilot completion zshPrint a shell completion script for bash, zsh or fish
copilot updateInstall the latest CLI release in place
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
-s, --silentPrint only the agent reply, without the usage statistics footer
--output-format=jsonEmit JSONL events instead of plain text for other programs to parse
--model=MODELPick the model for this run; auto lets Copilot choose (env var COPILOT_MODEL)
--effort=highSet reasoning effort to low, medium, high, xhigh or max
--allow-tool='shell(git:*)'Let named tools run without a prompt; everything else still asks
--deny-tool=TOOLBlock named tools outright, even when other flags allow all
--allow-all-toolsSkip approval prompts for every tool (deny rules still win)
--add-dir=PATHGive the agent file access to another directory and load its skills
--continue / -r, --resume[=ID]Reopen the latest session here, or pick a session by ID, prefix or name
Add MCP servers for this session only, on top of mcp-config.json
--share=PATHSave a programmatic run as a Markdown transcript when it ends
/model [--global|--repo] MODELSwitch model for the session, or pin a default for the repo or globally
/plan PROMPTDraft an implementation plan before any file is edited
/compact [FOCUS]Summarise history to free context, optionally keeping a focus topic
/contextShow how many tokens the context window is using, with a breakdown
/mcpOpen the MCP dashboard; subcommands add, edit, enable, disable and reload servers
/permissions allow-allSwitch permission mode; /yolo and /allow-all are aliases for this
/delegate PROMPTHand the change to the cloud agent, which opens a pull request
/diffReview changes in the working directory (experimental)
/instructionsList discovered instruction files and turn each on or off
/clear (or /new)Start a fresh conversation in the same terminal
@ FILENAMEPull a file's contents into the prompt context
! COMMANDRun a shell command yourself without going through the agent
Shift+TabCycle between standard, plan and autopilot modes
Esc EscInterrupt the turn that is running now
Ctrl+GWrite a long prompt in $EDITOR instead of the input line
Ctrl+Q or Ctrl+EnterQueue the next message while the agent is still busy
Ctrl+TShow or hide the model's reasoning output
Ctrl+C twiceExit the CLI; once just cancels or clears the input
Set COPILOT_HOME to move everything under ~/.copilot somewhere else. Instruction edits only apply to a new session (/new or copilot --continue).
~/.copilot/settings.jsonUser settings; repo overrides live in .github/copilot/settings.json
~/.copilot/mcp-config.jsonUser-level MCP server definitions loaded in every session
.github/copilot-instructions.mdRepository-wide instructions every Copilot session reads
.github/instructions/**/*.instructions.mdPath-specific rules that load when files matching applyTo are in use
AGENTS.md / CLAUDE.md / GEMINI.mdAgent instruction files the CLI also picks up from the repo
~/.copilot/copilot-instructions.mdPersonal instructions applied across all your repositories
COPILOT_CUSTOM_INSTRUCTIONS_DIRSComma-separated extra folders to search for AGENTS.md and instruction files
/explainExplain how the code in the active editor works
/fixPropose a fix for problems in the selected code
/testsGenerate unit tests for the selection
/fixTestFailureFind a failing test and suggest a fix for it
#file / #selectionAttach the current file or selected text as context
@terminalAsk about the integrated terminal shell and its recent output
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-toolson your own machine to stop the promptsAllow only the commands you need with
--allow-tool, and save blanket approval for disposable containers or sandboxes.Editing
.github/copilot-instructions.mdand expecting the open session to follow itInstructions load at session start, so run
/newor restart withcopilot --continueafter 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
--continueand--resumetogether in a scriptThey conflict; use
--continuefor the latest session here, or--resume=IDwhen you know which session you want.Using bare
--resumein CI and watching the job hangThe picker needs a terminal; pass the session ID or name explicitly in non-interactive runs.
Related cheat sheets
Sources
- https://docs.github.com/en/copilot/reference/cli-command-reference
- https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-custom-instructions
- https://docs.github.com/en/copilot/reference/chat-cheat-sheet
- https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/allowing-tools
- https://github.com/github/copilot-cli/releases
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.