AI / GitHub Copilot CLI Fundamentals Interview Questions
1. What is GitHub Copilot CLI and how does it differ from the deprecated gh copilot extension?
GitHub Copilot CLI is a standalone, terminal-native AI coding assistant that brings agentic capabilities directly to your command line. Invoked with the copilot command, it functions as an active collaborator capable of reading, modifying, and executing files, interacting with GitHub, and completing multi-step development tasks.
| Feature | New Copilot CLI (copilot) | Deprecated gh copilot extension (gh copilot) |
|---|---|---|
| Invocation | copilot | gh copilot suggest / gh copilot explain |
| Mode | Agentic - executes tasks autonomously | Command suggester - returned text to copy |
| File access | Yes - reads, writes, executes files | No - text output only |
| GitHub integration | Native - issues, PRs, branches | Basic - via gh CLI |
| Status | Active (generally available/public preview) | End-of-life: October 25, 2025 |
| Architecture | Standalone Node.js application | Extension on the gh CLI |
The fundamental distinction is philosophical: the old extension was a command suggester (proposes a shell command for the user to copy and run), while the new Copilot CLI is an agentic executor (understands goals, plans, and carries out the necessary commands and code changes itself).
2. What are the prerequisites for installing GitHub Copilot CLI?
Before installing Copilot CLI you must have the correct runtime environment, a valid Copilot subscription, and (if working within an organisation) the right admin policy enabled.
| Requirement | Detail |
|---|---|
| Node.js runtime | Node.js 22 or later must be installed |
| GitHub Copilot subscription | Any Copilot plan: Free, Pro, Pro+, Max, Business, or Enterprise |
| Organisation policy | If Copilot access comes through an organisation, the org admin must enable the 'Copilot CLI' policy in GitHub settings |
| Operating system | macOS, Linux, or Windows |
| Internet connection | Required for authentication and AI inference |
Organisation policy note: even if a user has a valid Copilot licence through their organisation, the CLI will not work if the organisation owner or enterprise administrator has disabled the Copilot CLI policy. This is a separate toggle from general Copilot access.
Copilot plans that include CLI: Copilot CLI is included as a core feature of all GitHub Copilot plans - there is no additional billing beyond the existing plan's AI Credits allowance.
3. How do you install GitHub Copilot CLI?
Copilot CLI can be installed through several methods depending on your operating system and preferences.
| Method | Command | OS |
|---|---|---|
| npm (recommended) | npm install -g @github/copilot | macOS, Linux, Windows |
| Install script (root) | curl -fsSL https://github.com/github/copilot-cli/releases/latest/download/install.sh | sudo bash | macOS, Linux |
| Install script (user) | curl -fsSL https://github.com/github/copilot-cli/releases/latest/download/install.sh | bash | macOS, Linux |
| Homebrew | brew install gh-copilot (check docs for current formula) | macOS |
| WinGet | winget install GitHub.CopilotCLI | Windows |
# npm installation (most common) npm install -g @github/copilot # Verify installation copilot --version # Install a specific version (using install script) curl -fsSL .../install.sh | VERSION=1.2.3 bash # Install to a custom directory (using install script) curl -fsSL .../install.sh | PREFIX=$HOME/.local bash # Installs to $HOME/.local/bin/
Install script options: The shell install script supports VERSION to pin a specific version and PREFIX to change the install directory. By default it installs to /usr/local/bin/ when run as root, or $HOME/.local/bin/ when run as a non-root user.
4. How do you authenticate GitHub Copilot CLI and what token types are supported?
Copilot CLI supports two authentication methods: an interactive browser-based flow (default) and a token-based flow for headless/automated environments.
| Method | How it works | Best for |
|---|---|---|
| Browser-based (default) | Run copilot or /login - browser opens for OAuth flow; token stored in system credential store | Interactive use on developer machines |
| Environment variable token | Set COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN env var | Headless automation, CI/CD, scripts |
# Method 1: Interactive browser flow (first time use) copilot # → prompted to /login if not authenticated # Follow on-screen browser authentication # Method 2: Fine-grained PAT in environment variable export COPILOT_GITHUB_TOKEN=github_pat_xxx copilot -p "List my open issues" # Method 3: Use GH_TOKEN or GITHUB_TOKEN (checked in order) export GH_TOKEN=your_token_here copilot -p "Explain this code"
Token type precedence (checked in order): COPILOT_GITHUB_TOKEN → GH_TOKEN → GITHUB_TOKEN.
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
- Classic personal access tokens (ghp_) are NOT supported
When no credential store is found, the token is saved as plain text in ~/.copilot/ (or the path set by COPILOT_HOME).
5. What is the directory trust model in GitHub Copilot CLI and why does it exist?
Copilot CLI has the ability to read, modify, and execute files in your working directory - which poses a security risk if you run it in an untrusted location (e.g. a directory containing malicious files). The directory trust model requires you to explicitly confirm trust before Copilot can act on files.
When you run copilot in a directory for the first time, you are presented with a trust prompt with three options:
| Option | Effect |
|---|---|
| 1. No | Copilot CLI exits - no files in this directory are accessed |
| 2. Yes, for this session only | Copilot can work with files in this folder for the current session only - asked again next time |
| 3. Yes, and remember this folder | Copilot trusts this folder permanently for all future sessions - not asked again when starting from this folder |
# Starting Copilot CLI in a directory for the first time: $ copilot During this GitHub Copilot CLI session, Copilot may attempt to read, modify, and execute files in and below this folder. Do you trust the files in this folder? > 1. No 2. Yes, for this session only 3. Yes, and remember this folder for future sessions
Why it matters: if you navigate into a directory containing maliciously crafted files and run Copilot CLI, those files could potentially influence the AI to execute harmful commands. The trust model ensures you consciously acknowledge the risk before granting Copilot file access.
6. How do you start an interactive Copilot CLI session and what are the two main usage modes?
Copilot CLI has two usage modes: an interactive session (the default) and a non-interactive / programmatic mode using the -p flag.
# Mode 1: Interactive session cd my-project copilot # → trust prompt → REPL-style interface opens # Type prompts, use slash commands, use keyboard shortcuts # Mode 2: Non-interactive / single prompt copilot -p "How do I undo a git commit without losing changes?" # → prints the answer and exits # Mode 2 with silent output (response only, no extra info) copilot -p "Explain git rebase" -s # Use -p in scripts for AI-powered automation SUMMARY=$(copilot -p "Summarise the changes in git diff HEAD~1" -s) echo "$SUMMARY"
| Mode | Command | Use case |
|---|---|---|
| Interactive | copilot | Ongoing coding sessions, multi-turn conversations, task execution |
| Non-interactive | copilot -p "prompt" | Scripts, automation, one-off questions, CI/CD integration |
| Silent non-interactive | copilot -p "prompt" -s | Capture only the AI response in a shell variable |
Inside an interactive session: you can type natural language prompts, use slash commands (e.g. /help, /model, /pr), use keyboard shortcuts (e.g. Shift+Tab to cycle between modes), and browse GitHub tabs - all without leaving the terminal.
7. What are slash commands in GitHub Copilot CLI and what are the most important ones?
Slash commands are special instructions you type inside an interactive Copilot CLI session (prefixed with /) to control behaviour, switch context, or trigger specific actions.
| Command | Purpose |
|---|---|
| /? or /help | List all available slash commands and keyboard shortcuts |
| /login | Authenticate with your GitHub account |
| /logout | Sign out of GitHub |
| /model | View or change the AI model for the current session |
| /model auto | Let Copilot pick the best available model automatically |
| /init | Generate or update a copilot-instructions.md file for the repo |
| /init suppress | Permanently hide the 'no instructions found' startup message for this repo |
| /pr | View, create, and fix pull requests from the terminal |
| /fleet | Spawn subagents to speed up multi-step implementation plans |
| /delegate | Ask Copilot to work autonomously on a task (similar to autopilot) |
| /chronicle | Query session history, get standup reports, usage insights |
| /experimental show | Enable access to experimental/preview features |
| /mcp | Manage MCP (Model Context Protocol) server connections |
# Inside an interactive session: /help # show all commands /model # list available models /model claude-3-7-sonnet # switch to a specific model /model auto # let Copilot auto-select /init # generate copilot-instructions.md /pr # open PR management interface /chronicle # session history insights
8. What are the operating modes in GitHub Copilot CLI and how do you switch between them?
Copilot CLI has three operating modes that control how autonomously the agent works. You cycle between them using Shift+Tab.
| Mode | Behaviour | When to use |
|---|---|---|
| Chat (default) | Conversational mode - answers questions, explains code, discusses approaches without executing commands | General Q&A, planning, getting advice |
| Plan | Copilot outlines a step-by-step plan for a task before executing anything - you can review and adjust the plan | Complex tasks where you want to verify the approach before Copilot acts |
| Autopilot | Copilot works autonomously until the task is complete without asking for step-by-step approval - it continues on its own after each step | Delegated tasks where you trust Copilot to handle the full implementation |
# Keyboard shortcut: Shift+Tab to cycle through modes # Chat → Plan → Autopilot → Chat → ... # You can also trigger via command /delegate # switches to autopilot-style autonomous execution # Launch with experimental flag to access all modes copilot --experimental # Then use /experimental show to see available preview features
Autopilot mode is one of the most powerful features - it encourages the agent to continue working until a task is fully completed without requiring human approval at each step. It is recommended for well-defined tasks where you have high confidence in the AI's direction.
Note: Autopilot mode requires the experimental features flag to be enabled. Once activated, the setting persists in your config so you don't need --experimental on subsequent launches.
9. What is the copilot-instructions.md file and how does it affect Copilot CLI behaviour?
The copilot-instructions.md file is a repository-level configuration file that provides Copilot with persistent custom instructions about your project - such as build commands, test procedures, architecture notes, and coding conventions. Copilot CLI reads this file automatically on startup.
# Generate copilot-instructions.md for your project /init # Copilot scans the repo and proposes content covering: # - Build, test, and lint commands # - High-level architecture overview # - Conventions and project-specific notes # If the file already exists, /init suggests improvements # You can accept or reject individual suggestions # Suppress the startup message if you don't want the file /init suppress # Example copilot-instructions.md content: # ## Build # npm run build # # ## Test # npm test # # ## Architecture # This is a React frontend with a Node.js Express backend...
What it typically documents:
- Build, test, and lint commands
- High-level architecture description
- Key directories and their purpose
- Coding conventions and style guidelines
- Deployment notes
Startup behaviour: if no copilot-instructions.md is found, Copilot CLI displays: 💡 No copilot instructions found. Run /init to generate a copilot-instructions.md file for this project. You can permanently suppress this message with /init suppress.
10. How does model selection work in GitHub Copilot CLI?
Copilot CLI supports multiple AI models and provides several ways to select or switch models - at launch, during a session, or automatically.
# Select a model at launch with --model flag copilot --model claude-3-7-sonnet # Use auto to let Copilot pick the best available model copilot --model auto # Or set via environment variable export COPILOT_MODEL=gpt-4o copilot # Switch model during an interactive session /model # list available models /model gpt-4o # switch to a specific model /model auto # switch to auto-selection # /model is also useful for comparing approaches: # Run the same prompt with different models to see # which handles your use case better
Auto model selection: passing auto lets Copilot automatically pick the best available model for each task. This is the recommended setting if you don't have a specific preference, as Copilot can route different request types to the most appropriate model.
Available models depend on your Copilot plan. Higher-tier plans (Business, Enterprise, Pro+, Max) have access to a wider range of models. Use /model inside a session to see which models are currently available to your account.
11. What is the /pr slash command in GitHub Copilot CLI and what can it do?
The /pr slash command lets you manage GitHub pull requests directly from the terminal without switching to a browser or using the gh CLI separately.
| Action | Description |
|---|---|
| View PRs | Browse open pull requests in the current repository |
| Create PR | Open a pull request from the current branch with an AI-generated description |
| Fix PR | Ask Copilot to address review comments or CI failures on an existing PR |
| Review PR | Get AI-generated code review suggestions for a PR |
| Create branch + PR in one command | copilot lets you implement a change and open a PR with a single natural language request |
# Inside an interactive Copilot CLI session: /pr # browse and manage PRs # One-command branch + implement + PR workflow: # "Create a branch, add input validation to the login form, and open a PR" # → Copilot creates the branch, makes the code change, opens the PR # Fix review comments on an existing PR: /pr # → navigate to the PR → ask Copilot to address feedback # Non-interactive: create PR from current branch copilot -p "Create a pull request for the current branch with a summary of changes" -s
Branch protections and policies: Copilot CLI respects your repository's branch protection rules, required status checks, and organisation policies - it cannot bypass these even when creating PRs autonomously. Copilot Business or Enterprise settings apply automatically.
12. What is the /fleet slash command and what problem does it solve?
The /fleet command allows Copilot CLI to spawn multiple subagents that work in parallel on different parts of a complex implementation plan. This dramatically speeds up multi-step tasks that would otherwise need to be executed sequentially.
# Example: implement a feature with multiple independent components /fleet # Copilot divides the work into parallel sub-tasks: # Subagent 1: Update the database schema # Subagent 2: Write unit tests # Subagent 3: Update API documentation # All run simultaneously - dramatically faster than sequential # You can monitor progress from GitHub.com or mobile # while /fleet coordinates the subagents in the background
How /fleet works:
- Copilot analyses your task and identifies parts that can be worked on in parallel
- It spawns subagents, each with their own context and tool access
- Results are coordinated and merged
- You stay in control - you can monitor, steer, and merge from GitHub.com or GitHub Mobile
Typical use case: large features that span multiple files or subsystems - e.g. adding a new API endpoint (requires schema change + controller + tests + docs). Without fleet, Copilot does these sequentially; with fleet, they run in parallel.
13. What is remote control in GitHub Copilot CLI and how does it work?
Remote control allows you to monitor and interact with a running Copilot CLI session from GitHub.com or GitHub Mobile, even after you have stepped away from your terminal.
# Enable remote control when starting a session copilot --remote # Or connect to an existing task by ID copilot --remote --resume TASK-ID # Remote export (share output remotely without full session control) copilot --remote-export # Connect to a specific remote session copilot --connect
Remote control use cases:
- Start a long-running task on your laptop, walk away, monitor progress on your phone
- Respond to Copilot's questions or approve steps from GitHub.com without returning to the terminal
- Hand off a session to a colleague who can continue it from GitHub.com
- Resume a remote task locally - works even if the task was originally created outside a Git repository
Requirements: the remote sessions feature must be available on your account. The --remote, --no-remote, --remote-export, --no-remote-export, and --connect options all require this feature.
14. What are Copilot CLI hooks and what can they be used for?
Hooks are user-defined scripts that Copilot CLI invokes automatically at specific points during a session - for example, before or after Copilot modifies files. They let you inject custom logic (validation, notifications, formatting) into the Copilot workflow without modifying the agent's core behaviour.
| Aspect | Detail |
|---|---|
| Configuration | Defined in the Copilot CLI config or a hooks configuration file |
| Hook events | Pre-task, post-task, pre-file-write, post-file-write, and others depending on the version |
| Input payload | Hooks receive a JSON payload describing the current action |
| Decision control | Hooks can allow, block, or modify Copilot's planned actions |
| Use cases | Auto-format code after edits, run linters, send Slack notifications, enforce security policies |
# Example hook: run prettier after every file write # hooks config (format may vary - check docs for current schema) hooks: post-file-write: - command: "npx prettier --write {file}" description: "Auto-format after Copilot edits" # Example hook: block writes to sensitive paths # A hook can inspect the planned file path and return # a decision to allow or deny the write
For detailed information about hooks - including configuration formats, supported events, input payloads, and decision control - see the GitHub Copilot hooks reference in the official documentation.
15. What is the AGENTS.md file and how does it differ from copilot-instructions.md?
Both files customise how Copilot behaves in a repository, but they serve different purposes and have different scopes.
| Feature | AGENTS.md | copilot-instructions.md |
|---|---|---|
| Purpose | Define custom instructions and tool access for agentic sessions - used by Copilot when working autonomously | Provide project context: build commands, architecture, conventions for all Copilot interactions |
| Scope | Agentic/autonomous sessions (Plan, Autopilot, /fleet) | All Copilot CLI sessions including chat |
| Contents | Agent behaviour rules, which skills/tools are permitted, task-specific instructions | Build commands, test commands, architecture overview, coding style |
| Cross-session consistency | Ensures behaviour stays consistent across models, sessions, and delegated work | Ensures Copilot has project context on every session |
| Generated by | Created manually or by /init for agent-specific needs | Generated or updated by /init |
When to use each:
- Use copilot-instructions.md to give Copilot general project knowledge that applies to all interactions (how to build, test, understand the codebase)
- Use AGENTS.md to define the rules and constraints for autonomous agent sessions specifically - what tools an agent can use, what actions it should or shouldn't take, task-specific behavioural guidelines
16. What is the /chronicle slash command and what session history features does it provide?
The /chronicle command gives you access to a searchable history of all your Copilot CLI sessions. Instead of losing context between sessions, Copilot builds a persistent record that you can query in natural language.
| Feature | Description |
|---|---|
| Session history search | Query past sessions using natural language - e.g. 'find the session where I fixed the auth bug' |
| Standup reports | Generate a summary of what you worked on yesterday or this week |
| Personalised tips | Get suggestions based on patterns in your CLI usage history |
| Resume previous work | Identify a past session and pick up where you left off |
| Usage insights | Understand which models, commands, and workflows you use most |
# Inside an interactive Copilot CLI session: /chronicle # → opens session history interface # Example queries inside /chronicle: "What did I work on yesterday?" "Find the session where I added pagination to the API" "Generate a standup report for this week" "Show me tips based on how I've been using Copilot" # Resume a specific past session copilot --resume SESSION-ID
Why it matters: developer context is often lost between terminal sessions. /chronicle makes your AI-assisted work history queryable and actionable - turning session logs from a passive record into an active productivity tool. You can generate daily standup notes in seconds rather than reconstructing what you did from git logs.
17. What is MCP (Model Context Protocol) support in Copilot CLI and how do you use it?
Model Context Protocol (MCP) is an open standard that allows AI models to connect to external tools and data sources through a standardised interface. Copilot CLI supports MCP via the /mcp slash command, allowing you to extend it with a rich ecosystem of third-party integrations.
# Manage MCP server connections inside a Copilot CLI session /mcp # view connected MCP servers /mcp add <server-name> # connect a new MCP server /mcp remove <server-name> # disconnect an MCP server # GitHub's own native MCP server # /mcp includes github - lets Copilot work with: # - Issues and pull requests # - Branches and commits # - Repository metadata # All through the MCP protocol
Why MCP matters: without MCP, Copilot CLI's tool access is limited to local file system, shell, and GitHub.com. With MCP servers you can connect Copilot to:
- Databases (query schema, run migrations)
- Monitoring tools (query logs, dashboards)
- Issue trackers (Jira, Linear)
- Cloud providers (AWS, GCP tools)
- Community-built integrations
GitHub's native MCP server is built in and lets Copilot work with GitHub issues, branches, and pull requests programmatically - not just through file edits. This is described as the preferred way to interact with GitHub resources in Copilot CLI.
18. What is the COPILOT_HOME environment variable and where does Copilot CLI store its config?
Copilot CLI stores configuration, cached data, and authentication tokens in a dedicated directory. By default this is ~/.copilot/ but you can override the location with the COPILOT_HOME environment variable.
| Item | Default location | Override |
|---|---|---|
| Config directory | ~/.copilot/ | Set COPILOT_HOME=/path/to/dir |
| Auth token (no credential store) | ~/.copilot/ (plain text) | Avoided if system credential store available |
| Trusted directories list | Stored in config directory | N/A |
| Session history | Stored in config directory | N/A |
| MDM configuration | System-managed path | Refer to GitHub Copilot CLI configuration directory docs |
# Override the config directory location export COPILOT_HOME=/custom/path/.copilot copilot # COPILOT_HOME is useful for: # - Running multiple Copilot CLI instances with separate configs # - Storing config in a non-home directory (e.g. shared CI environment) # - Pointing to a network-mounted config for team consistency # - Isolating config in containerised/ephemeral environments # Default credential storage preference: # 1. System credential store (keychain on macOS, etc.) - most secure # 2. Plain text ~/.copilot/config - fallback if no credential store found
Security note: Copilot CLI prefers the system credential store (macOS Keychain, Windows Credential Manager, etc.) for token storage. If no credential store is detected, it falls back to a plain text file in the config directory - this is less secure and Anthropic recommends ensuring a credential store is available on developer machines.
19. What are experimental features in Copilot CLI and how do you enable them?
Copilot CLI has a set of preview/experimental features that are not enabled by default. These are features GitHub is actively developing and may change based on feedback. Enabling experimental features unlocks capabilities before they reach general availability.
# Method 1: Launch with the --experimental flag copilot --experimental # Once activated, the setting persists in config # Subsequent launches do NOT need --experimental # Method 2: Use the slash command inside a session /experimental show # → displays and enables available experimental features # Check what experimental features are currently available /experimental show # Lists current preview features you can opt into
Key experimental feature - Autopilot mode: autopilot is introduced as an experimental feature (press Shift+Tab to cycle to it). Once you have enabled experimental features, autopilot persists as an available mode.
Important: experimental features are subject to change, may be incomplete, and could be removed or significantly altered before reaching GA. They are best suited for personal developer machines rather than production workflows.
20. What is AI Credits billing in GitHub Copilot CLI and how does it work?
GitHub Copilot CLI draws on your plan's AI Credits allowance rather than being charged separately. Every interaction with the agent - submitting a prompt - reduces your monthly AI Credits quota by one premium request.
| Aspect | Detail |
|---|---|
| Billing model | Included in all Copilot plans - no additional subscription needed |
| Cost per interaction | Each prompt submitted to Copilot CLI reduces your monthly premium request quota by one |
| Plan differences | Higher plans (Pro+, Max, Business, Enterprise) have larger premium request allowances |
| Overage | If you exceed your allowance, behaviour depends on your plan (blocked or billed at overage rate) |
| Tool calls within a session | Tool calls within a single agent turn may count differently - check current docs |
Copilot CLI is included in all Copilot plans: Free, Pro, Pro+, Max, Business, and Enterprise. There is no separate CLI subscription. The CLI competes for the same AI Credits pool as other Copilot features (chat, code completion, etc.).
Practical tip: long agentic sessions with many tool calls and back-and-forth exchanges consume more AI Credits than short Q&A prompts. Monitor your usage in GitHub settings if you are on a plan with limited premium requests.
21. How does Copilot CLI read and understand repository context?
Copilot CLI builds its understanding of your codebase from several sources - the directory you run it in, the files it reads during a session, project configuration files, and the copilot-instructions.md file.
| Source | What Copilot learns |
|---|---|
| copilot-instructions.md | Build commands, test procedures, architecture overview, conventions |
| AGENTS.md | Agent behavioural rules, tool permissions for autonomous sessions |
| Directory structure | Project layout, frameworks, languages in use |
| Files read during session | Full content of files explicitly opened or referenced in the task |
| Git history and diffs | Recent changes, branch context, commit messages |
| GitHub.com data | Issues, PRs, CI results - accessed via native GitHub integration or MCP |
# Copilot CLI reads context progressively during a session # It does NOT index the entire codebase upfront # To give Copilot specific context: "Look at src/auth/login.ts and explain the authentication flow" # → Copilot reads that file and builds context from it # For large codebases, guide Copilot to the relevant files: "The bug is in the payment processing module in src/payments/" # → Copilot narrows its file reading to that directory # copilot-instructions.md reduces the need for repeated context: # Instead of explaining your stack every session, put it in the file
Context limits: like all LLM-based tools, Copilot CLI has a context window limit. For very large files or repositories, it reads selectively. Providing clear, targeted prompts and maintaining a well-written copilot-instructions.md reduces the risk of Copilot operating with incomplete context.
22. What are the keyboard shortcuts available in an interactive Copilot CLI session?
Copilot CLI provides keyboard shortcuts that speed up navigation and mode switching inside an interactive session, reducing the need to type slash commands for common operations.
| Shortcut | Action |
|---|---|
| Shift+Tab | Cycle between Chat, Plan, and Autopilot modes |
| Enter | Submit current prompt |
| Ctrl+C | Cancel the current Copilot action or exit the session |
| Up / Down arrow | Navigate through prompt history (previous prompts in the session |
| Tab | Autocomplete slash command names |
| /? or /help | List all available commands and shortcuts |
# Starting an interactive session to practice shortcuts copilot # → Shift+Tab to cycle modes: # [Chat] → [Plan] → [Autopilot] → [Chat] → ... # → Type /? to see all shortcuts # → Use Up arrow to recall previous prompts # → Press Tab after / to autocomplete slash commands # Key workflow tip: # Start in Chat to discuss approach # Shift+Tab to Plan to review the plan before execution # Shift+Tab to Autopilot to let Copilot run it autonomously
Most important shortcut - Shift+Tab: this is the primary way to switch modes without typing a command. Mastering when to use Chat vs Plan vs Autopilot via Shift+Tab is one of the most impactful productivity skills for Copilot CLI power users.
23. What is the difference between GitHub Copilot CLI and Copilot in VS Code?
Both are AI coding assistants powered by GitHub Copilot, but they target different workflows and environments.
| Dimension | GitHub Copilot CLI | GitHub Copilot in VS Code |
|---|---|---|
| Interface | Terminal / command line | IDE (graphical editor) |
| Primary strength | Agentic task execution - multi-step, multi-file autonomous work | Inline completions, chat in editor, code actions at the cursor |
| File handling | Reads and writes files via shell and bash tool | Edits files via VS Code's editor API |
| GitHub integration | Native - issues, PRs, branches via /pr and MCP | Via GitHub Pull Requests extension |
| Offline capability | No - requires API connection | No - requires API connection |
| Best for | DevOps tasks, refactoring, feature implementation, CI workflows | Inline code completion, quick edits, chat about specific code |
| Billing | Shared AI Credits pool | Same shared AI Credits pool |
Complementary tools: Copilot CLI and Copilot in VS Code are not competitors - they complement each other. A typical workflow might use VS Code Copilot for active editing and inline suggestions, then switch to Copilot CLI for larger, autonomous tasks like refactoring a module or setting up a CI/CD pipeline.
24. What is GitHub Copilot Workspace and how does it differ from Copilot CLI?
GitHub Copilot Workspace is a browser-based, GitHub-native environment for planning and executing larger tasks driven by issues and pull requests. It is distinct from Copilot CLI, which is terminal-native.
| Dimension | Copilot CLI | Copilot Workspace |
|---|---|---|
| Interface | Terminal | GitHub.com browser interface |
| Entry point | A task or natural language prompt in the terminal | A GitHub issue or pull request |
| Execution environment | Your local machine (files, shell) | GitHub-managed cloud environment |
| Agentic capability | Yes - autopilot, fleet, hooks | Yes - multi-step planning and coding from issue to PR |
| Best for | Local development, DevOps, CI integration | Issue-driven feature development, reviewing and implementing GitHub tasks |
| Requires local setup | Yes - Node.js 22+, auth | No - runs entirely in the browser on GitHub.com |
Key distinction: Copilot CLI operates on your local machine and is best for terminal-centric workflows. Copilot Workspace operates entirely within GitHub.com and is driven by GitHub issues - you can go from a bug report or feature request to an open pull request without leaving the browser.
25. What are common Copilot CLI troubleshooting steps and how do you debug issues?
When Copilot CLI behaves unexpectedly - authentication errors, tool failures, or unexpected responses - a structured set of checks resolves most issues.
| Symptom | Likely cause | Fix |
|---|---|---|
| 'Not authenticated' error | No valid token found | Run copilot and complete /login, or set COPILOT_GITHUB_TOKEN |
| 'Organisation policy' error | CLI not enabled for your org | Ask org admin to enable Copilot CLI in org settings |
| Classic PAT rejected | ghp_ tokens are not supported | Use a fine-grained PAT with Copilot Requests permission |
| Copilot ignores project context | No copilot-instructions.md | Run /init to generate the file |
| Session crashes on large repo | Context window exceeded | Use targeted prompts; guide Copilot to specific files |
| Trust prompt on every launch | 'Yes for this session' selected | Reselect 'Yes, remember this folder' to persist trust |
| /mcp server not connecting | MCP server config incorrect | Check /mcp and review server connection settings |
| Outdated model / responses seem off | Old version of Copilot CLI | npm update -g @github/copilot |
# Common diagnostic commands copilot --version # check installed version copilot -p "hello" -s # quick test of auth + model # Update Copilot CLI npm update -g @github/copilot # Re-authenticate copilot /logout /login # Check which token is being used echo $COPILOT_GITHUB_TOKEN echo $GH_TOKEN
For persistent issues, GitHub's Copilot CLI documentation includes a dedicated troubleshooting section, and you can open GitHub Support tickets for plan or policy-related authentication failures.
26. How does Copilot CLI differ between Copilot Individual, Business, and Enterprise plans?
All Copilot plans include access to Copilot CLI, but the plans differ in available models, premium request limits, and administrative controls.
| Feature | Free / Pro | Pro+ / Max | Business | Enterprise |
|---|---|---|---|---|
| Copilot CLI access | Yes | Yes | Yes | Yes |
| Model selection | Limited | Wider selection | Wider selection | Widest selection |
| Monthly AI Credits | Lower allowance | Higher allowance | Per-seat allowance | Per-seat allowance (highest) |
| Organisation policy controls | N/A | N/A | Admin can enable/disable CLI | Admin can enable/disable CLI |
| Audit logs for CLI usage | No | No | Yes | Yes |
| IP indemnification | No | No | Yes | Yes |
| Data excluded from training | No | No | Yes (promptless) | Yes (promptless) |
Data privacy note: for Business and Enterprise plans, prompts and completions are not used to train GitHub or OpenAI models by default. For Free and Pro plans, data may be used for model improvement unless you opt out in GitHub settings.
Policy controls: only Business and Enterprise org admins can enable or disable the Copilot CLI policy for their organisations. Individual plan users are not subject to org-level restrictions (unless they are also members of a Business/Enterprise org that restricts CLI).
27. How do you use Copilot CLI effectively with private repositories?
Copilot CLI works with private repositories the same way it works with public ones - the local file system access means it reads private files directly without sending them to GitHub. However, when using GitHub-integrated features like /pr or MCP, your token must have the appropriate private repository permissions.
# Working with a private repository is straightforward: git clone https://github.com/myorg/private-repo.git cd private-repo copilot # → Trust prompt → session starts with access to all local files # Copilot reads your private code locally - it doesn't # upload your entire repo to GitHub to enable CLI features # For /pr on a private repo, your token needs: # - repo scope (classic PAT) OR # - Contents: read + Pull requests: write (fine-grained PAT) # Fine-grained PAT setup for private org repo: export COPILOT_GITHUB_TOKEN=github_pat_xxx # Token needs: Copilot Requests + Contents (read) + Pull requests (write) # for full CLI + PR functionality on private repos
Security considerations for private repos:
- Copilot CLI reads private files locally - the content it reads for local tasks stays in your AI inference session and is governed by your plan's data policy
- For Business/Enterprise plans, private code is not used for training
- Prompts containing private code snippets are governed by GitHub's data handling policies
- The trust prompt is especially important in private repos - ensure only authorised users can start Copilot sessions in sensitive directories
28. What are best practices for writing effective prompts in GitHub Copilot CLI?
The quality of Copilot CLI's output is directly related to the clarity and specificity of your prompt. Well-structured prompts reduce back-and-forth and get you to working code faster.
| Principle | Example |
|---|---|
| Specify the task clearly | 'Add input validation to the email field in src/forms/signup.tsx - reject addresses without @ and a domain' |
| Include the context path | 'Look at src/api/auth.ts and add rate limiting to the /login endpoint' |
| Mention constraints | 'Add the feature without modifying existing tests' |
| Describe the expected outcome | 'The result should pass all existing tests and add new tests for the validation logic' |
| Break large tasks into phases | Use Plan mode to review a step-by-step plan before Autopilot executes it |
# Vague prompt (avoid) "Fix the bug" # Better prompt "The login form throws a TypeError when the email field is empty. Fix the bug in src/components/LoginForm.tsx - the issue is in the handleSubmit function around line 45." # Best prompt for complex task - use Plan mode # Shift+Tab to Plan mode, then: "Refactor the payment processing module in src/payments/ to use the new Stripe SDK v5 API. The old SDK used client.charges.create(); the new SDK uses client.paymentIntents.create(). Preserve all existing error handling and update the relevant unit tests." # → Copilot produces a plan for review before executing
Pro tip - use Plan mode for risky changes: before letting Copilot execute a significant refactor or delete files, switch to Plan mode (Shift+Tab) and review the proposed steps. This catches misunderstandings before they cause unintended changes.
29. How can you use GitHub Copilot CLI in CI/CD pipelines and automation workflows?
Copilot CLI's non-interactive mode (-p) and environment variable authentication make it suitable for use in CI/CD pipelines, GitHub Actions, and shell scripts - enabling AI-powered automation at scale.
# GitHub Actions example: AI-powered PR summary on every PR name: Copilot PR Summary on: pull_request: types: [opened] jobs: summarise: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: "22" - run: npm install -g @github/copilot - name: Generate PR summary env: COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_TOKEN }} run: | SUMMARY=$(copilot -p "Summarise the changes in this diff for a PR description" -s) echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY # Shell script: AI-powered code review check #!/bin/bash export COPILOT_GITHUB_TOKEN="$COPILOT_TOKEN" REVIEW=$(copilot -p "Review the changes in git diff HEAD~1 for security issues" -s) if echo "$REVIEW" | grep -qi "security concern"; then echo "Security review flagged issues:" echo "$REVIEW" exit 1 fi
CI/CD best practices with Copilot CLI:
- Always use environment variable authentication - never hardcode tokens
- Store the token as an encrypted secret in your CI system
- Use
-s(silent) flag to capture clean output for downstream processing - Trust prompts do not appear in non-interactive mode - CI environments are automatically trusted
- Use fine-grained PATs with minimum required permissions
30. What security considerations should developers be aware of when using GitHub Copilot CLI?
Copilot CLI is a powerful agentic tool that can read, modify, and execute code. This power introduces security considerations that every developer and organisation should understand before adopting it.
| Risk | Mitigation |
|---|---|
| Malicious files in untrusted directories | Use the directory trust model - never select 'Yes' in untrusted or downloaded directories without inspection |
| Prompt injection via file contents | Be cautious with repos from unknown sources - malicious files can contain instructions that try to hijack Copilot's actions |
| Token security | Use fine-grained PATs with minimum permissions; rotate tokens regularly; store in system credential store |
| Data privacy | Business/Enterprise plans exclude data from training; Free/Pro users should review GitHub's data usage settings |
| Runaway agent actions | Use Plan mode to review before Autopilot executes risky changes; Ctrl+C to stop at any time |
| CI/CD secret exposure | Never log COPILOT_GITHUB_TOKEN; use encrypted secrets in CI systems |
| Scope of file access | Copilot only accesses files in and below the trusted directory - structure your repos accordingly |
Prompt injection warning: if you run Copilot CLI in a directory containing adversarially crafted files (e.g. a malicious repository), those files could contain embedded instructions designed to make Copilot take unintended actions. The directory trust model is the primary defence - only trust directories you control and have inspected.
31. What is the --delegate flag and how does the /delegate slash command work?
The /delegate slash command and --delegate flag allow you to hand off a task to Copilot for fully autonomous execution - similar to Autopilot mode but often used to initiate a delegation from the command line or during a session when you want to step away entirely.
# Delegate a task from the command line copilot --delegate "Implement pagination for the /api/users endpoint, add tests, and open a pull request when done" # Inside an interactive session: /delegate # → Copilot switches to full autonomous execution # → You can monitor from GitHub.com or GitHub Mobile # → Use --remote to enable remote monitoring alongside delegation # Combine delegation with remote control: copilot --delegate "Refactor the payment module" --remote # → Task runs autonomously AND you can monitor/steer it remotely
Delegate vs Autopilot: Autopilot mode (via Shift+Tab) keeps you in the session and cycles step approvals automatically. Delegation goes one step further - you explicitly hand the task over and can walk away, with Copilot working until the task is complete. Remote control (--remote) complements delegation by letting you check in from anywhere.
Best uses for delegation: long-running tasks (implementing a feature, writing comprehensive tests, refactoring a module) where you want to continue other work or step away from the computer while Copilot makes progress.
32. What logging and diagnostic capabilities does GitHub Copilot CLI provide?
Copilot CLI provides several mechanisms for understanding what is happening during a session - from verbose logging to dry-run previews - useful for debugging, auditing, and understanding agent behaviour.
# Enable verbose/debug logging copilot --log-level debug # Write logs to a file copilot --log-file ./copilot-debug.log # Non-interactive with logging copilot -p "explain this code" --log-level debug -s # Check version and build info copilot --version # Use /chronicle for session-level history and insights /chronicle "Show me everything Copilot did in the last session" "What tools did Copilot use during this session?"
| Option | Purpose |
|---|---|
| --log-level debug | Verbose output showing tool calls, API requests, decision logic |
| --log-file | Write log output to a file instead of (or in addition to) stdout |
| --version | Print the installed Copilot CLI version |
| /chronicle | Query past sessions, view what was done, get usage patterns |
| copilot -p ... -s | Non-interactive with clean output - useful for scripted diagnostics |
Debug logging is particularly useful when Copilot CLI is not behaving as expected - it shows what tools were called, what inputs they received, and what the model decided at each step, giving full visibility into the agent's reasoning loop.
33. What does GitHub Copilot CLI's diff and undo capability provide?
After Copilot makes file modifications, Copilot CLI provides review and undo capabilities so you can inspect changes before committing them or roll back actions that produced unexpected results.
# After Copilot edits files, review the diff # Copilot CLI shows a diff view of changes made in the session # Review changes with standard git tooling git diff # see all changes Copilot made git diff src/api/users.ts # changes to a specific file # Undo all changes Copilot made in the session git checkout . # restore all tracked files git clean -fd # remove any new untracked files Copilot created # Selective undo - restore just one file git checkout src/api/users.ts # Copilot CLI also shows inline diffs during Plan mode # before executing - use Plan mode (Shift+Tab) to preview # changes before they are applied # Best practice: commit your work before a Copilot session git add -A && git commit -m "WIP: state before Copilot session" # → Easy rollback point if Copilot makes unwanted changes
Best practice before any Copilot CLI session: commit your current work or stash it (git stash). This gives you a clean rollback point - if Copilot's changes are not what you wanted, a single git checkout . undoes everything since the commit.
34. What are the Windows-specific considerations for GitHub Copilot CLI?
Copilot CLI is supported on Windows but has some differences compared to macOS and Linux that developers should know about - particularly around the shell environment and tool execution.
| Aspect | Windows | macOS/Linux |
|---|---|---|
| Shell | PowerShell or Command Prompt (cmd) | bash/zsh/fish |
| Installation | npm install -g @github/copilot OR winget install GitHub.CopilotCLI | npm, brew, install script, or WinGet |
| Bash tool | Requires Windows Subsystem for Linux (WSL) or Git Bash for full bash support | Native bash available |
| Credential store | Windows Credential Manager | macOS Keychain / Linux secret service |
| Path separator | Backslash (\) - Copilot accounts for this | Forward slash (/) |
| Terminal recommendation | Windows Terminal with WSL2 | Any modern terminal |
# Windows installation via WinGet winget install GitHub.CopilotCLI # Or via npm (requires Node.js 22+ on Windows) npm install -g @github/copilot # Using Copilot CLI in PowerShell copilot -p "How do I list all running processes in PowerShell?" -s # For full agentic (bash tool) support on Windows # install WSL2 and run Copilot CLI from within WSL: wsl npm install -g @github/copilot copilot
The bash tool (used by Copilot for executing shell commands during agentic tasks) requires a bash environment. On Windows, Copilot CLI can run without full bash tool support for chat and planning tasks, but for full agentic execution (especially tasks that involve running build/test commands), running under WSL2 provides the best experience.
35. What is the full list of GitHub Copilot CLI command-line flags and their purposes?
Understanding the complete flag set allows you to use Copilot CLI effectively in both interactive and scripted contexts. Flags are passed at launch to configure the session or a single non-interactive call.
| Flag | Description |
|---|---|
| --version | Print the installed version and exit |
| -p, --prompt | Run a single non-interactive prompt and exit |
| -s, --silent | Suppress extra output - print only Copilot's response (use with -p) |
| --model | Specify the AI model to use (or 'auto' for automatic selection) |
| --experimental | Enable experimental/preview features |
| --no-experimental | Disable experimental features (override persisted setting) |
| --remote | Enable remote control - monitor and interact from GitHub.com/Mobile |
| --no-remote | Disable remote control for this session |
| --remote-export | Share output remotely without full session control |
| --no-remote-export | Disable remote export |
| --resume | Resume a specific previous or remote task by ID |
| --connect | Connect to an existing remote session |
| --delegate | Delegate a task for autonomous execution |
| --log-level | Set logging verbosity (debug, info, warn, error) |
| --log-file | Write log output to the specified file |
| -h, --help | Show help and all available flags |
# Common flag combinations: # Run a quick question non-interactively copilot -p "What is the difference between let and const in JS?" -s # Start a session with a specific model copilot --model gpt-4o # Delegate a task with remote monitoring copilot --delegate "Add pagination to /api/users" --remote # Resume a task from the command line copilot --resume task-abc123 # Debug a failing session copilot --log-level debug --log-file ./debug.log
36. How does GitHub Copilot CLI integrate with GitHub issues?
Copilot CLI can work directly with GitHub issues - reading issue details, using issue context to guide implementation, and linking completed work back to issues through pull requests.
# Reference a GitHub issue directly in your prompt copilot -p "Implement the feature described in issue #42 in this repository" # Or inside an interactive session: "Look at issue #123 and implement the requested change in src/" # Copilot will: # 1. Fetch the issue details from GitHub # 2. Understand the requirements from the issue body and comments # 3. Implement the changes in the relevant files # 4. Optionally open a PR that references the issue # Link a PR to close an issue automatically: "Implement issue #42 and open a PR that will close it when merged" # → Copilot adds "Closes #42" to the PR description
GitHub integration depth: Copilot CLI accesses GitHub issues via the GitHub API using your authenticated token. It can read the issue title, description, labels, and comments to build context. For organisations using GitHub Projects, Copilot can reference the broader project context when available.
Issue-to-PR workflow: one of Copilot CLI's most powerful workflows is going from a GitHub issue directly to a merged PR without manual intermediate steps - the agent reads the issue, plans the implementation, writes the code, runs tests, and opens the PR, all from a single prompt.
37. What are the key differences when using Copilot CLI on macOS vs Linux?
Copilot CLI runs on both macOS and Linux with near-identical behaviour - the differences are primarily in installation methods, credential storage, and system integration rather than core features.
| Aspect | macOS | Linux |
|---|---|---|
| Install (recommended) | npm install -g @github/copilot OR brew install (check docs) | npm install -g @github/copilot OR install script |
| Install script default dir | Uses PREFIX or /usr/local/bin | Uses PREFIX or /usr/local/bin |
| Credential store | macOS Keychain (most secure) | libsecret / GNOME Keyring / KWallet (if available) |
| Fallback credential | ~/.copilot/ plain text | ~/.copilot/ plain text (common in servers/containers) |
| Package manager option | Homebrew (brew) | apt/dnf/pacman (no official package - use npm) |
| Containerised use | Uncommon | Common - Docker, GitHub Actions runners |
# macOS: Homebrew installation (if available) brew install gh-copilot # check docs for current formula # Linux: npm installation npm install -g @github/copilot # Linux server (headless): use token auth export COPILOT_GITHUB_TOKEN=github_pat_xxx copilot -p "Summarise the git log from the last week" -s # Linux container: install script non-root curl -fsSL .../install.sh | PREFIX=$HOME/.local bash export PATH="$HOME/.local/bin:$PATH" copilot --version
On Linux servers and CI environments (headless, no UI, no keychain), plain text credential storage to ~/.copilot/ or COPILOT_HOME is the default fallback. Always use environment variable authentication in these environments rather than the interactive login flow.
38. What is the overall workflow for using Copilot CLI on a real development task from start to finish?
Combining all Copilot CLI features into an end-to-end workflow demonstrates how the tool fits into professional development practice.
# ── End-to-end Copilot CLI workflow ────────────────────────────── # 1. Set up the project for Copilot CLI cd my-project copilot # → Trust prompt: "Yes, and remember this folder" /init # → Copilot generates copilot-instructions.md with build/test commands # 2. Discuss the task in Chat mode # [Chat mode is active by default] "I need to add pagination to the GET /api/products endpoint. We use Express + Prisma. How should I approach this?" # → Copilot gives advice; refine as needed # 3. Switch to Plan mode to review steps # Press Shift+Tab once "Implement pagination with limit and offset query params, add Swagger docs, and write Jest unit tests" # → Copilot outlines steps for review - inspect and confirm # 4. Execute with Autopilot mode # Press Shift+Tab again "Go ahead and implement the plan" # → Copilot implements autonomously # 5. Review the changes git diff # If happy: git add -A git commit -m "feat: add pagination to GET /api/products" # 6. Open a pull request /pr "Create a PR for this branch with a summary of what was added" # → Copilot opens PR with AI-generated description # 7. Review session history /chronicle "What did I implement today?"
This workflow demonstrates the full spectrum: Chat (discuss) → Plan (review) → Autopilot (execute) → git review → /pr (publish). Copilot CLI compresses what would previously require multiple context switches (editor, terminal, browser) into a single terminal workflow.
