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
Copy file name to clipboardExpand all lines: docs/3-custom-instructions.md
+2-66Lines changed: 2 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Context is key across many aspects of life, and when working with generative AI.
7
7
8
8
In this exercise, you will learn how to:
9
9
10
-
- provide Copilot with project-specific context, coding guidelines and documentation standards using [repository custom instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions)**.github/copilot-instructions.md**.
10
+
- provide Copilot with project-specific context, coding guidelines and documentation standards using [repository custom instructions][repository-custom-instructions]**.github/copilot-instructions.md**.
11
11
- provide path instruction files to guide Copilot for repetitive or templated tasks on specific types of files.
12
12
- implement both repository-wide instructions and task-specific instructions.
13
13
@@ -160,68 +160,4 @@ We want to create a new endpoint to list all publishers, and to follow the same
160
160
161
161

162
162
163
-
13. Send the same prompt as before to generate the desired endpoint:
164
-
165
-
```plaintext
166
-
Create a new endpoint to return a list of all publishers. It should return the name and id for all publishers.
167
-
```
168
-
169
-
14. Note the **References** section and how it uses the **flask-endpoint.instructions.md** file to provide context. If you use instructions files with Copilot agent mode, you will notice that Copilot explores and reads the files referenced in the instructions file.
170
-
171
-

172
-
173
-
15. Copilot generates the files. Notice how it generates updates across multiple files, like **publishers.py** and **test_publishers.py**
174
-
175
-
> [!NOTE]
176
-
> Note that the code generated may diverge from some of the standards we set. AI tools like Copilot are non-deterministic, and may not always provide the same result. The other files in our codebase do not contain docstrings or comment headers, which could lead Copilot in another direction. Consistency is key, so making sure that your code follows the established patterns is important. You can always follow-up in chat and ask Copilot to follow your coding standards, which will help guide it in the right direction.
177
-
178
-
16. After reviewing the code, select **Keep** in Copilot Chat to accept the changes.
179
-
17. If you are prompted to run tests select **Cancel**; we'll perform this task later.
180
-
18. Open a terminal window by selecting <kbd>Ctl</kbd> + <kbd>\`</kbd>.
181
-
19. Run the tests by running the script with the following command:
182
-
183
-
```sh
184
-
./scripts/run-server-tests.sh
185
-
```
186
-
187
-
20. Once the code is correct, and all tests pass, open the **Source Control** panel on the left of the Codespace and review the changes made by Copilot.
188
-
189
-
> [!NOTE]
190
-
> If any tests fail, ask Copilot to suggest a fix. You can use `@terminal /explain` to give Copilot the context of your terminal window.
191
-
192
-
21. Stage the changes by selecting the **+** icon in the **Source Control** panel.
193
-
22. Generate a commit message using the **Sparkle** button.
194
-
195
-

196
-
197
-
23. Commit the changes to your repository by selecting **Commit**.
198
-
199
-
## Summary and next steps
200
-
201
-
Congratulations! You explored how to ensure Copilot has the right context to generate code following the practices your organization has set forth. This can be done at a repository level with the **.github/copilot-instructions.md** file, or on a task basis with instruction files. You explored how to:
202
-
203
-
- provide Copilot with project-specific context, coding guidelines and documentation standards using custom instructions (.github/copilot-instructions.md).
204
-
- use instruction files to guide Copilot for repetitive or templated tasks.
205
-
- implement both repository-wide instructions and task-specific instructions.
206
-
207
-
Next we'll use [agent mode to add functionality to the site][next-lesson].
208
-
209
-
## Resources
210
-
211
-
-[Instruction files for GitHub Copilot customization][instruction-files]
212
-
-[Best practices for creating custom instructions][instructions-best-practices]
213
-
-[Personal custom instructions for GitHub Copilot][personal-instructions]
0 commit comments