Skip to main content

Responsible use of Copilot in the CLI

Learn how to use Copilot in the CLI responsibly by understanding its purposes, capabilities, and limitations.

Who can use this feature?

Owners of organizations or enterprises with a Copilot Business or Copilot Enterprise subscription can decide whether to grant access to Copilot in the CLI for users in their organization or enterprise.

If you have a Copilot Pro or Copilot Pro+ subscription, you now have access to Copilot in the CLI.

About Copilot in the CLI

Copilot in the CLI provides a chat-like interface in the terminal that allows you to ask questions about the command line. You can ask Copilot to provide either command suggestions or explanations of given commands.

The only supported language for Copilot in the CLI is English.

Copilot in the CLI parses your question and provides an answer using a combination of natural language processing and machine learning. This process can be broken down into a number of steps.

Input processing

The input prompt from the user is pre-processed by Copilot in the CLI and sent to a service that is connected to a large language model that then generates a response based on the context and prompt. User input can take the form of natural language prompts or questions. It may also include choosing the command type they would like to ask about from a predetermined list, i.e. generic shell command, Git (git), or CLI (gh). The system is only intended to respond to command line-related questions. For more information about CLI, see About CLI.

Language model analysis

The input prompt is then passed through the language model, which is a neural network that has been trained on a large body of text data. The language model analyzes the input prompt to find the command or command explanation most relevant to your query.

Response generation

The language model generates a response based on its analysis of the input prompt. This response will take the form of a suggested command or an explanation of the command you asked about. If you want to run a suggested command, you need to copy the command and paste it in a separate window or tab in the terminal.

Output formatting

The response generated by Copilot in the CLI is formatted and presented to you. Copilot in the CLI uses syntax highlighting, indentation, and other formatting features to add clarity to the generated response.

Copilot in the CLI is intended to provide you with the most relevant answer to your question. However, it may not always provide the answer you are looking for. Users of Copilot in the CLI are responsible for reviewing and validating responses generated by the system to ensure they are accurate and appropriate. Copilot in the CLI also provides an optional feedback mechanism to rate suggestions, which helps us improve the tool for the future. For more information, see Improving Copilot in the CLI.

Use cases for Copilot in the CLI

Copilot in the CLI can help you by providing either command suggestions or explanations of given commands.

Find the right command to perform a task

Copilot in the CLI aims to suggest commands that help you perform the tasks you’re trying to complete. To help Copilot in the CLI provide better suggestions, you can specify the type of command you are looking for (generic, git, or gh). If the result isn’t quite what you’re looking for, you can keep revising your question until the returned command meets your expectations. Once you’ve generated the perfect command for your task, you can copy it to your clipboard to run it wherever you need, or you can ask Copilot in the CLI to execute the command for you.

Explain an unfamiliar command

Copilot in the CLI can help explain a command that you asked about by generating a natural language description of the command's functionality and purpose. This can be useful if you want to understand the command's behavior for the specific example provided without having to read or search through the command's documentation. The explanation can include information such as the command's input and output parameters and examples of how it could be used.

By generating explanations, Copilot in the CLI may help you to understand the command better, leading to enhanced learning, improved productivity, and less context switching. However, it's important to note that the generated explanations may not always be accurate or complete, so you'll need to review, and occasionally correct, its output. You remain responsible for ensuring the accuracy and appropriateness of the commands you run in the command line.

Improving Copilot in the CLI

To enhance the experience and address some of the limitations of Copilot in the CLI, there are various measures that you can adopt. For more information about the limitations, see Limitations of Copilot in the CLI.

Use Copilot in the CLI as a tool, not a replacement

While Copilot in the CLI can be a powerful tool for enhancing understanding of commands and the command line, it is important to use it as a tool rather than a replacement for human programming. You should always review and verify the command generated by Copilot in the CLI to ensure that it meets your requirements and is free of errors or security concerns.

Provide feedback

If you encounter any issues or limitations with Copilot in the CLI, we recommend that you provide feedback by selecting the "Rate response" option in Copilot in the CLI. This can help the developers to improve the tool and address any concerns or limitations.

Limitations of Copilot in the CLI

Depending on factors such as your operating system and input data, you may encounter different levels of accuracy when using Copilot in the CLI. The following information is designed to help you understand system limitations and key concepts about performance as they apply to Copilot in the CLI.

Limited scope

Copilot in the CLI operates within defined boundaries and might struggle with intricate commands, less common ones, or more recently developed tools. The quality of suggestions it provides for each language can be influenced by the availability and diversity of training data. For instance, inquiries about well-documented commands and tools like Git may yield more accurate responses compared to questions about more obscure command line tools.

Potential biases and errors

Copilot in the CLI's training data is sourced from existing online sources. It’s important to note that these sources may include biases and errors of the individuals who contributed to the training data. Copilot in the CLI may inadvertently perpetuate these biases and errors. Additionally, Copilot in the CLI might perform differently depending on the scripting languages or scripting styles, potentially resulting in suboptimal or incomplete command suggestions or explanations.

Inaccurate responses

Copilot in the CLI may generate seemingly valid but syntactically or semantically incorrect commands. To avoid issues, always carefully review and verify suggestions, especially for critical or destructive tasks such as deleting content. Ensure generated commands align with best practices and fit your workflow.

Risk management and user accountability in command execution

Additional caution is required with the addition of the functionality to ask Copilot in the CLI to execute a command, particularly regarding the potential destructiveness of some suggested commands. You may encounter commands for file deletion or hard drive formatting, which can cause problems if used incorrectly. While such commands may be necessary in certain scenarios, you need to be careful when accepting and running these commands.

Additionally, you are ultimately responsible for the commands executed by Copilot in the CLI. It is entirely your decision whether to use commands generated by Copilot in the CLI. Despite the presence of fail-safes and safety mechanisms, you must understand that executing commands carries inherent risks. Copilot in the CLI provides a powerful tool set, but you should approach its recommendations with caution and ensure that commands align with your intentions and requirements.

Inaccurate responses to non-coding topics

Copilot in the CLI is not designed to answer questions beyond the scope of command line-related tasks. As a result, its responses might not consistently offer accuracy or assistance when confronted with questions unrelated to coding or general command line use. When you inquire about non-coding topics, Copilot in the CLI may express its inability to provide a meaningful response.

Differing performance based on natural language

Copilot in the CLI has been trained on natural language content written predominantly in English. As a result, you may notice differing performance when providing Copilot in the CLI with natural language input prompts in languages other than English.

Further reading