◀ Playbook index
NO.14

Copilot CLI

Updated: 2026-07-22

In a nutshell

Copilot CLI is Copilot living inside the terminal.

It helps you ask, plan, edit, and execute — just like Copilot in VS Code. But it has CLI-specific features and harness, so let's explore those together.

Key Features

A full-stack AI environment packed into a single terminal.

  • Multi-file context awareness: Treats the entire repository as a single workspace.
  • Code generation & editing: Make edits from the terminal, review diffs, and approve.
  • Command execution: Run builds, tests, lint, and more — read the results and proceed.
  • IDE-agnostic: Works anywhere there’s a terminal: VS Code, Vim, over SSH, etc.
  • Skills / MCP support: Add the capabilities and external tools you need.
  • Non-interactive execution: Run via CI, cron, or scripts with copilot -p "...".

CLI vs VS Code Chat

Copilot CLIVS Code Chat
UIVery lightweight. Terminal-centric, so there’s a learning curve for commands and a minimal editor UI. On the other hand, since the CLI opens instantly, it’s easy to work with local computer resources like folders, PowerPoint, and Excel files.Easier to handle options, settings, file navigation, inline diffs, and the debugger on screen.
Speed of new featuresNew experiments like /chronicle, /fleet, /share, and Rubber Duck tend to land here first.More stability-oriented. Often adopts good ideas that matured in the CLI.
Sub-agentsHas many built-in agents — Explore, Task, Rubber Duck, Code Review — and can launch them natively.Currently limited, but gradually catching up.
Session managementFine-grained session control with /context, /compact, /session, etc.Improving, but not as granular as the CLI right now.
Partner agentsCopilot CLI runs within Copilot’s harness. Codex / Claude harnesses are not available — you can use their models, but not their native harnesses.Inside VS Code, it’s easy to switch between Copilot, Codex, Claude, and other agents / extensions.
IndexPrimarily uses terminal/search tools like grep, rg, and workspace commands.Can use richer editor-side indexes like Blackbird.

Powerful Built-in Agents

Copilot CLI includes built-in agents for common tasks.

AgentDescription
ExploreQuickly analyzes the codebase and lets you ask questions about it, without adding it to the main context.
TaskRuns commands like tests and builds, returning a short summary on success or the full output on failure.
General purposeHandles complex multi-step tasks that require all tools and advanced reasoning, in a separate context from the main conversation.
Code reviewReviews code changes focusing solely on issues that genuinely matter, minimizing noise.
ResearchConducts deep research across the codebase, related repositories, and the web, producing detailed reports with citations.
Rubber duckReturns constructive critical feedback for complex tasks. Used automatically by Copilot CLI.

💡 You can inspect these built-in agents’ definitions in your local CLI install at definitions/*.agent.yaml (e.g. ~/.copilot/pkg/darwin-arm64/<version>/definitions/*.agent.yaml).

Rubber Duck — Cross-model Review

🦆 Experimental: A different model family from the main model provides a “second opinion” as a constructive critic, independently reviewing each phase of planning, implementation, and testing.

flowchart LR
  User([👤 Developer])
  Main["🧠 Main Model<br/>e.g. Claude"]
  Out["📝 Plan / Implementation / Test"]
  Duck["🦆 Rubber Duck<br/>e.g. GPT-5.4"]
  Final([✅ Verified output])
  User --> Main
  Main --> Out
  Out -->|"Independent review"| Duck
  Duck -->|"Blind spots / wrong assumptions"| Main
  Main --> Final

  classDef user fill:#0a1a14,stroke:#9bbc0f,color:#9bbc0f,stroke-width:2px
  classDef main fill:#0a0e27,stroke:#00f0ff,color:#00f0ff,stroke-width:2px
  classDef duck fill:#1a1500,stroke:#ffb000,color:#ffb000,stroke-width:2px
  classDef out fill:#1a0a2e,stroke:#ff2e88,color:#ff2e88,stroke-width:2px
  class User,Final user
  class Main main
  class Duck duck
  class Out out

Why does it work? ── When the same model checks its own output, it gets caught by the same assumptions and the same blind spots. A model from a different family has different training data and different values, so it can catch logic errors that were invisible to the first model.

Other Useful Commands

The CLI lets you instantly check models, sharing, experimental features, and environment info via slash commands.

CommandWhen to use
/helpCheck available commands and shortcuts.
/modelCheck or switch the model in use.
/ideConnect to an IDE such as VS Code.
/shareShare the current session.
/experimentalCheck and enable experimental features.
/chronicleReview the session history and work log.
/taskCheck agents and tasks running in the background.
/askConsult Copilot as a question before proceeding.
/envCheck the environment information visible to the CLI.

🖥️ TUI (Terminal UI)

Run /experimental on to try the redesigned terminal UI with theme-aware semantic colors — check them with /theme. Inside a GitHub repository, use Tab to move between the menus in the table below.

TabWhat’s in it
SessionThe normal interactive session (default)
IssuesBrowse the repository’s issues
Pull requestsBrowse pull requests
GistsBrowse your personal gists

📝 Screen-reader support and many other UI improvements landed too — see the changelog ↗.

🛡️ Sandbox — Safe Execution Environment

Copilot runs the shell commands it executes inside an isolated environment, restricting access to your filesystem, network, and system — so you can hand off agentic work with confidence. (Public preview)

🖥️ Local sandbox☁️ Cloud sandbox
Enable/sandbox enable in a sessioncopilot --cloud
Runs onYour machine (isolated)GitHub-hosted ephemeral Linux
Built onMicrosoft MXCAzure Container Apps Sandboxes
SupportmacOS / Linux (Windows on Insiders)Any device
PolicyCentrally managed via Intune / MDMInherits Cloud Agent policies
  • 🔒 What’s isolated: filesystem / network / system capabilities for Copilot-initiated shell execution.
  • 🔁 Cloud keeps state: Active → Stopped (snapshot) → Deleted. Resume from another device and run heavy tasks in parallel.
  • 🧩 Same auth: uses your Copilot CLI sign-in — no separate cloud setup required.

Non-interactive Mode (Programmatic Execution) ★

Copilot CLI can be run with a single command using copilot -p "...". It executes one turn and exits without opening an interactive session, so it can be called from shell scripts, cron, batch files, and GitHub Actions. Delegate routine work — PR auto-review, lint fixes, release notes — to Copilot whenever a human doesn’t need to be in the loop.

Key flags

  • -p "..." / --prompt "..." — Pass a prompt and exit after one turn
  • -s (silent) — Output response text only to stdout (ideal for variable assignment or piping)
  • --no-ask-user — Skip clarifying questions; make decisions autonomously
  • --allow-tool='shell(npm:*), write' — Allow only the necessary tools (--allow-all is for sandboxes only)
  • --model gpt-5.5 — Pin the model to reduce variance
  • --share='./session.md' — Save the entire session as Markdown

Common use cases

  • 📝 Commit message generation / 📰 Release note drafting
  • 🐛 Bulk lint error fixes / 🧪 Tests for untested modules
  • 🔍 AI PR review (script /review) / 🔐 Dependency vulnerability audit
  • 📚 Bulk README & JSDoc generation / 🌏 Document translation

Operational tips

  • 🔑 Pass auth via env vars: COPILOT_GITHUB_TOKENGH_TOKENGITHUB_TOKEN
  • 🧾 Use fine-grained PAT (v2) with the “Copilot Requests” permission (old ghp_ format isn’t supported)
  • 🛡️ --allow-tool with a whitelist is the rule. Never use --allow-all outside a sandbox
  • 🎯 Be specific in prompts — pinning the output format (“Number only.”, “YES/NO”) makes parsing easy
  • 📊 Save sessions with --share so you can trace the reasoning behind results later
  • 🧩 Iterate the prompt in interactive mode first, then port it to -p once it’s solid

📘 Details: