Skip to content

Commit f3d979e

Browse files
sunbryeam-steadheiskrCopilot
authored
"Use Copilot CLI agents" map topic (#59789)
Co-authored-by: Anne-Marie <102995847+am-stead@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 720fefc commit f3d979e

File tree

7 files changed

+254
-47
lines changed

7 files changed

+254
-47
lines changed

content/copilot/how-tos/copilot-cli/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: '{% data variables.copilot.copilot_cli %}'
33
shortTitle: '{% data variables.copilot.copilot_cli_short %}'
4-
intro: 'Use {% data variables.product.prodname_copilot_short %} directly from your terminal to answer questions, write and debug code, and interact with {% data variables.product.github %}.'
4+
intro: Use {% data variables.product.prodname_copilot_short %} directly from your terminal to answer questions, write and debug code, and interact with {% data variables.product.github %}.
55
versions:
66
feature: copilot
77
contentType: landing
@@ -21,7 +21,7 @@ children:
2121
- /cli-best-practices
2222
- /set-up-copilot-cli
2323
- /customize-copilot
24-
- /use-copilot-cli
24+
- /use-copilot-cli-agents
2525
- /administer-copilot-cli-for-your-enterprise
2626
- /automate-with-actions
2727
- /speeding-up-task-completion
@@ -50,7 +50,7 @@ children:
5050
- /content/copilot/responsible-use/copilot-cli
5151
carousels:
5252
recommended:
53-
- /copilot/how-tos/copilot-cli/use-copilot-cli
53+
- /copilot/how-tos/copilot-cli/use-copilot-cli-agents/overview
5454
- /copilot/how-tos/copilot-cli/cli-best-practices
5555
- /copilot/reference/cli-command-reference
5656
includedCategories:
@@ -60,3 +60,4 @@ includedCategories:
6060
- Build with Copilot CLI
6161
- Administer Copilot CLI
6262
---
63+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Requesting a code review with {% data variables.copilot.copilot_cli %}
3+
shortTitle: Agentic code review
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Use {% data variables.copilot.copilot_cli_short %} to review your code changes directly from the terminal.'
6+
product: '{% data reusables.gated-features.copilot-cli %}'
7+
versions:
8+
feature: copilot
9+
topics:
10+
- Copilot
11+
contentType: how-tos
12+
category:
13+
- Build with Copilot CLI
14+
---
15+
16+
## About agentic code review
17+
18+
You can use the `/review` slash command to have {% data variables.product.prodname_copilot_short %} analyze code changes without leaving the CLI. This lets you get quick feedback on your changes prior to committing.
19+
20+
1. Type `/review` and optionally specify a prompt, path, or file pattern to narrow the review scope, then press <kbd>Enter</kbd>.
21+
1. If {% data variables.product.prodname_copilot_short %} proposes running a command (for example, to inspect a diff or verify a file), review the command, then use the arrow keys to choose an option and press <kbd>Enter</kbd>.
22+
* Select **Yes** to run the command.
23+
* Select **No** to skip the command and tell {% data variables.product.prodname_copilot_short %} what to do differently.
24+
1. Read the feedback that {% data variables.product.prodname_copilot_short %} provides about your changes and apply any suggested improvements in your code editor.
25+
26+
## Further reading
27+
28+
* [AUTOTITLE](/copilot/how-tos/copilot-cli/automate-with-actions)
29+
* [AUTOTITLE](/copilot/how-tos/copilot-cli/add-custom-instructions)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Delegating tasks to {% data variables.copilot.copilot_cli %}
3+
shortTitle: Delegate tasks to Copilot
4+
intro: Use {% data variables.copilot.copilot_cli_short %}''s autopilot mode to hand off tasks and have {% data variables.product.prodname_copilot_short %} work autonomously on your behalf.
5+
allowTitleToDifferFromFilename: true
6+
product: '{% data reusables.gated-features.copilot-cli %}'
7+
versions:
8+
feature: copilot
9+
topics:
10+
- Copilot
11+
contentType: how-tos
12+
category:
13+
- Build with Copilot CLI
14+
---
15+
16+
## Get {% data variables.product.prodname_copilot_short %} to work autonomously
17+
18+
You can tell {% data variables.product.prodname_copilot_short %} to use its best judgment to complete a task autonomously, rather than the CLI prompting you for input at each decision point within a task. You do this by using the CLI's autopilot mode.
19+
20+
There are two ways to use autopilot mode:
21+
22+
* **Interactively:** In an interactive session, press <kbd>Shift</kbd>+<kbd>Tab</kbd> until you see "autopilot" in the status bar. If prompted to choose permissions for autopilot mode, allow full permissions, then enter your prompt.
23+
* **Programmatically:** Pass the CLI a prompt directly in a command, and include the `--autopilot` option. For example, to use autopilot mode with full permissions, restricting it to 10 continuations, enter `{% data reusables.cli.autopilot-programmatic-prompt %}`.
24+
25+
For more information, see [AUTOTITLE](/copilot/concepts/agents/copilot-cli/autopilot).
26+
27+
## Delegate tasks to {% data variables.copilot.copilot_coding_agent %}
28+
29+
The delegate command lets you push your current session to {% data variables.copilot.copilot_coding_agent %} on {% data variables.product.github %}. This lets you hand off work while preserving all the context {% data variables.product.prodname_copilot_short %} needs to complete your task.
30+
31+
You can delegate a task using the slash command, followed by a prompt:
32+
33+
```shell
34+
/delegate complete the API integration tests and fix any failing edge cases
35+
```
36+
37+
Alternatively, prefix a prompt with `&` to delegate it:
38+
39+
```shell
40+
& complete the API integration tests and fix any failing edge cases
41+
```
42+
43+
{% data variables.product.prodname_copilot_short %} will ask to commit any of your unstaged changes as a checkpoint in a new branch it creates. {% data variables.copilot.copilot_coding_agent %} will open a draft pull request, make changes in the background, and request a review from you.
44+
45+
{% data variables.product.prodname_copilot_short %} will provide a link to the pull request and agent session on {% data variables.product.github %} once the session begins.
46+
47+
## Next steps
48+
49+
To learn how to invoke specialized agents tailored to specific tasks, such as code review, documentation, or security audits, see [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli-agents/invoke-custom-agents).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Use {% data variables.copilot.copilot_cli %} agents
3+
shortTitle: Use Copilot CLI agents
4+
intro: Understand the different ways you can use agents in {% data variables.copilot.copilot_cli_short %} to delegate and automate work.
5+
versions:
6+
feature: copilot
7+
topics:
8+
- Copilot
9+
children:
10+
- /overview
11+
- /delegate-tasks-to-cca
12+
- /invoke-custom-agents
13+
- /steer-agents
14+
- /agentic-code-review
15+
contentType: how-tos
16+
---
17+
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: Invoking custom agents
3+
shortTitle: Invoke custom agents
4+
intro: Use custom agents, skills, and MCP servers in {% data variables.copilot.copilot_cli_short %} to extend its capabilities.
5+
product: '{% data reusables.gated-features.copilot-cli %}'
6+
versions:
7+
feature: copilot
8+
topics:
9+
- Copilot
10+
contentType: how-tos
11+
category:
12+
- Build with Copilot CLI
13+
---
14+
15+
## Use {% data variables.copilot.custom_agents_short %}
16+
17+
A {% data variables.copilot.copilot_custom_agent_short %} is a specialized version of {% data variables.product.prodname_copilot_short %}. {% data variables.copilot.custom_agents_caps_short %} help {% data variables.product.prodname_copilot_short %} handle unique workflows, particular coding conventions, and specialist use cases.
18+
19+
{% data variables.copilot.copilot_cli_short %} includes a default group of {% data variables.copilot.custom_agents_short %} for common tasks:
20+
21+
<table>
22+
<thead>
23+
<tr>
24+
<th style="width:20%">Agent</th>
25+
<th>Description</th>
26+
</tr>
27+
</thead>
28+
<tbody>
29+
<tr>
30+
<td>Explore</td>
31+
<td>Performs quick codebase analysis, allowing you to ask questions about your code without adding to your main context.</td>
32+
</tr>
33+
<tr>
34+
<td>Task</td>
35+
<td>Executes commands such as tests and builds, providing brief summaries on success and full output on failure.</td>
36+
</tr>
37+
<tr>
38+
<td>General-purpose</td>
39+
<td>Handles complex, multi-step tasks that require the full toolset and high-quality reasoning, running in a separate context to keep your main conversation clearly focused.</td>
40+
</tr>
41+
<tr>
42+
<td>Code-review</td>
43+
<td>Reviews changes with a focus on surfacing only genuine issues, minimizing noise.</td>
44+
</tr>
45+
</tbody>
46+
</table>
47+
48+
The AI model being used by the CLI can choose to delegate a task to a subsidiary subagent process, that operates using a {% data variables.copilot.copilot_custom_agent_short %} with specific expertise, if it judges that this would result in the work being completed more effectively. The model may equally choose to handle the work directly in the main agent.
49+
50+
You can define your own {% data variables.copilot.custom_agents_short %} using Markdown files, called {% data variables.copilot.agent_profiles %}, that specify what expertise the agent should have, what tools it can use, and any specific instructions for how it should respond.
51+
52+
You can define {% data variables.copilot.custom_agents_short %} at the user, repository, or organization/enterprise level:
53+
54+
| Type | Location | Scope |
55+
| --- | --- | --- |
56+
| User-level {% data variables.copilot.copilot_custom_agent_short %} | local `~/.copilot/agents` directory | All projects |
57+
| Repository-level {% data variables.copilot.copilot_custom_agent_short %} | `.github/agents` directory in your local and remote repositories | Current project |
58+
| Organization and Enterprise-level {% data variables.copilot.copilot_custom_agent_short %} | `/agents` directory in the `.github-private` repository in an organization or enterprise | All projects under your organization and enterprise account |
59+
60+
In the case of naming conflicts, a system-level agent overrides a repository-level agent, and the repository-level agent would override an organization-level agent.
61+
62+
{% data variables.copilot.custom_agents_caps_short %} can be used in three ways:
63+
64+
* Using the slash command in the CLI's interactive interface to select from the list of available {% data variables.copilot.custom_agents_short %}:
65+
66+
```shell
67+
/agent
68+
```
69+
70+
* Calling out to the {% data variables.copilot.copilot_custom_agent_short %} directly in a prompt:
71+
72+
```shell
73+
Use the refactoring agent to refactor this code block
74+
```
75+
76+
{% data variables.product.prodname_copilot_short %} will automatically infer the agent you want to use.
77+
78+
* Specifying the {% data variables.copilot.copilot_custom_agent_short %} you want to use with the command-line option. For example:
79+
80+
```shell
81+
copilot --agent=refactor-agent --prompt "Refactor this code block"
82+
```
83+
84+
For more information, see [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents).
85+
86+
## Use skills
87+
88+
You can create skills to enhance the ability of {% data variables.product.prodname_copilot_short %} to perform specialized tasks with instructions, scripts, and resources.
89+
90+
For more information, see [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/create-skills).
91+
92+
## Add an MCP server
93+
94+
{% data variables.copilot.copilot_cli_short %} comes with the {% data variables.product.github %} MCP server already configured. This MCP server allows you to interact with resources on {% data variables.product.prodname_dotcom_the_website %}—for example, allowing you to merge pull requests from the CLI.
95+
96+
To extend the functionality available to you in {% data variables.copilot.copilot_cli_short %}, you can add more MCP servers:
97+
98+
1. Use the following slash command:
99+
100+
```shell
101+
/mcp add
102+
```
103+
104+
1. Fill in the details for the MCP server you want to add, using the <kbd>Tab</kbd> key to move between fields.
105+
1. Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to save the details.
106+
107+
Details of your configured MCP servers are stored in the `mcp-config.json` file, which is located, by default, in the `~/.copilot` 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 [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#writing-a-json-configuration-for-mcp-servers).
108+
109+
For more detailed information on adding and managing MCP servers in {% data variables.copilot.copilot_cli_short %}, see [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers).
110+
111+
## Next steps
112+
113+
To learn how to guide and refine agent behavior during task execution to keep work on track, see [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli-agents/steer-agents).

content/copilot/how-tos/copilot-cli/use-copilot-cli.md renamed to content/copilot/how-tos/copilot-cli/use-copilot-cli-agents/overview.md

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
---
22
title: Using GitHub Copilot CLI
3-
shortTitle: Use Copilot CLI
3+
shortTitle: Overview
44
intro: Learn how to use {% data variables.product.prodname_copilot %} from the command line.
55
product: '{% data reusables.gated-features.copilot-cli %}'
66
redirect_from:
77
- /copilot/how-tos/use-copilot-cli
88
- /copilot/how-tos/use-copilot-agents/use-copilot-cli
9+
- /copilot/how-tos/copilot-cli/use-copilot-cli
910
versions:
1011
feature: copilot
1112
contentType: how-tos
1213
category:
13-
- Author and optimize with Copilot # Copilot discovery page
14-
- Build with Copilot CLI # Copilot CLI bespoke page
14+
- Author and optimize with Copilot
15+
- Build with Copilot CLI
1516
---
1617

1718
The command-line interface (CLI) for {% data variables.product.prodname_copilot %} allows you to use {% data variables.product.prodname_copilot_short %} directly from your terminal. For more information, see [AUTOTITLE](/copilot/concepts/agents/about-copilot-cli).
@@ -85,10 +86,6 @@ If you enter a prompt and then decide you want to stop {% data variables.product
8586

8687
Plan mode lets you collaborate with {% data variables.product.prodname_copilot_short %} on an implementation plan before any code is written. Press <kbd>Shift</kbd>+<kbd>Tab</kbd> to cycle in and out of plan mode.
8788

88-
### Steer the conversation while {% data variables.product.prodname_copilot_short %} is thinking
89-
90-
You can interact with {% data variables.product.prodname_copilot_short %} while it's thinking. Send follow-up messages to steer the conversation in a different direction, or queue additional instructions for {% data variables.product.prodname_copilot_short %} to process after it finishes its current response.
91-
9289
### Include a specific file in your prompt
9390

9491
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 {% data variables.product.prodname_copilot_short %}.
@@ -119,37 +116,6 @@ You can prepend your input with `!` to directly run shell commands, without maki
119116
!git clone https://github.com/github/copilot-cli
120117
```
121118

122-
### Get {% data variables.product.prodname_copilot_short %} to work autonomously
123-
124-
You can tell {% data variables.product.prodname_copilot_short %} to use its best judgment to complete a task autonomously, rather than the CLI prompting you for input at each decision point within a task. You do this by using the CLI's autopilot mode.
125-
126-
There are two ways to use autopilot mode:
127-
128-
* **Interactively:** In an interactive session, press <kbd>Shift</kbd>+<kbd>Tab</kbd> until you see "autopilot" in the status bar. If prompted to choose permissions for autopilot mode, allow full permissions, then enter your prompt.
129-
* **Programmatically:** Pass the CLI a prompt directly in a command, and include the `--autopilot` option. For example, to use autopilot mode with full permissions, restricting it to 10 continuations, enter `{% data reusables.cli.autopilot-programmatic-prompt %}`.
130-
131-
For more information, see [AUTOTITLE](/copilot/concepts/agents/copilot-cli/autopilot).
132-
133-
### Delegate tasks to {% data variables.copilot.copilot_coding_agent %}
134-
135-
The delegate command lets you push your current session to {% data variables.copilot.copilot_coding_agent %} on {% data variables.product.github %}. This lets you hand off work while preserving all the context {% data variables.product.prodname_copilot_short %} needs to complete your task.
136-
137-
You can delegate a task using the slash command, followed by a prompt:
138-
139-
```shell
140-
/delegate complete the API integration tests and fix any failing edge cases
141-
```
142-
143-
Alternatively, prefix a prompt with `&` to delegate it:
144-
145-
```shell
146-
& complete the API integration tests and fix any failing edge cases
147-
```
148-
149-
{% data variables.product.prodname_copilot_short %} will ask to commit any of your unstaged changes as a checkpoint in a new branch it creates. {% data variables.copilot.copilot_coding_agent %} will open a draft pull request, make changes in the background, and request a review from you.
150-
151-
{% data variables.product.prodname_copilot_short %} will provide a link to the pull request and agent session on {% data variables.product.github %} once the session begins.
152-
153119
### Resume an interactive session
154120

155121
You can use the `--resume` command-line option or the `/resume` slash command to select and resume an interactive CLI session, allowing you to pick up right where you left off, with the saved context. You can kick off a {% data variables.copilot.copilot_coding_agent %} session on {% data variables.product.github %}, and then use {% data variables.copilot.copilot_cli %} to bring that session to your local environment.
@@ -267,8 +233,6 @@ To extend the functionality available to you in {% data variables.copilot.copilo
267233
268234
Details of your configured MCP servers are stored in the `mcp-config.json` file, which is located, by default, in the `~/.copilot` 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 [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#writing-a-json-configuration-for-mcp-servers).
269235
270-
For more detailed information on adding and managing MCP servers in {% data variables.copilot.copilot_cli_short %}, see [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers).
271-
272236
### Context management
273237
274238
{% data variables.copilot.copilot_cli_short %} provides several slash commands to help you monitor and manage your context window:
@@ -284,10 +248,6 @@ For more detailed information on adding and managing MCP servers in {% data vari
284248
285249
{% data variables.copilot.copilot_cli %} automatically compresses your history in the background when your conversation approaches 95% of the token limit, without interrupting your workflow.
286250
287-
### Review code changes
288-
289-
You can use the `/review` slash command to have {% data variables.product.prodname_copilot_short %} analyze code changes without leaving the CLI. This lets you get quick feedback on your changes prior to committing.
290-
291251
### Enable all permissions
292252
293253
For situations where you trust {% data variables.product.prodname_copilot_short %} to run freely, you can use the `--allow-all` or `--yolo` flags to enable all permissions at once.
@@ -325,6 +285,17 @@ For additional information use one of the following commands in your terminal:
325285
326286
{% data reusables.cli.feedback %}
327287
288+
## Next steps
289+
290+
{% data variables.copilot.copilot_cli_short %} can operate as a conversational assistant, answering questions and helping you write code interactively. Beyond chat, {% data variables.copilot.copilot_cli_short %} supports a range of agentic modes that allow you to delegate tasks with greater autonomy.
291+
292+
You can work with agents in {% data variables.copilot.copilot_cli_short %} to support a full task lifecycle, from delegating work to reviewing results:
293+
294+
* **Delegate tasks autonomously**: Run {% data variables.copilot.copilot_cli_short %} in autopilot mode to complete multi-step tasks without requiring approval at each step. See [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli-agents/delegate-tasks-to-cca).
295+
* **Invoke custom agents**: Invoke specialized agents tailored to specific tasks, such as code review, documentation, or security audits. See [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli-agents/invoke-custom-agents).
296+
* **Steer agents**: Guide and refine agent behavior during task execution to keep work on track. See [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli-agents/steer-agents).
297+
* **Request a code review**: Use {% data variables.copilot.copilot_cli_short %} to get an AI-powered review of your code changes. See [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli-agents/agentic-code-review).
298+
328299
## Further reading
329300
330301
* [AUTOTITLE](/copilot/how-tos/copilot-cli/cli-best-practices)

0 commit comments

Comments
 (0)