About GitHub Copilot CLI - GitHub Docs (original) (raw)

Find out about using Copilot from the command line.

Who can use this feature?

GitHub Copilot CLI is available with the GitHub Copilot Pro, GitHub Copilot Pro+, GitHub Copilot Business and GitHub Copilot Enterprise plans.

If you receive Copilot from an organization, the Copilot CLI policy must be enabled in the organization's settings.

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.

Note

GitHub Copilot CLI is in public preview with data protection and subject to change.

Supported operating systems

For installation instructions, see Installing GitHub Copilot CLI.

Modes of use

GitHub Copilot CLI can be used in two modes:

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:
Bash

echo ./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.

Use cases for GitHub Copilot CLI

The following sections provide examples of tasks you can complete with GitHub Copilot CLI.

Local tasks

Tasks involving GitHub.com

Security considerations

When you use Copilot CLI, Copilot can perform tasks on your behalf, such as executing or modifying files, or running shell commands.

You should therefore always keep security considerations in mind when using Copilot CLI, just as you would when working directly with files yourself, or running commands directly in your terminal. You should always review suggested commands carefully when Copilot CLI requests your approval.

Trusted directories

When you start a GitHub Copilot CLI session, you'll be asked to confirm that you trust the files in, and below, the directory from which you launched the CLI.

Warning

You can choose to trust the current directory for:

If you choose to trust the directory for future sessions, the trusted directory prompt will not be displayed again. You should only choose this second option if you are sure that this location will always be a safe place for Copilot to operate.

You can edit the list of permanently trusted directories by amending the contents of the trusted_folders array in the CLI's config.json file. This is located, by default, in the ~/.copilot directory. You can change this location by setting the XDG_CONFIG_HOME environment variable.

Allowed tools

The first time that Copilot needs to use a tool that could be used to modify or execute a file—for example, touch, chmod, node, or sed—it will ask you whether you want to allow it to use that tool.

Typically, you can choose from three options:

1. Yes
2. Yes, and approve TOOL for the rest of the running session
3. No, and tell Copilot what to do differently (Esc)

Option 1 allows Copilot to run this particular command, this time only. The next time it needs to use this tool, it will ask you again.

Option 2 allows Copilot to use this tool again, without asking you for permission, for the duration of the currently running session. It will ask for your approval again in new sessions, or if you resume the current session in the future. If you choose this option, you are allowing Copilot to use this tool in any way it thinks is appropriate. For example, if Copilot asks you to allow it to run the command rm ./this-file.txt, and you choose option 2, then Copilot can run any rm command (for example, rm -rf ./*) during the current run of this session, without asking for your approval.

Option 3 cancels the proposed command and allows you to tell Copilot to try a different approach.

Allowing tools to be used without manual approval

There are three command-line options that you can use for either interactive or programmatic mode to determine tools that Copilot can use without asking for your approval:

copilot -p "Revert the last commit" --allow-all-tools  

Using the approval options

The --deny-tool and --allow-tool options require one of the following arguments:

copilot --deny-tool 'shell(git push)'  

The tool specification is optional. For example, copilot --allow-tool 'shell' allows Copilot to use any shell command without individual approval.

Combining approval options

You can use a combination of approval options to determine exactly which tools Copilot can use without asking for your approval.

For example, to prevent Copilot from using the rm and git push commands, but automatically allow all other tools, use:

copilot --allow-all-tools --deny-tool 'shell(rm)' --deny-tool 'shell(git push)'

To prevent Copilot from using the tool tool_name from the MCP server named My-MCP-Server, but allow all other tools from that server to be used without individual approval, use:

copilot --allow-tool 'My-MCP-Server' --deny-tool 'My-MCP-Server(tool_name)'

Security implications of automatic tool approval

It's important to be aware of the security implications of using the approval command-line options. These options allow Copilot to execute commands needed to complete your request, without giving you the opportunity to review and approve those commands before they are run. While this streamlines workflows, and allows headless operation of the CLI, it increases the risk of unintended actions being taken that might result in data loss or corruption, or other security issues.

Risk mitigation

You can mitigate the risks associated with using the automatic approval options by using Copilot CLI in a restricted environment, such as a virtual machine, container, or dedicated system, without internet access. This confines any potential damage that could occur when allowing Copilot to execute commands that you have not reviewed and verified.

Model usage

The default model used by GitHub Copilot CLI is Claude Sonnet 4.5. GitHub reserves the right to change this model.

You can change the model used by GitHub Copilot CLI by using the /model slash command. Enter this command, then select a model from the list.

Each time you submit a prompt to Copilot in Copilot CLI's interactive mode, and each time you use Copilot CLI in programmatic mode, your monthly quota of Copilot premium requests is reduced by one, multiplied by the multiplier shown in parentheses in the model list. For example, Claude Sonnet 4.5 (1x) indicates that with this model each time you submit a prompt your quota of premium requests is reduced by one. For information about premium requests, see Requests in GitHub Copilot.

Feedback

If you have any feedback about GitHub Copilot CLI, please let us know by using the /feedback slash command in an interactive session and choosing one of the options. You can complete a private feedback survey, submit a bug report, or suggest a new feature.

Further reading