--- title: Getting started with GitHub Copilot CLI shortTitle: Copilot CLI quickstart intro: Quickly learn how to use {% data variables.copilot.copilot_cli %}. allowTitleToDifferFromFilename: true product: '{% data reusables.gated-features.copilot-cli %}' versions: feature: copilot redirect_from: - /copilot/how-tos/copilot-cli/cli-getting-started contentType: get-started category: - Build with Copilot CLI - Quickstarts - Author and optimize with Copilot docsTeamMetrics: - copilot-cli --- ## Introduction {% data variables.copilot.copilot_cli %} is a powerful terminal-native AI coding assistant that brings agentic capabilities directly to your command line. The {% data variables.copilot.copilot_cli_short %} offers deep flexibility, {% data variables.product.github %} workflow integration, and the ability to work autonomously on complex tasks while maintaining full user control. This guide will help you start using the CLI. ## Installation Use one of these commands: * **Cross-platform (npm)** Prerequisite: {% data variables.copilot.copilot_cli_npm_version %}. ```bash copy npm install -g @github/copilot ``` * **Windows (WinGet)** ```bash copy winget install GitHub.Copilot ``` * **macOS/Linux (Homebrew)** ```bash copy brew install --cask copilot-cli ``` ## Starting the CLI for the first time 1. In the terminal, navigate to the project directory where you want to use {% data variables.copilot.copilot_cli_short %}. 1. Start an interactive CLI session: ```bash copilot ``` 1. In the CLI interface, enter `/login` and follow the on-screen prompts to authenticate with your {% data variables.product.github %} account. You'll only have to do this the first time you use the CLI. 1. When prompted, confirm that you trust that the files in the current directory are suitable for use with an AI tool. > [!NOTE] > {% data variables.product.prodname_copilot_short %} won't make changes to your files without your explicit approval. 1. Try asking {% data variables.product.prodname_copilot_short %} a question, for example: ```copilot copy Give me an overview of this project. ``` If you like, you can speak your prompt instead of typing it. See [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli/voice-input). ## Core shortcuts to master | Shortcut | Action | | -------- | ------ | | Esc | Cancel the current operation | | Ctrl+C | Cancel if thinking, clear input, or exit | | Ctrl+L | Clear the screen | | `@` | Mention files to include in context | | `/` | Show slash commands | | `?` | Show tabbed help | | ↑ and ↓ | Navigate the command history | For a full list of shortcuts and available commands, enter: ```bash /help ``` ## Using {% data variables.copilot.copilot_cli %} non-interactively You can also enter a command and get a response from {% data variables.product.prodname_copilot_short %} directly in your terminal, without starting an interactive session. To do this, pass a prompt to the CLI with the `-p` flag. For example: ```bash copilot -p "In Git, how can I apply a commit from another branch" ``` The `-p` flag allows you to use {% data variables.copilot.copilot_cli %} programmatically within scripts, for example to automate tasks using AI. You can add the `-s` flag to tell the CLI to output only {% data variables.product.prodname_copilot_short %}'s response, omitting the additional usage information. ```bash copilot -sp "YOUR PROMPT HERE" ``` For details of other flags you can use programmatically, and for more information, enter: ```bash copilot help ``` or: ```bash copilot help TOPIC ``` where TOPIC is one of the topics listed in the help output. ## Next steps Find out more about {% data variables.copilot.copilot_cli_short %}: * [AUTOTITLE](/copilot/concepts/copilot-surfaces/copilot-cli) * [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli/overview) * [AUTOTITLE](/copilot/how-tos/copilot-cli/cli-best-practices) * [Get started with {% data variables.copilot.copilot_cli %}: A free hands-on course](https://developer.microsoft.com/blog/get-started-with-github-copilot-cli-a-free-hands-on-course)