Copilot CLI Commands Reference
This document provides detailed information about all GitHub Copilot CLI commands.
Main Commands
login
Authenticate with GitHub Copilot via OAuth device flow.
copilot login [options]When to use:
- First-time setup
- Re-authentication after token expiration
- Switching GitHub accounts
Example:
copilot logininit
Initialize Copilot instructions for the current repository.
copilot initWhat it does:
- Creates
.copilot/AGENTS.mdorAGENTS.mdin the repository - Allows you to define custom instructions for this project
- Instructions are automatically loaded when running Copilot in this directory
When to use:
- Setting up project-specific guidelines
- Defining coding standards for a team
- Creating custom workflows for a repository
Example:
cd ~/my-project
copilot init
# Edit AGENTS.md with project-specific instructionsupdate
Download and install the latest version of Copilot CLI.
copilot updateWhen to use:
- Manually updating to the latest version
- When auto-update is disabled
Note: Auto-update is enabled by default. Use --no-auto-update to disable.
version
Display version information and check for available updates.
copilot versionOutput includes:
- Current CLI version
- Update availability status
- Installation path
help
Display help information for Copilot CLI or specific topics.
copilot help [topic]Available topics:
config- Configuration settingscommands- Interactive mode commandsenvironment- Environment variableslogging- Logging configurationpermissions- Permission system details
Examples:
copilot help
copilot help config
copilot help permissionsplugin
Manage plugins and plugin marketplaces.
copilot plugin [subcommand]Note: Plugin system allows extending Copilot CLI with additional functionality. See plugin documentation for details.
Interactive Mode Commands
When inside an interactive Copilot session, the following slash commands are available:
/help
Display available interactive commands.
/share
Share the current session to a markdown file or GitHub gist.
/share [path]
/share gist/clear
Clear the current conversation context while remaining in the session.
/exit or /quit
Exit the interactive session.
/model
Switch the AI model during an interactive session.
/model claude-sonnet-4.5
/model gpt-5/retry
Retry the last agent response with a different approach.
Command Execution Modes
Interactive Mode
Start a persistent conversation session:
# Basic interactive
copilot
# Start with a prompt
copilot -i "Fix the authentication bug"
# Interactive with specific model
copilot --model claude-opus-4.5 -i "Design the new API architecture"Characteristics:
- Maintains conversation context
- Allows multiple back-and-forth interactions
- Can resume later
- Supports slash commands
- Ideal for exploration and complex tasks
Non-Interactive Mode
Execute a single prompt and exit:
copilot -p "Fix the bug in main.js" --allow-all-toolsCharacteristics:
- Single execution, then exits
- Returns exit code (0 = success, non-zero = failure)
- Perfect for automation and scripting
- Requires explicit permission grants
- Can save output with
--share
Session Resume
Continue a previous session:
# Resume most recent
copilot --continue
# Resume with picker
copilot --resume
# Resume specific session
copilot --resume <session-id>Characteristics:
- Restores full conversation context
- Continues from last message
- Maintains permissions from original session (unless overridden)
Command-Line Execution Flow
- Authentication Check: Verifies GitHub Copilot access
- Permission Setup: Applies --allow-, --deny- flags
- Custom Instructions: Loads AGENTS.md if present and not disabled
- Model Initialization: Loads specified model (or default)
- MCP Server Setup: Initializes enabled MCP servers
- Execution: Runs prompt or starts interactive session
- Cleanup: Saves session, logs, shares output if requested
Exit Codes
0: Success1: General error2: Authentication error3: Permission denied4: Invalid arguments130: User interrupt (Ctrl+C)
Use exit codes for error handling in scripts:
if copilot -p "Run tests" --allow-all; then
echo "Tests passed"
else
echo "Tests failed with code $?"
fiEnvironment Integration
Working Directory
Copilot CLI uses the current working directory as context:
cd ~/my-project
copilot -p "Fix all TypeScript errors" --allow-allGit Integration
Automatically detects:
- Current branch
- Repository status
- Recent commits
- Staged/unstaged changes
Use this for branch-aware operations:
git checkout -b feature/new-auth
copilot -p "Implement OAuth2 authentication" --allow-allCustom Instructions
Place AGENTS.md or .copilot/AGENTS.md in your repository:
# Project Instructions
This is a TypeScript project using React and Node.js.
## Code Standards
- Use functional components with hooks
- Prefer async/await over promises
- Write tests for all features
## Development Workflow
- Create feature branches from main
- Write tests before implementation
- Run linter before committingCopilot will automatically apply these instructions in this directory.