GitHub Copilot CLI transforms your terminal into a conversational partner. It doesn’t just autocomplete code; it explains complex shell scripts and suggests entire commands based on natural language.

As of 2026, the tool has evolved into a more “agentic” assistant that can navigate your directories and even help with multi-step terminal tasks.

⚙️ Installation & Setup

The Copilot CLI is managed as an extension for the GitHub (gh) CLI.

Command Description
gh extension install github/gh-copilot Install the Copilot extension.
gh copilot --help Verify the installation and see the command list.
gh copilot config Open the configuration menu (shortcuts, feedback settings, etc.).

💡 The Core Duo: Suggest & Explain

These are the two commands you will use most frequently to bridge the gap between “what I want” and “how do I type that?”

  • gh copilot suggest “your prompt”: Ask Copilot to generate a shell command.
    • Example: gh copilot suggest “find all large logs and delete them”
    • Once suggested, you can Explain it, Revise it, or Execute it directly.
  • gh copilot explain “command”: Paste a cryptic command to see a breakdown of what every flag and argument does.
    • Example: gh copilot explain “ps aux grep node”

⚡ The Secret Sauce: Shell Aliases

Typing gh copilot suggest every time is tedious. Use the alias command to create shorter, native-feeling shortcuts like ?? or git?.

  1. Run: gh copilot alias -- <your-shell> (e.g., bash, zsh, or fish).
  2. Follow the prompt to add the output to your shell profile (.zshrc or .bashrc).
  3. Usage after setup:
    • ?? “how do I undo my last git commit”
    • explain “sudo rm -rf /” (Please don’t actually run this one).

🤖 Agentic Mode & Slash Commands

The newer “Agentic” version of the CLI allows you to start an interactive session where Copilot “stays” in your terminal to help with a larger task.

When inside an interactive Copilot session, you can use Slash Commands:

Slash Command Purpose
/clear Wipes the current session history to start fresh.
/cwd Changes or confirms the current working directory Copilot is looking at.
/model Switch between AI models (e.g., choosing a faster model vs. a smarter one).
/add-dir <path> Grant Copilot permission to read files in a specific directory for context.
/delegate Ask Copilot to handle a background task, like generating a PR from your changes.

🛠️ Tips for Better Results

  • Prepend with !: If you are inside an interactive Copilot session and need to run a standard shell command (like ls or mkdir) without exiting, prepend it with !.
  • Be Specific: Instead of “fix the error,” try “explain the last error in my build logs and suggest a fix.”
  • Context Matters: Open the specific directory you are working in before starting the CLI; Copilot uses your file structure to provide better suggestions.