The AI coding agent in your terminal. Master interactive sessions, model selection, permissions, MCP integration, and automation workflows.
Quick Reference
copilot Start interactive sessioncopilot -p "..." Single-shot promptcopilot --continue Resume last sessioncopilot --resume Browse sessionscopilot login Authenticatecopilot update Update to latest/help Show commands/model Switch model/compact Compress context/clear Reset context/review Review code changes/delegate Send to coding agent/share gist Export as Gist--yolo All permissions--allow-all-tools Auto-approve tools--allow-all-paths All file access--allow-tool "..." Specific tool (glob)--deny-tool "..." Block tool (precedence)claude-opus-4.6 Deep reasoningclaude-sonnet-4.5 Balanced defaultgpt-5.2-codex Code generationgpt-5-mini Fast & free*gemini-3-pro-preview Data & analytics--enable-all-github-mcp-tools GitHub tools--add-dir [path] Add directory--additional-mcp-config Custom MCP/add-dir Add dir in session01 / Setup
Install GitHub Copilot CLI via npm:
npm install -g @github/copilot
Alternatively, install as a GitHub CLI extension:
gh extension install github/gh-copilot
gh copilot
Authenticate with your GitHub account:
copilot login
For automated environments, use a Personal Access Token with the "Copilot Requests" permission:
# Set token as environment variable
export GH_TOKEN=your_token_here
# or
export GITHUB_TOKEN=your_token_here
# For credential managers
export GITHUB_ASKPASS=/path/to/executable/that/returns/token
Non-interactive workflows respect the GH_HOST environment variable for GitHub Enterprise Server authentication.
copilot init # Initialize configuration
copilot version # Check installed version
copilot update # Update to latest version
copilot help # View available commands
02 / Core Experience
copilot # Start interactive session (default)
copilot --continue # Resume most recent session
copilot --resume # Browse and resume sessions
Type / during an interactive session to see all available commands. Here is the full reference:
/help Display command help and descriptions/clear Reset conversation context/exit End session cleanly/session Show session metrics (duration, changes)/usage Display token usage statistics/resume ID Resume a specific session by ID/compact Manually compress context/cwd Display or change working directory/cd Change directory (tab completion)/add-dir Grant access to a directory/list-dirs Show directory permissions/model Switch AI model mid-session/review Analyze staged/unstaged changes/delegate Push to Copilot coding agent (opens draft PR)/agent NAME Invoke a custom agent/share Export session to markdown/share gist Create GitHub Gist (prompts for visibility)/feedback Submit product feedback| Shortcut | Action |
|---|---|
| Tab | Autocomplete paths in /cwd and /add-dir |
| Shift+Tab | Toggle plan mode (collaborative planning before implementation) |
| Ctrl+T | Toggle model reasoning visibility (supported models) |
| Ctrl+C | Cancel current operation |
Press Shift+Tab to enter plan mode. Copilot will analyze your request, ask clarifying questions, and build a structured implementation plan before writing any code. This is ideal for major refactors or complex features.
"Plan before you build, steer as you go." Plan mode enables collaborative planning with step-by-step approval before any code changes are made.
03 / Automation
Use the -p (or --prompt) flag for single-shot execution, perfect for scripting and CI/CD pipelines.
copilot -p "your prompt here"
copilot --prompt "your prompt here"
# Find information
copilot -p "List all open issues assigned to me in OWNER/REPO"
# Code generation
copilot -p "Generate unit tests for main.js"
# Code analysis
copilot -p "Find all TODO comments in src/ directory"
# Pipe input to Copilot
echo "Explain this code" | copilot -p
# Chain with other tools
copilot -p "Run tests" --allow-all-tools
# Export results to file
copilot -p "Analyze code quality" --share > report.md
# Automated quality check in pipeline
copilot -p "Run full test suite and generate coverage report" \
--allow-all-tools \
--share-gist \
--model gpt-5-mini
Always use --allow-all-tools or specific --allow-tool patterns in automated contexts to bypass interactive approval prompts.
04 / Models
Choose the right model for your task. Switch at launch with --model or mid-session with /model.
Deep reasoning, complex system design, architecture decisions, greenfield projects.
Balanced speed and capability. Great general-purpose development model.
Lightweight Claude variant for quick, simple tasks.
Latest high-performance code generation model.
Maximum capability codex variant for demanding workloads.
Fast and lightweight. Does not consume premium requests on paid plans.
Reliable GPT-4.1. Does not consume premium requests.
Other available models: gpt-5.2, gpt-5.1-codex, gpt-5.1, gpt-5, gpt-5.1-codex-mini
Data transformation, analytics, and multimodal tasks.
Start with claude-sonnet-4.5 for balanced performance. Switch to claude-opus-4.6 for architecture decisions. Use gpt-5-mini for high-volume simple tasks. Try gemini-3-pro-preview for data-heavy work. Use /model to switch mid-session as task complexity changes.
05 / Security
Copilot CLI uses a layered permission system. By default, each tool execution requires interactive approval. Use flags to grant broader access.
# Allow specific tools (glob patterns supported)
--allow-tool "shell(npm run test:*)"
--allow-tool "read"
# Deny specific tools (takes precedence over allow)
--deny-tool "shell"
--deny-tool "write(*.env)"
# Auto-approve all tool executions
--allow-all-tools
# Allow access to all file paths
--allow-all-paths
# Grant directory access in session
/add-dir /path/to/directory
# Allow specific URL patterns
--allow-url "https://api.example.com/*"
# Deny URL patterns
--deny-url "https://internal.corp/*"
URL permission rules also affect commands like curl and wget executed through the shell tool.
| Flag | Effect |
|---|---|
| --allow-all | Enable all permissions at once |
| --yolo | Same as --allow-all (trust Copilot to run freely) |
| --allow-all-tools | Auto-approve all tool executions |
| --allow-all-paths | Allow access to any file path |
| --allow-all-urls | Allow all URL access |
# Secure code review (read-only, no shell)
copilot -p "Review security in auth module" \
--allow-tool "read" \
--deny-tool "shell" \
--allow-all-paths
# Enterprise-safe automation (specific tools only)
copilot -p "Deploy to staging" \
--allow-tool "shell(kubectl *)" \
--allow-tool "shell(docker *)" \
--deny-url "*" \
--config-dir /etc/copilot
# Fast prototyping (full trust)
copilot --yolo --model claude-opus-4.6
06 / Extensibility
Model Context Protocol (MCP) is an industry-standard protocol that allows Copilot CLI to integrate with custom context providers and external tools.
MCP servers are configured in ~/.copilot/mcp-config.json:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "my-mcp-server"],
"env": {
"API_KEY": "your-key"
}
}
}
}
The built-in GitHub MCP server provides tools for issues, PRs, repositories, and Copilot Spaces:
# Enable all GitHub MCP tools
copilot --enable-all-github-mcp-tools
# Add a specific tool
copilot --add-github-mcp-tool github_search_code
# Add a toolset (e.g., all issue-related tools)
copilot --add-github-mcp-toolset issues
| Flag | Description |
|---|---|
| --additional-mcp-config [path] | Load additional MCP config file |
| --add-github-mcp-tool [tool] | Add specific GitHub MCP tool |
| --add-github-mcp-toolset [set] | Add GitHub MCP toolset |
| --enable-all-github-mcp-tools | Enable all GitHub MCP tools |
| --disable-builtin-mcps | Disable built-in MCP servers |
| --disable-mcp-server [name] | Disable specific MCP server |
Define custom servers at the user level (~/.copilot/mcp-config.json), in organization/enterprise agent profiles, or via the --additional-mcp-config flag.
Start with the GitHub MCP toolset for common needs. Add custom MCP servers for specialized tools. Test configurations with simple prompts first before using in automation.
07 / Continuity
# Resume the most recently closed session
copilot --continue
# Browse and pick from local and remote sessions
copilot --resume
# Resume a specific session by ID (in interactive mode)
/resume SESSION-ID
~/.copilot/session-state/Automatic compression: When approaching 95% of the token limit, Copilot automatically compresses history in the background without interruption. This enables virtually infinite sessions.
# Manually compress context anytime
/compact
# Reset context completely
/clear
# In interactive mode
/share
# As a CLI flag (exports on completion)
copilot -p "..." --share
# In interactive mode (prompts for visibility, description, filename)
/share gist
# As a CLI flag
copilot -p "..." --share-gist
Exports include timestamp, model used, token usage, and full conversation history with formatting preserved.
With GitHub Enterprise Cloud and data residency enabled, Gist creation may be restricted by organization policy.
08 / Customization
Copilot CLI loads instructions from multiple sources, in order of priority:
$HOME/.copilot/copilot-instructions.md
.github/copilot-instructions.md
.github/instructions/**/*.instructions.md
CLAUDE.md # Claude-specific
GEMINI.md # Gemini-specific
AGENTS.md # Agent definitions
# Set via environment variable (comma-separated)
export COPILOT_CUSTOM_INSTRUCTIONS_DIRS="/path/to/dir1,/path/to/dir2"
Repository-level instructions take precedence and enforce team conventions. Instructions are cached; restart CLI or use /resume after editing.
Create specialized agents using Markdown files with YAML frontmatter:
# ~/.copilot/agents/test-agent.md
---
name: test-agent
description: Runs tests and analyzes failures
tools:
- shell
- read
---
Always run tests with verbose output.
If failures occur, analyze stack traces and suggest fixes.
~/.copilot/agents/ — User-level agents.github/agents/ — Repository-level agents{org}/.github/agents/ — Organization-level agents# Invoke a custom agent in interactive mode
/agent my-agent
# Invoke the explore agent
/agent explore
Plugins extend Copilot CLI with custom agents, MCP servers, skills, and LSP configurations.
# Manage plugins
copilot plugin [command]
Plugin sources include GitHub repositories, direct URLs, and local file paths. The copilot-plugins repository serves as a centralized registry.
# Ignore all custom instruction files for this session
copilot --no-custom-instructions
09 / Reference
| Command | Description |
|---|---|
| copilot login | Authenticate with GitHub |
| copilot help | Display help information |
| copilot init | Initialize configuration |
| copilot update | Update to latest version |
| copilot version | Show version information |
| copilot plugin | Manage plugins |
| Flag | Description |
|---|---|
| -i, --interactive | Start interactive session (default) |
| -p, --prompt [text] | Non-interactive mode with single prompt |
| --agent | Agent mode (orchestrator with system prompt) |
| --acp | Start as ACP (Agent Client Protocol) server |
| --acp --port [num] | Start ACP server in TCP mode on port |
| Flag | Description |
|---|---|
| --model [name] | Specify AI model to use |
| --continue | Resume most recently closed local session |
| --resume | Cycle through and resume local/remote sessions |
| --share | Export session to markdown on completion |
| --share-gist | Export session to GitHub Gist on completion |
| Flag | Description |
|---|---|
| --allow-tool [tools...] | Allow specific tools (glob patterns supported) |
| --deny-tool [tools...] | Deny specific tools (takes precedence) |
| --allow-all-tools | Auto-approve all tool executions |
| --allow-all-paths | Allow access to any file path |
| --allow-url [patterns...] | Allow URL patterns |
| --deny-url [patterns...] | Deny URL patterns |
| --allow-all-urls | Allow all URL access |
| --allow-all | Enable all permissions |
| --yolo | Enable all permissions (alias) |
| Flag | Description |
|---|---|
| --additional-mcp-config [path] | Load additional MCP config file |
| --add-github-mcp-tool [tool] | Add specific GitHub MCP tool |
| --add-github-mcp-toolset [set] | Add GitHub MCP toolset |
| --enable-all-github-mcp-tools | Enable all GitHub MCP tools |
| --disable-builtin-mcps | Disable built-in MCP servers |
| --disable-mcp-server [name] | Disable specific MCP server |
| Flag | Description |
|---|---|
| --add-dir [path] | Grant access to specific directory |
| --config-dir [path] | Specify config directory (default: ~/.copilot) |
| --no-custom-instructions | Ignore custom instruction files |
| --experimental | Enable experimental features |
10 / Mastery
Be specific about requirements and provide examples:
copilot -p "Refactor AuthService to use dependency injection. \
Current implementation uses singletons. Preserve existing test coverage."
Press Shift+Tab before implementing major features. Copilot asks clarifying questions, builds a structured plan, and you approve before execution.
# Start fast with sonnet
copilot --model claude-sonnet-4.5
# Switch mid-session when hitting complex decisions
/model
# Select claude-opus-4.6
# Back to fast model for iterations
/model
# Select gpt-5-mini
Create specialized agents for recurring workflows:
# ~/.copilot/agents/security-review.md
---
name: security-review
description: Reviews code for security vulnerabilities
tools:
- read
---
Analyze code for OWASP Top 10 vulnerabilities.
Focus on authentication, input validation, and data exposure.
Report findings with severity levels.
As you work, Copilot stores coding standards, project structure insights, and your preferred approaches. This makes future sessions progressively more productive.
#!/bin/bash
copilot -p "
1. Run eslint on src/
2. Run prettier --check
3. Run unit tests
4. Generate summary report
" --allow-all-tools --share > quality-report.md
#!/bin/bash
while true; do
copilot --continue --model claude-sonnet-4.5
read -p "Continue? (y/n) " choice
[[ "$choice" != "y" ]] && break
done
#!/bin/bash
copilot -p "Review changes in $(git diff --name-only)" \
--model claude-opus-4.6 \
--share-gist > review-url.txt
echo "Review shared at: $(cat review-url.txt)"
/compact before starting major new tasks within a session/clear to reset context when switching projects--allow-tool patterns for specific commands rather than blanket access--yolo for trusted local environments only/session periodically~/.copilot/copilot-instructions.md) for personal preferences.github/copilot-instructions.md) for team standardsAGENTS.md) for specialized workflows--continue to resume work immediately after breaks/share to document important sessions for future reference/share gist for sharing discoveries with your team# In interactive mode - pushes session to GitHub,
# opens draft PR, makes changes in background
/delegate
# Use the explore agent to ask questions
# without cluttering your main context
/agent explore
"How is authentication implemented?"
"Find all database queries in services/"
# Start as Agent Client Protocol server
copilot --acp
# Or with TCP mode on a specific port
copilot --acp --port 3000
This allows third-party tools, IDEs, and automation systems to integrate with Copilot's agentic capabilities.
# Central config for team
export COPILOT_CUSTOM_INSTRUCTIONS_DIRS="/opt/company/copilot-config"
# Run with enterprise settings
copilot --config-dir /etc/copilot \
--additional-mcp-config /etc/copilot/enterprise-mcp.json