You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> [!NOTE] This feature is currently in {% data variables.release-phases.public_preview %} and is subject to change.
20
-
21
19
This version of this article is for using repository custom instructions on the {% data variables.product.github %} website. Click the tabs above for information on using custom instructions in other environments. <!-- markdownlint-disable-line MD027 -->
22
20
23
21
{% endwebui %}
@@ -36,16 +34,12 @@ This version of this article is for using repository custom instructions in {% d
36
34
37
35
{% jetbrains %}
38
36
39
-
> [!NOTE] This feature is currently in {% data variables.release-phases.public_preview %} and is subject to change.
40
-
41
37
This version of this article is for using repository custom instructions in JetBrains IDEs. Click the tabs above for instructions on using custom instructions in other environments.
42
38
43
39
{% endjetbrains %}
44
40
45
41
{% xcode %}
46
42
47
-
> [!NOTE] This feature is currently in {% data variables.release-phases.public_preview %} and is subject to change.
48
-
49
43
This version of this article is for using repository custom instructions in Xcode. Click the tabs above for instructions on using custom instructions in other environments.
50
44
51
45
{% endxcode %}
@@ -64,8 +58,6 @@ Repository custom instructions let you provide {% data variables.product.prodnam
64
58
65
59
* Your personal choice of whether to use custom instructions must be set to enabled. This is enabled by default. See [Enabling or disabling repository custom instructions](#enabling-or-disabling-repository-custom-instructions) later in this article.
66
60
67
-
* During the {% data variables.release-phases.public_preview %}, if you're using a {% data variables.copilot.copilot_business_short %} {% ifversion ghec %}or {% data variables.copilot.copilot_enterprise_short %}{% endif %} plan, the organization {% ifversion ghec %}or enterprise{% endif %} that provides your plan must have the **Opt in to preview features** setting enabled. See [AUTOTITLE](/enterprise-cloud@latest/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-policies-for-copilot-in-your-organization#enabling-copilot-features-in-your-organization){% ifversion ghec %} and [AUTOTITLE](/enterprise-cloud@latest/copilot/managing-copilot/managing-copilot-for-your-enterprise/managing-policies-and-features-for-copilot-in-your-enterprise#copilot-in-githubcom){% endif %}.
68
-
69
61
{% endwebui %}
70
62
71
63
{% vscode %}
@@ -76,7 +68,7 @@ Repository custom instructions let you provide {% data variables.product.prodnam
76
68
77
69
{% visualstudio %}
78
70
79
-
* The **Enable custom instructions** option must be enabled in your settings. This is enabled by default. See [Enabling or disabling repository custom instructions](#enabling-or-disabling-repository-custom-instructions) later in this article.
71
+
* The **Enable custom instructions...** option must be enabled in your settings. This is enabled by default. See [Enabling or disabling repository custom instructions](#enabling-or-disabling-repository-custom-instructions) later in this article.
80
72
81
73
{% endvisualstudio %}
82
74
@@ -206,12 +198,108 @@ Whitespace between instructions is ignored, so the instructions can be written a
206
198
207
199
{% webui %}
208
200
209
-
**{% data variables.copilot.copilot_chat_short %}** on the {% data variables.product.github %} website and **{% data variables.copilot.copilot_code-review_short %}** support a single `.github/copilot-instructions.md` custom instructions file stored in the repository.
201
+
**{% data variables.copilot.copilot_chat_short %}** on the {% data variables.product.github %} website, **{% data variables.copilot.copilot_coding_agent %}** and **{% data variables.copilot.copilot_code-review_short %}** support a single `.github/copilot-instructions.md` custom instructions file stored in the repository.
210
202
211
203
In addition, **{% data variables.copilot.copilot_coding_agent %}** supports one or more `.instructions.md` files stored within `.github/instructions` in the repository. Each file can specify `applyTo` frontmatter to define what files or directories its instructions apply to.
212
204
213
205
### Using a single `.github/copilot-instructions.md` file
214
206
207
+
You can ask {% data variables.copilot.copilot_coding_agent %} to generate a `.github/copilot-instructions.md` file, or you can write your own instructions file.
208
+
209
+
#### Asking {% data variables.copilot.copilot_coding_agent %} to generate a `.github/copilot-instructions.md` file
210
+
211
+
> [!NOTE]
212
+
> {% data reusables.copilot.coding-agent.preview-note-text %}
213
+
214
+
1. Navigate to the Agents page at [github.com/copilot/agents](https://github.com/copilot/agents).
215
+
216
+
You can also reach this page by clicking the **{% octicon "copilot" aria-label="Copilot icon" %}** button next to the search bar on any page on {% data variables.product.github %}, then selecting **Agents** from the sidebar.
217
+
218
+
1. Using the dropdown menu in the prompt field, select the repository you want {% data variables.product.prodname_copilot_short %} to generate custom instructions for.
219
+
220
+
1. Copy the following prompt, customizing it if needed:
221
+
222
+
```markdown copy
223
+
Your task is to "onboard" this repository to Copilot coding agent by adding a .github/copilot-instructions.md file in the repository that contains information describing how a coding agent seeing it for the first time can work most efficiently.
224
+
225
+
You will do this task only one time per repository and doing a good job can SIGNIFICANTLY improve the quality of the agent's work, so take your time, think carefully, and search thoroughly before writing the instructions.
226
+
227
+
<Goals>
228
+
- Reduce the likelihood of a coding agent pull request getting rejected by the user due to
229
+
generating code that fails the continuous integration build, fails a validation pipeline, or
230
+
having misbehavior.
231
+
- Minimize bash command and build failures.
232
+
- Allow the agent to complete its task more quickly by minimizing the need for exploration using grep, find, str_replace_editor, and code search tools.
233
+
</Goals>
234
+
235
+
<Limitations>
236
+
- Instructions must be no longer than 2 pages.
237
+
- Instructions must not be task specific.
238
+
</Limitations>
239
+
240
+
<WhatToAdd>
241
+
242
+
Add the following high level details about the codebase to reduce the amount of searching the agent has to do to understand the codebase each time:
243
+
<HighLevelDetails>
244
+
245
+
- A summary of what the repository does.
246
+
- High level repository information, such as the size of the repo, the type of the project, the languages, frameworks, or target runtimes in use.
247
+
</HighLevelDetails>
248
+
249
+
Add information about how to build and validate changes so the agent does not need to search and find it each time.
250
+
<BuildInstructions>
251
+
252
+
- For each of bootstrap, build, test, run, lint, and any other scripted step, document the sequence of steps to take to run it successfully as well as the versions of any runtime or build tools used.
253
+
- Each command should be validated by running it to ensure that it works correctly as well as any preconditions and postconditions.
254
+
- Try cleaning the repo and environment and running commands in different orders and document errors and and misbehavior observed as well as any steps used to mitigate the problem.
255
+
- Run the tests and document the order of steps required to run the tests.
256
+
- Make a change to the codebase. Document any unexpected build issues as well as the workarounds.
257
+
- Document environment setup steps that seem optional but that you have validated are actually required.
258
+
- Document the time required for commands that failed due to timing out.
259
+
- When you find a sequence of commands that work for a particular purpose, document them in detail.
260
+
- Use language to indicate when something should always be done. For example: "always run npm install before building".
261
+
- Record any validation steps from documentation.
262
+
</BuildInstructions>
263
+
264
+
List key facts about the layout and architecture of the codebase to help the agent find where to make changes with minimal searching.
265
+
<ProjectLayout>
266
+
267
+
- A description of the major architectural elements of the project, including the relative paths to the main project files, the location
268
+
of configuration files for linting, compilation, testing, and preferences.
269
+
- A description of the checks run prior to check in, including any GitHub workflows, continuous integration builds, or other validation pipelines.
270
+
- Document the steps so that the agent can replicate these itself.
271
+
- Any explicit validation steps that the agent can consider to have further confidence in its changes.
272
+
- Dependencies that aren't obvious from the layout or file structure.
273
+
- Finally, fill in any remaining space with detailed lists of the following, in order of priority: the list of files in the repo root, the
274
+
contents of the README, the contents of any key source files, the list of files in the next level down of directories, giving priority to the more structurally important and snippets of code from key source files, such as the one containing the main method.
275
+
</ProjectLayout>
276
+
</WhatToAdd>
277
+
278
+
<StepsToFollow>
279
+
- Perform a comprehensive inventory of the codebase. Search for and view:
280
+
- README.md, CONTRIBUTING.md, and all other documentation files.
281
+
- Search the codebase for build steps and indications of workarounds like 'HACK', 'TODO', etc.
282
+
- All scripts, particularly those pertaining to build and repo or environment setup.
283
+
- All build and actions pipelines.
284
+
- All project files.
285
+
- All configuration and linting files.
286
+
- For each file:
287
+
- think: are the contents or the existence of the file information that the coding agent will need to implement, build, test, validate, or demo a code change?
288
+
- If yes:
289
+
- Document the command or information in detail.
290
+
- Explicitly indicate which commands work and which do not and the order in which commands should be run.
291
+
- Document any errors encountered as well as the steps taken to workaround them.
292
+
- Document any other steps or information that the agent can use to reduce time spent exploring or trying and failing to run bash commands.
293
+
- Finally, explicitly instruct the agent to trust the instructions and only perform a search if the information in the instructions is incomplete or found to be in error.
294
+
</StepsToFollow>
295
+
- Document any errors encountered as well as the steps taken to work-around them.
296
+
297
+
1. Click **Send now** or press <kbd>Return</kbd>.
298
+
299
+
{% data variables.product.prodname_copilot_short %} will start a new session, which will appear in the list below the prompt box. {% data variables.product.prodname_copilot_short %} will create a draft pull request, write your custom instructions, push them to the branch, then add you as a reviewer when it has finished, triggering a notification.
300
+
301
+
#### Writing your own `.github/copilot-instructions.md` file
302
+
215
303
1. In the root of your repository, create a file named `.github/copilot-instructions.md`.
216
304
217
305
Create the `.github` directory if it does not already exist.
@@ -220,6 +308,9 @@ In addition, **{% data variables.copilot.copilot_coding_agent %}** supports one
220
308
221
309
Whitespace between instructions is ignored, so the instructions can be written as a single paragraph, each on a new line, or separated by blank lines for legibility.
222
310
311
+
> [!TIP]
312
+
> The first time you create a pull request in a given repository with {% data variables.copilot.copilot_coding_agent %}, {% data variables.product.prodname_copilot_short %} will leave a comment with a link to automatically generate custom instructions for the repository.
313
+
223
314
### Using one or more `.instructions.md` files
224
315
225
316
1. Create the `.github/instructions` directory if it does not already exist.
@@ -397,7 +488,7 @@ Your choice persists, for all repositories containing a custom instructions file
397
488

398
489
399
490
1. In the "Options" dialog, type `custom instructions` in the search box, then click **{% data variables.product.prodname_copilot_short %}**.
400
-
1. Select or clear the checkbox for **(Preview) Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests**.
491
+
1. Select or clear the checkbox for **Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests**.
401
492
402
493
{% data reusables.copilot.custom-instructions-enabling-for-ccr %}
Copy file name to clipboardExpand all lines: content/copilot/tutorials/coding-agent/get-the-best-results.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,9 @@ If {% data variables.product.prodname_copilot_short %} is able to build, test an
79
79
80
80
You can add instructions in a single `.github/copilot-instructions.md` file in the repository, or create one or more `.github/instructions/**/*.instructions.md` files applying to different files or directories in your repository. For more information, see [AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot?tool=webui).
81
81
82
-
Here is an example of an effective `copilot-instructions.md` file:
82
+
The first time you ask {% data variables.product.prodname_copilot_short %} to create a pull request in a given repository, {% data variables.product.prodname_copilot_short %} will leave a comment with a link to automatically generate custom instructions. You can also ask {% data variables.product.prodname_copilot_short %} to generate custom instructions for you at any time using our recommended prompt. See [AUTOTITLE](/copilot/how-tos/configure-custom-instructions/add-repository-instructions?tool=webui#asking-copilot-coding-agent-to-generate-a-githubcopilot-instructionsmd-file).
83
+
84
+
You can also choose to write your own custom instructions at any time. Here is an example of an effective `copilot-instructions.md` file:
83
85
84
86
```markdown
85
87
This is a Go based repository with a Ruby client for certain API endpoints. It is primarily responsible for ingesting metered usage for GitHub and recording that usage. Please follow these guidelines when contributing:
Copy file name to clipboardExpand all lines: content/site-policy/github-terms/github-pre-release-license-terms.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ These terms apply to the pre-release software made available to you by GitHub. T
26
26
27
27
## 2. Installation and Use Rights.
28
28
29
-
a. **General**. GitHub grants you a limited right to use a non-production instance of the software. You may use any number of copies of the software to develop and test your applications, including deployment within your internal corporate network. You may also use the software in demonstrating your applications.
29
+
a. **General**. GitHub grants you a limited right to use a non-production instance of the software for evaluation and testing. This means you may use any number of copies of the software to evaluate its functionality and internally develop and test your applications, including deployment of the software within your internal corporate network for evaluation but not external distribution. You may also use the software in internally demonstrating your applications, but may not use the pre-release software in any active production environment, including any use to process live customer data.
30
30
31
31
b. **Inclusion of Third-Party Components.** The software may include third-party components with separate legal notices or governed by other agreements, as may be described in a license file accompanying the software.
Copy file name to clipboardExpand all lines: data/reusables/copilot/code-review/custom-instructions-information.md
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,3 @@
1
-
> [!NOTE]
2
-
> Custom instructions for {% data variables.copilot.copilot_code-review_short %} are in {% data variables.release-phases.public_preview %} and are subject to change.
3
-
>
4
-
> During the {% data variables.release-phases.public_preview %}, if you're using a {% data variables.copilot.copilot_business_short %} or {% data variables.copilot.copilot_enterprise_short %} plan, the organization or enterprise that provides your plan must have the **Opt in to preview features** setting enabled. See [AUTOTITLE](/enterprise-cloud@latest/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-policies-for-copilot-in-your-organization#enabling-copilot-features-in-your-organization) or [AUTOTITLE](/enterprise-cloud@latest/copilot/managing-copilot/managing-copilot-for-your-enterprise/managing-policies-and-features-for-copilot-in-your-enterprise#copilot-in-githubcom)
5
-
6
1
You can customize {% data variables.copilot.copilot_code-review_short %} by adding a `.github/copilot-instructions.md` file in your repository containing information that you want {% data variables.product.prodname_copilot_short %} to consider when reviewing code. This is the same `copilot-instructions.md` used by {% data variables.copilot.copilot_chat_short %}. See [AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot).
0 commit comments