GitHub Copilot CLI - GitHub Docs
Skip to main content Skip to content Collapse sidebar Expand sidebar GitHub Copilot CLI Find out about using Copilot from the command line. Who can use this feature? GitHub Copilot CLI is available with all Copilot plans. If you receive Copilot from an organization, the Copilot CLI policy must be enabled in the organization's settings. In this article Introduction The command-line interface (CLI) for GitHub Copilot allows you to use Copilot directly from your terminal.
You can use it to answer questions, write and debug code, and interact with GitHub.com. For example, you can ask Copilot to make some changes to a project and create a pull request. GitHub Copilot CLI gives you quick access to a powerful AI agent, without having to leave your terminal. It can help you complete tasks more quickly by working on your behalf, and you can work iteratively with GitHub Copilot CLI to build the code you need.
Supported operating systems Linux macOS Windows from within Powershell and Windows Subsystem for Linux (WSL) For installation instructions, see Installing GitHub Copilot CLI . Modes of use GitHub Copilot CLI has two user interfaces: interactive and programmatic. Interactive interface To start an interactive session, enter copilot . Within an interactive session, you can have a conversation with Copilot. You can prompt Copilot to perform one or more tasks, and you can give it feedback and steer the direction of the work.
The interactive interface has two modes. In addition to the default ask/execute mode there is also a plan mode in which Copilot will build a structured implementation plan for a task you want to complete. Press Shift + Tab to cycle between modes. In plan mode, Copilot analyzes your request, asks clarifying questions to understand scope and requirements, and builds a plan before writing any code. This helps you catch misunderstandings before any code is written, and stay in control of complex, multi-step tasks.
Programmatic interface You can also pass the CLI a single prompt directly on the command line. The CLI completes the task and then exits. To use the CLI programmatically, include the -p or --prompt command-line option in your command. To allow Copilot to modify and execute files you should also use one of the approval options described later in this article—see Allowing tools to be used without manual approval ). For example: copilot -p "Show me this week's commits and summarize them" --allow-tool= 'shell(git)' Alternatively, you can use a script to output command-line options and pipe this to copilot .
For example: ./script-outputting-options.sh | copilot Caution If you use an automatic approval option such as --allow-all-tools , Copilot has the same access as you do to files on your computer, and can run any shell commands that you can run, without getting your prior approval. See Security considerations , later in this article. Running Copilot CLI commands in a sandbox To prevent Copilot from modifying files you don't want it to touch, you can force agents to run commands within a local sandboxed environment.
Alternatively, you can run an entire CLI session in an isolated environment in the cloud. For more information, see About local sandboxing for GitHub Copilot . Local sandboxing You can enable local sandboxing inside a Copilot CLI session to restrict Copilot's access to your filesystem, network, and system capabilities. To enable it, run /sandbox enable inside a session. Cloud sandboxing You can start a Copilot CLI session in a cloud sandbox.
The --cloud option starts the same kind of cloud sandbox as other Copilot clients, so the session runs in an isolated environment that GitHub hosts, without using your machine. Because the session runs in the cloud, you can follow and steer it from any Copilot client. For example, you can start work in Copilot CLI, steer it from GitHub Mobile while away, then pick it back up in Copilot CLI or another client. For more information, see About cloud sandboxes for GitHub Copilot .
To start a cloud-backed session, run: copilot --cloud Use cases for GitHub Copilot CLI The following sections provide examples of tasks you can complete with GitHub Copilot CLI. Local tasks From within a project directory you can ask Copilot to make a change to the code in the project. For example: Change the background-color of H1 headings to dark blue Copilot finds the CSS file where H1 headings are defined and changes the color value.
Ask Copilot to tell you about changes to a file: Show me the last 5 changes made to the CHANGELOG.md file. Who changed the file, when, and give a brief summary of the changes they made Use Copilot to help you improve the code, or documentation, in your project. Suggest improvements to content.js Rewrite the readme in this project to make it more accessible to newcomers Use Copilot to help you perform Git operations. Commit the changes to this repo Revert the last commit, leaving the changes unstaged Ask Copilot to create an application from scratch—for example, as a proof of concept.
Use the create-next-app kit and tailwind CSS to create a next.js app. The app should be a dashboard built with data from the GitHub API. It should track this project's build success rate, average build duration, number of failed builds, and automated test pass rate. After creating the app, give me easy to follow instructions on how to build, run, and view the app in my browser. Ask Copilot to explain why a change it made is not working as expected, or tell Copilot to fix a problem with the last change it made.
For example: You said: "The application is now running on http://localhost:3002 and is fully functional!" but when I browse to that URL I get "This site can't be reached" Browser use Note Browser use is in public preview and subject to change. You can enable browser use to let Copilot interact with websites as part of a task. For more information, see Using GitHub Copilot CLI to interact with your browser . Computer use In local sessions on macOS and Windows, you can enable computer use to let Copilot interact with desktop applications.
This capability is useful for workflows in legacy and GUI-only software that do not provide an API, command-line interface, or MCP integration. For more information, see About computer use in GitHub Copilot . Tasks involving GitHub.com Fetch and display details about your work from GitHub.com. List my open PRs This lists your open pull requests from any repository on GitHub. For more specific results, include the repository name in your prompt: List all open issues assigned to me in OWNER/REPO Ask Copilot to work on an issue: I've been assigned this issue: https://github.com/octo-org/octo-repo/issues/1234.
Start working on this for me in a suitably named branch. Ask Copilot to make file changes and raise a pull request on GitHub.com. In the root of this repo, add a Node script called user-info.js that outputs information about the user who ran the script. Create a pull request to add this file to the repo on GitHub. Create a PR that updates the README at https://github.com/octo-org/octo-repo, changing the subheading "How to run" to "Example usage" Copilot creates a pull request on GitHub.com, on your behalf.
You are marked as the pull request author. Ask Copilot to create an issue for you on GitHub.com. Raise an improvement issue in octo-org/octo-repo. In src/someapp/somefile.py the `file = open('data.txt', 'r')` block opens a file but never closes it. Ask Copilot to check the code changes in a pull request. Check the changes made in PR https://github.com/octo-org/octo-repo/pull/57575. Report any serious errors you find in these changes.
Copilot responds in the CLI with a summary of any problems it finds. Manage pull requests from GitHub Copilot CLI. Merge all of the open PRs that I've created in octo-org/octo-repo Close PR #11 on octo-org/octo-repo Find specific types of issues. Use the GitHub MCP server to find good first issues for a new team member to work
The rest of this page is on the live site.