Sitemap
DhanushKumar

DhanushKumar

A guy who is curious to learn and blog ... Data Science @Deloitte AI | Data Science | Azure AI

GitHub Copilot CLI— Commands, Plugins, Programmatic Use.

11 min readJun 2, 2026

--

GitHub Copilot CLI is GitHub’s terminal-first Copilot experience for working interactively with an agent in your shell, delegating tasks, managing sessions, reviewing code, connecting to remote sessions, and extending the experience with plugins, MCP servers, skills, and custom agents. The command reference frames it as an interactive UI plus a set of shell commands, slash commands, and automation-friendly flags; the programmatic reference explicitly says you can also pass a prompt directly in one shot for scripts, CI/CD pipelines, and automation workflows.

Press enter or click to view image in full size

What Is GitHub Copilot CLI?

GitHub Copilot CLI is a full-featured agentic coding assistant that runs directly in your terminal. Unlike IDE extensions that suggest code snippets inline, Copilot CLI takes on complete tasks — reading your codebase, running shell commands, editing files, creating pull requests, conducting deep research, and more — all from a conversational prompt.

Think of it as having a senior engineer sitting beside you in your terminal. You describe a task in plain English; Copilot CLI plans a course of action, asks for permission before making consequential changes, executes multi-step workflows, and reports results — all without leaving the command line.

Key capabilities at a glance:

  • Interactive chat — conversational back-and-forth in a rich terminal UI
  • Autopilot mode — fully autonomous execution without stopping to confirm every step
  • Plan mode — generate an implementation plan before any code is written
  • Fleet mode — run subtasks in parallel across multiple subagents
  • Remote control — steer a CLI session from GitHub.com or GitHub Mobile
  • Programmatic mode — pipe a prompt in, get a result back (no interactive UI)
  • Plugins — install or create packages that add agents, skills, MCP servers, and more
  • MCP server support — connect the agent to any Model Context Protocol server
  • Custom agents — define specialized sub-agents in Markdown files
  • Hooks — run your own scripts before/after tool calls
  • Session persistence — resume previous sessions; export transcripts to Markdown or Gists

Installation and Authentication

Install

# macOS (Homebrew)
brew install github/gh/copilot

# Or download from GitHub releases and put the binary on your PATH

Authenticate

# Log in via browser OAuth (default)
copilot login

# Log in to GitHub Enterprise Cloud (data residency)
copilot login --host https://your-org.ghe.com

# Use a fine-grained PAT via environment variable (for CI/headless use)
COPILOT_GITHUB_TOKEN=github_pat_... copilot
Press enter or click to view image in full size

Supported token types:

  • Fine-grained personal access tokens (v2 PATs) with the “Copilot Requests” permission
  • OAuth tokens from the Copilot CLI app
  • OAuth tokens from the GitHub CLI (gh) app

Note: Classic ghp_ personal access tokens are NOT supported.

Token priority order (highest to lowest): COPILOT_GITHUB_TOKEN → GH_TOKEN → GITHUB_TOKEN

The Three Layers of Copilot CLI

Before diving into commands, it helps to understand how the three reference areas relate to each other:

Press enter or click to view image in full size

Part I — CLI Commands: Every Command Explained

Core Binary Commands

These are the commands you run directly in your shell, outside of any interactive session.

Shell Completion Examples

# Bash — current session only
source <(copilot completion bash)

# Bash — persistent (Linux)
copilot completion bash | sudo tee /etc/bash_completion.d/copilot

# Zsh — persistent (restart shell after running)
copilot completion zsh > "${fpath[1]}/_copilot"

# Fish
copilot completion fish > ~/.config/fish/completions/copilot.fish

Interactive Slash Commands (The Full List)

Once inside an interactive session, you communicate via natural-language prompts and these slash commands. Slash commands are prefixed with / and can be run at any time, even mid-task.

Session and Navigation

Press enter or click to view image in full size

Context and Workspace

Press enter or click to view image in full size

Agentic Modes

Press enter or click to view image in full size

Pull Requests and Version Control

Models and Customization

Press enter or click to view image in full size

Productivity Utilities

Remote Control

Keyboard Shortcuts Cheat Sheet

Global Shortcuts

Timeline Shortcuts

Session Picker Shortcuts (when /resume is open)

Tool Availability and Permission Patterns

When you run Copilot CLI interactively or programmatically, you can precisely control which tools the agent is allowed to use. Tools come in categories:

Shell Tools

File Operation Tools

Agent and Task Delegation Tools

Other Tools

Press enter or click to view image in full size

Permission Patterns

The --allow-tool and --deny-tool flags accept patterns in the format Kind(argument):

Important: Deny rules always take precedence over allow rules, even when --allow-all is set.

# Allow all git commands except git push
copilot --allow-tool='shell(git:*)' --deny-tool='shell(git push)'

# Allow specific MCP tool
copilot --allow-tool='github(create_issue)'

# Allow everything from a named MCP server
copilot --allow-tool='MyMCP'

Environment Variables

Part II — CLI Plugins: Extending Copilot with Packages

Plugins allow you to bundle custom agents, skills, MCP server configurations, hooks, and even CLI commands into a single installable package. They are the distribution mechanism for Copilot CLI extensions — for your own team or for the wider community.

Plugin Commands

Terminal Commands (outside interactive session)

Plugin Install Specification Formats

plugin.json Reference

Get DhanushKumar’s stories in your inbox

Join Medium for free to get updates from this writer.

Every plugin must have a plugin.json file at its root. This manifest tells Copilot CLI what the plugin contains and where to find its components.

Required Field

Optional Metadata Fields

Component Path Fields

Example plugin.json

{
"name": "my-dev-tools",
"description": "React development utilities for our team",
"version": "1.2.0",
"author": {
"name": "Jane Doe",
"email": "jane@example.com"
},
"license": "MIT",
"keywords": ["react", "frontend", "typescript"],
"agents": "agents/",
"skills": ["skills/", "extra-skills/"],
"hooks": "hooks.json",
"mcpServers": ".mcp.json"
}

marketplace.json Reference

A marketplace is a curated list of plugins hosted in a GitHub repository (or local directory). Store marketplace.json in .github/plugin/ or .claude-plugin/ in your repository.

Plugin Entry Fields (within plugins array)

Example marketplace.json

{
"name": "acme-internal-plugins",
"owner": {
"name": "Acme Engineering",
"email": "eng-tools@acme.com"
},
"metadata": {
"description": "Internal Copilot CLI plugins for Acme developers",
"version": "1.0.0"
},
"plugins": [
{
"name": "frontend-design",
"description": "UI design utilities and component generators",
"version": "2.1.0",
"source": "plugins/frontend-design"
},
{
"name": "security-checks",
"description": "OWASP and internal security audit skills",
"version": "1.3.0",
"source": "plugins/security-checks"
}
]
}

/commands

Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

Loading Order and Precedence

When multiple plugins or configuration sources define the same agent, skill, or MCP server, Copilot CLI follows a deterministic precedence model:

Agents and Skills — first-found-wins:

  1. ~/.copilot/agents/ (user-level)
  2. <project>/.github/agents/ (project-level)
  3. <parents>/.github/agents/ (inherited from parent directories)
  4. <project>/.claude/agents/ (project-level)
  5. Plugin-provided agents (in install order)
  6. Remote org/enterprise agents

MCP Servers — last-wins:

  1. ~/.copilot/mcp-config.json (lowest priority)
  2. Plugin-provided MCP configs
  3. --additional-mcp-config flag (highest priority)

Key rule: Built-in tools and agents are always present and cannot be overridden by any user-defined configuration.

Programmatic Use: Scripting and CI/CD Automation

The programmatic mode turns Copilot CLI into a scriptable AI subprocess. You pass a prompt with -p, get a response to stdout, and the process exits cleanly — no interactive UI involved.

Core Programmatic Flags

Tool Filters and Fine-Grained Permissions

Model Selection and Precedence

You can specify which model handles a task — useful for balancing cost and capability across different CI jobs.

# Fast, cheap model for simple summary tasks
copilot -p "What does this project do?" -s --model claude-haiku-4.5

# Powerful model for deep reasoning tasks
copilot -p "Fix the race condition in the worker pool" \
--model gpt-5.3-codex \
--allow-tool='write,shell'

Model precedence order (highest to lowest):

  1. Model specified in the custom agent definition (if using --agent)
  2. --model command-line option
  3. COPILOT_MODEL environment variable
  4. model key in ~/.copilot/config.json
  5. CLI default model

You can set a persistent model and reasoning effort in ~/.copilot/config.json:

{
"model": "gpt-5.3-codex",
"reasoning_effort": "low"
}

Custom Agents in Headless Mode

# Use a custom code-review agent in programmatic mode
copilot -p "Review the latest commit" \
--allow-tool='shell' \
--agent code-review

Real-World Use Case Examples

Use Case 1: Daily Interactive Coding Session

# Launch a session from your project root
cd ~/projects/my-api
copilot

# Inside the session:
# > "Explain the auth middleware in src/middleware/auth.ts"
# > "Refactor it to use async/await instead of callbacks"
# > "/diff"
# > "/pr create"

Use Case 2: Autopilot Mode for Large Refactors

# Launch directly into autopilot mode — no confirmation prompts
copilot --autopilot --allow-all-tools --allow-all-paths \
-i "Migrate all console.log statements to use the Winston logger"

Use Case 3: CI/CD — Automated Code Quality Check

# .github/workflows/copilot-review.yml
- name: Copilot code review
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_TOKEN }}
run: |
copilot -p "Review the changed files in this PR for security issues and coding standards violations" \
--allow-tool='shell(git:*)' \
--allow-tool='read' \
--model claude-sonnet-4.6 \
--silent \
--share=review-output.md

Use Case 4: Scripted Batch Processing

#!/bin/bash
# Generate tests for all service files that lack test coverage

for service in src/services/*.ts; do
echo "Generating tests for $service..."
copilot -p "Write unit tests for $service. Place them in tests/ following the existing naming convention." \
-s \
--allow-tool='write,read' \
--allow-all-paths \
--no-ask-user
done

Use Case 5: Fleet Mode for Parallel Feature Work

# Inside interactive session:
/fleet "Implement the user authentication feature:
- Subagent 1: Create the JWT token service in src/auth/
- Subagent 2: Write the login and register API endpoints
- Subagent 3: Write unit tests for both"

Use Case 6: Deep Research on a Technical Topic

# Inside interactive session:
/research "What are the current best practices for rate limiting in Node.js APIs in 2025? Focus on Redis-based solutions."

Use Case 7: Remote Control from Mobile

# Start a session with remote access enabled
copilot --remote

# The CLI displays a session URL you can open in GitHub Mobile
# You can then send messages and monitor progress from your phone

Use Case 8: Installing and Using a Team Plugin

# An enterprise team registers their internal marketplace
copilot plugin marketplace add https://github.com/acme/copilot-plugins

# Browse available plugins
copilot plugin marketplace browse acme-copilot-plugins

# Install a specific plugin
copilot plugin install security-checks@acme-copilot-plugins

# Now the security audit agent is available in every session
copilot
# > "Run the security audit agent on the payment module"

Use Case 9: Session Export and Audit Trail

# Run a task and automatically export the full transcript
copilot -p "Analyze the database schema and suggest normalization improvements" \
--allow-all \
--share=./audit/copilot-db-analysis-$(date +%Y%m%d).md \
--silent

Use Case 10: Agentic Pull Request Management

# Inside interactive session on a feature branch:
/pr create

# Copilot will:
# 1. Analyze the diff
# 2. Generate a structured PR description
# 3. Link related issues
# 4. Open the PR on GitHub

Best Practices and Pro Tips

Start with Plan Mode for complex tasks. Use Shift+Tab or --mode=plan to have Copilot draft a plan before touching any files. This is the single best way to avoid unwanted changes.

Use /undo freely. Copilot CLI tracks checkpoints, so you can always roll back the last turn's file changes with /undo. Don't be afraid to let it try things.

Lock down tools in CI. Never use --allow-all in CI pipelines. Instead, explicitly list the exact tools the agent needs: --allow-tool='shell(git:*),write(src/*),read'. This creates a minimal-permission surface and makes your CI pipelines auditable.

Name your sessions. Use /rename or -n NAME to give sessions meaningful names. You'll thank yourself later when you want to /resume a specific session from three days ago.

Use /compact for long sessions. When the context window fills up on a long task, /compact summarizes the history into a tighter representation, reclaiming tokens without losing the thread of work.

Use @file and #issue for precision context. Rather than describing a file, just type @src/auth/middleware.ts in your prompt to inject the file's contents directly. Same for #123 to include a GitHub issue.

Redact secrets in programmatic mode. Always use --secret-env-vars to redact any tokens or passwords that might appear in logs: --secret-env-vars='DB_PASSWORD,AWS_SECRET_KEY'.

Store model preferences in config. Instead of always passing --model, set your preferred model once in ~/.copilot/config.json using the /model slash command. It persists across sessions.

Use plugins for team consistency. Package your team’s custom agents, shared skills, and MCP server configurations into a plugin and distribute via an internal marketplace. This ensures every developer gets the same capabilities without manual setup.

Monitor context usage. Use /context to see how full the context window is. On long exploratory tasks, periodically /compact to keep performance high and avoid context cutoff.

GitHub Copilot CLI is not just a terminal chat interface — it’s a composable, scriptable, extensible AI agent platform built for software developers. Here’s what you now know:

CLI Commands give you a full-featured terminal UI with rich slash commands for managing sessions, agentic modes, pull requests, model selection, MCP servers, and more. The keyboard shortcuts alone — from queueing messages to expanding timeline items to remote steering — make daily use significantly faster.

Plugins let you package and distribute custom agents, skills, and MCP configurations as installable packages. The plugin.json manifest and marketplace.json catalog enable team-level distribution without requiring every developer to manually configure their environment.

Programmatic mode transforms Copilot CLI into a CI/CD-native tool. With -p for prompts, -s for silent output, precise tool permission patterns, and model pinning, you can build AI-powered automation into GitHub Actions, shell scripts, and batch workflows with full auditability.

Together these three layers make GitHub Copilot CLI one of the most powerful developer productivity tools available — a genuine AI agent for the command line that you can customize, extend, and automate to fit exactly how you work.

--

--

DhanushKumar
DhanushKumar

Written by DhanushKumar

A guy who is curious to learn and blog ... Data Science @Deloitte AI | Data Science | Azure AI