The command-line interface (CLI) for GitHub Copilot allows you to use Copilot directly from your terminal. For more information, see About GitHub Copilot CLI.
Nota:
GitHub Copilot en la CLI is in public preview and subject to change.
Prerequisite
Install Copilot en la CLI. See Installing GitHub Copilot CLI.
Using Copilot en la CLI
-
In your terminal, navigate to a folder that contains code you want to work with.
-
Enter
copilot
to start Copilot en la CLI.Copilot will ask you to confirm that you trust the files in this folder.
Importante
During this GitHub Copilot en la CLI session, Copilot may attempt to read, modify, and execute files in and below this folder. You should only proceed if you trust the files in this location. For more information about trusted directories, see About GitHub Copilot CLI.
-
Choose one of the options:
1. Yes, proceed:
Copilot can work with the files in this location for this session only.
2. Yes, and remember this folder for future sessions:
You trust the files in this folder for this and future sessions. You won't be asked again when you start Copilot en la CLI from this folder. Only choose this option if you are sure that it will always be safe for Copilot to work with files in this location.
3. No, exit (Esc):
End your Copilot en la CLI session.
-
If you are not currently logged in to GitHub, you'll be prompted to use the
/login
slash command. Enter this command and follow the on-screen instructions to authenticate. -
Enter a prompt in the CLI.
This can be a simple chat question, or a request for Copilot to perform a specific task, such as fixing a bug, adding a feature to an existing application, or creating a new application.
For some examples of prompts, see About GitHub Copilot CLI.
-
When Copilot wants to use a tool that could modify or execute files—for example,
touch
,chmod
,node
, orsed
—it will ask you to approve the use of the tool.Choose one of the options:
1. Yes:
Allow Copilot to use this tool. The next time Copilot wants to use this tool, it will ask you to approve it again.
2. Yes, and approve TOOL for the rest of the running session:
Allow Copilot to use this tool—with any options—without asking again, for the rest of the currently running session. You will have to approve the command again in future sessions.
Choosing this option is useful for a many tools—such as
chmod
—as it avoids you having to approve similar commands repeatedly in the same session. However, you should be aware of the security implications of this option. Choosing this option for the commandrm
, for example, would allow Copilot to delete any file in or below the current folder without asking for your approval.3. No, and tell Copilot what to do differently (Esc):
Copilot will not run the command. Instead, it ends the current operation and awaits your next prompt. You can tell Copilot to continue the task but using a different approach.
For example, if you ask Copilot to create a bash script but you do not want to use the script Copilot suggests, you can stop the current operation and enter a new prompt, such as:
Continue the previous task but include usage instructions in the script
.
Tips
Optimize your experience with Copilot en la CLI with the following tips.
Stop a currently running operation
If you enter a prompt and then decide you want to stop Copilot from completing the task while it is still "Thinking," press Esc.
Include a specific file in your prompt
To add a specific file to your prompt, use @
followed by the relative path to the file. For example: Explain @config/ci/ci-required-checks.yml
or Fix the bug in @src/app.js
. This adds the contents of the file to your prompt as context for Copilot.
When you start typing a file path, the matching paths are displayed below the prompt box. Use the arrow keys to select a path and press Tab to complete the path in your prompt.
Work with files in a different location
To complete a task, Copilot may need to work with files that are outside the current working directory. If a prompt you have entered in an interactive session requires Copilot to modify a file outside the current location, it will ask you to approve access to the file's directory.
You can also add a trusted directory manually at any time by using the slash command:
/add-dir /path/to/directory
If all of the files you want to work with are in a different location, you can switch the current working directory without starting a new Copilot en la CLI session by using the slash command:
/cwd /path/to/directory
Resume an interactive session
You can return to a previous interactive session, and continue your conversation with Copilot, by using the --resume
command line option, then choosing the session you want to resume from the list that's displayed.
Use custom instructions
You can enhance Copilot’s performance, by adding custom instructions to the repository you are working in. Custom instructions are natural language descriptions saved in Markdown files in the repository. They are automatically included in prompts you enter while working in that repository. This helps Copilot to better understand the context of your project and how to respond to your prompts.
Copilot en la CLI supports:
- Repository-wide instructions in the
.github/copilot-instructions.md
file. - Path-specific instructions files:
.github/copilot-instructions/**/*.instructions.md
. - Agent files such as
AGENTS.md
.
For more information, see Incorporación de instrucciones personalizadas del repositorio para GitHub Copilot.
Add an MCP server
Copilot en la CLI comes with the GitHub MCP server already configured. This MCP server allows you to interact with resources on GitHub.com—for example, allowing you to merge pull requests from the CLI.
To extend the functionality available to you in Copilot en la CLI, you can add more MCP servers:
-
Use the following slash command:
/mcp add
-
Fill in the details for the MCP server you want to add, using the Tab key to move between fields.
-
Press Ctrl+S to save the details.
Details of your configured MCP servers are stored in the mcp-config.json
file, which is located, by default, in the ~/.config
directory. This location can be changed by setting the XDG_CONFIG_HOME
environment variable. For information about the JSON structure of a server definition, see Extensión del agente de codificación de GitHub Copilot con el protocolo de contexto de modelo (MCP).
Find out more
For a complete list of the command line options and slash commands that you can use with Copilot en la CLI, do one of the following:
- Enter
?
in the prompt box in an interactive session. - Enter
copilot help
in your terminal.
For additional information use one of the following commands in your terminal:
-
Configuration settings:
copilot help config
You can adjust the configuration settings by editing the
config.json
file, which is located, by default, in the~/.config
directory. This location can be changed by setting theXDG_CONFIG_HOME
environment variable. -
Environment variables that affect Copilot en la CLI:
copilot help environment
-
Available logging levels:
copilot help logging
-
Permissions for allowing or denying tool use:
copilot help permissions
Feedback
If you have any feedback about GitHub Copilot en la 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.