I’ve been using GitHub Copilot CLI for a few weeks now, and it has significantly enhanced my productivity beyond what Copilot in IDEs already provides. In this post, I’ll share my experience and practical tips to help you maximize this powerful terminal-based AI assistant.
NOTE: GitHub Copilot CLI is in public preview. Features may change before general availability.
What is GitHub Copilot CLI?
GitHub Copilot CLI brings AI-powered assistance directly to your terminal, similar to the IDE experience but optimized for command-line workflows. It stays unobtrusive until needed and excels for developers who prefer terminal-based work. Beyond code completions, Copilot CLI enables powerful automation capabilities—you can run prompts in CI/CD pipelines, background jobs, or any automated workflow.
Important: AI output is not deterministic. Always review AI-generated content before implementation.
Prerequisites
Before getting started, ensure you have:
- Node.js v22+ and npm v10+
- GitHub Copilot Pro or Enterprise license
- Copilot CLI enabled on your GitHub account or organization
- At least one AI model enabled (e.g., Claude Sonnet 4.5, GPT-4o, or Gemini 2.5 Pro)
Getting Started
Install GitHub Copilot CLI globally using npm:
| |
Launch Copilot CLI in your project directory:
| |
Authenticate with your GitHub account:
| |
You’re now ready to use Copilot CLI!
Basic Usage
Copilot CLI offers multiple interaction methods:
- Slash commands: Type
/to see available commands. - Inline prompts: Type your prompt directly in the terminal.
- Files and folders: Reference files or folders in your prompts for context.
Try these examples to get started:
| |
Using Custom Agents
Custom agents are pre-configured AI personas designed for specific tasks. Create agents by defining their behavior in markdown files within the .github/agents folder. Here’s an example agent for blog content review:
| |
Agents configured for GitHub repositories work seamlessly in Copilot CLI as well.
Best Practices for Custom Agents:
- Be specific: Clearly define what the agent should and shouldn’t do
- Focus the scope: The example above explicitly prevents new content creation, focusing on refinement only
- Specialize when needed: For mono-repos, create language-specific agents for better code reviews
- Learn from examples: Check the Awesome Copilot repository for inspiration
Use the /agent command to leverage custom agents in the CLI:
| |
Using MCP Servers
Model Context Protocol (MCP) servers extend Copilot CLI’s capabilities by enabling interaction with local and external services. While GitHub MCP is enabled by default, you can install additional MCP servers to streamline your workflow.
Manage MCP servers with the /mcp command:
| |
For example, add the Playwright MCP server for browser automation:
| |

With the playwright MCP server added, you can take screenshots of web pages directly from the terminal:
| |
Delegate Tasks to Remote Agents
The /delegate command enables you to offload tasks to specialized remote agents on GitHub.com, perfect for complex or time-consuming operations.
| |
This creates an Agent Session where you can iterate and refine results. Copilot CLI provides a link to monitor progress, and upon completion, generates a draft pull request for review.


Using Copilot CLI in CI/CD and Background Jobs
Copilot CLI excels at tasks requiring reasoning without strict determinism, such as report analysis. The example below demonstrates using Copilot CLI in GitHub Actions to analyze certificate expiration reports and automatically create issues.
WARNING: Grant Copilot CLI only the minimum privileges necessary. The more capabilities provided, the greater the risk of unintended actions. Always implement appropriate safeguards.
Setup Steps:
- Create a fine-grained GitHub token with Copilot Requests access
- Add the token as a
COPILOT_GITHUB_TOKENrepository secret - Create a workflow file with the configuration below:
| |
Advanced: You can also use MCP servers in non-interactive mode, though the configuration requires additional parameters:
| |

Alternatives
While GitHub Copilot CLI offers robust features, several alternatives worth considering include:
- Claude Code - Agentic workflow with strong privacy controls and repo-wide multi-file edits
- Codex CLI - OpenAI’s command-line tool for code generation and assistance
- Gemini CLI - Google’s Gemini model in a terminal interface
Each tool has unique strengths, choose based on your privacy requirements, budget, ecosystem, and workflow preferences.
Additional Resources
What’s your experience with GitHub Copilot CLI? Have you discovered unique use cases or created custom agents? Share your thoughts in the comments below!
Cheers,
Lucas
