Skip to content

Commit 86a98f8

Browse files
authored
Merge pull request #90 from github-samples/minor-updates
Improve documentation clarity and navigation with reference links
2 parents 58e39d2 + 41ed8b7 commit 86a98f8

17 files changed

+468
-189
lines changed

content/1-hour/0-setup.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Workshop setup
22

3-
To complete this workshop you will need to create a repository with a copy of the contents of this repository. While this can be done by [forking a repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo), the goal of a fork is to eventually merge code back into the original (or upstream) source. In our case we want a separate copy as we don't intend to merge our changes. This is accomplished through the use of a [template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository). Template repositories are a great way to provide starters for your organization, ensuring consistency across projects.
3+
| [← Getting started with GitHub Copilot][walkthrough-previous] | [Next: Coding with GitHub Copilot →][walkthrough-next] |
4+
|:-----------------------------------|------------------------------------------:|
5+
6+
To complete this workshop you will need to create a repository with a copy of the contents of this repository. While this can be done by [forking a repository][fork-repo], the goal of a fork is to eventually merge code back into the original (or upstream) source. In our case we want a separate copy as we don't intend to merge our changes. This is accomplished through the use of a [template repository][template-repo]. Template repositories are a great way to provide starters for your organization, ensuring consistency across projects.
47

58
The repository for this workshop is configured as a template, so we can use it to create your repository.
69

710
> [!IMPORTANT]
8-
> Ensure you have the [requisite software](./README.md#required-local-installation) and [requisite resources](./README.md#required-resources) setup.
11+
> Ensure you have the [requisite software][required-software] and [requisite resources][required-resources] setup.
912
1013
## Create your repository
1114

@@ -51,8 +54,8 @@ With the repository created, it's now time to clone the repository locally. We'l
5154

5255
The startup script will start two applications:
5356

54-
- The backend Flask app on [localhost:5100](http://localhost:5100). You can see a list of dogs by opening the [dogs API](http://localhost:5100/api/dogs).
55-
- The frontend Astro/Svelte app on [localhost:4321](http://localhost:4321). You can see the [website](http://localhost:4321) by opening that URL.
57+
- The backend Flask app on [localhost:5100][flask-url]. You can see a list of dogs by opening the [dogs API][dogs-api].
58+
- The frontend Astro/Svelte app on [localhost:4321][astro-url]. You can see the [website][website-url] by opening that URL.
5659

5760
## Open your editor
5861

@@ -65,6 +68,19 @@ With the code cloned locally, and the site running, let's open the codebase up i
6568
6669
## Summary and next steps
6770
68-
You've now cloned the repository you'll use for this workshop and have your IDE setup! Next let's [add a new endpoint to the server](./1-add-endpoint.md)!
71+
You've now cloned the repository you'll use for this workshop and have your IDE setup! Next let's [add a new endpoint to the server][walkthrough-next]!
72+
73+
74+
| [← Getting started with GitHub Copilot][walkthrough-previous] | [Next: Coding with GitHub Copilot →][walkthrough-next] |
75+
|:-----------------------------------|------------------------------------------:|
6976

70-
**NEXT:** [Exercise 1: Add an endpoint](./1-add-endpoint.md)
77+
[astro-url]: http://localhost:4321
78+
[dogs-api]: http://localhost:5100/api/dogs
79+
[flask-url]: http://localhost:5100
80+
[fork-repo]: https://docs.github.com/en/get-started/quickstart/fork-a-repo
81+
[required-resources]: ./README.md#required-resources
82+
[required-software]: ./README.md#required-local-installation
83+
[template-repo]: https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository
84+
[walkthrough-previous]: README.md
85+
[walkthrough-next]: ./1-add-endpoint.md
86+
[website-url]: http://localhost:4321

content/1-hour/1-add-endpoint.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
# Coding with GitHub Copilot
22

3-
With code completion, GitHub Copilot provides suggestions in your code editor while you're coding. This can turn comments into code, generate the next line of code, and generate an entire function just from a signature. Code completion helps reduce the amount of boilerplate code and ceremony you need to type, allowing you to focus on the important aspects of what you're creating.
3+
| [← Workshop setup][walkthrough-previous] | [Next: Helping GitHub Copilot understand context →][walkthrough-next] |
4+
|:-----------------------------------|------------------------------------------:|
5+
6+
7+
With code completions, GitHub Copilot provides suggestions in your code editor while you're coding. This can turn comments into code, generate the next line of code, and generate an entire function just from a signature. Code completion helps reduce the amount of boilerplate code and ceremony you need to type, allowing you to focus on the important aspects of what you're creating.
48

59
## Scenario
610

711
It's standard to work in phases when adding functionality to an application. Given that we know we want to allow users to filter the list of dogs based on breed, we'll need to add an endpoint to provide a list of all breeds. Later we'll add the rest of the functionality, but let's focus on this part for now.
812

9-
The application uses a Flask app with SQLAlchemy as the backend API (in the [/server](/server/) folder), and an Astro app with Svelte as the frontend (in the [/client](/client/) folder). You will explore more of the project later; this exercise will focus solely on the Flask application.
13+
The application uses a Flask app with SQLAlchemy as the backend API (in the [/server][server-code] folder), and an Astro app with Svelte as the frontend (in the [/client][client-code] folder). You will explore more of the project later; this exercise will focus solely on the Flask application.
1014

1115
> [!NOTE]
1216
> As you begin making changes to the application, there is always a chance a breaking change could be created. If the page stops working, check the terminal window you used previously to start the application for any error messages. You can stop the app by using <kbd>Ctl</kbd>+<kbd>C</kbd>, and restart it by running `./scripts/start-app.sh`.
1317
1418
## Flask routes
1519

16-
While we won't be able to provide a full overview of [routing in Flask](https://flask.palletsprojects.com/en/stable/quickstart/#routing), they are defined by using the Python decorator `@app.route`. There are a couple of parameters you can provide to `@app.route`, including the path (or URL) one would use to access the route (such as **api/breeds**), and the [HTTP method(s)](https://www.w3schools.com/tags/ref_httpmethods.asp) which can be used.
20+
While we won't be able to provide a full overview of [routing in Flask][flask-routing], they are defined by using the Python decorator `@app.route`. There are a couple of parameters you can provide to `@app.route`, including the path (or URL) one would use to access the route (such as **api/breeds**), and the [HTTP method(s)][http-methods] which can be used.
1721

1822
## Code completion
1923

@@ -61,25 +65,38 @@ Let's build our new route in our Flask backend with the help of code completion.
6165
return jsonify(breeds_list)
6266
```
6367

64-
> [!IMPORTANT]
65-
> Because LLMs are probabilistic, not deterministic, the exact code generated can vary. The above is a representative example. If your code is different, that's just fine as long as it works!
68+
> [!IMPORTANT]
69+
> Because LLMs are probabilistic, not deterministic, the exact code generated can vary. The above is a representative example. If your code is different, that's just fine as long as it works!
6670

6771
8. **Save** the file.
6872

6973
## Validate the endpoint
7074

7175
With the code created and saved, let's quickly validate the endpoint to ensure it works.
7276

73-
1. Navigate to [http://localhost:5100/api/breeds](http://localhost:5100/api/breeds) to validate the route. You should see JSON displayed which contains the list of breeds!
77+
1. Navigate to [http://localhost:5100/api/breeds][breeds-endpoint] to validate the route. You should see JSON displayed which contains the list of breeds!
7478

7579
## Summary and next steps
7680

77-
You've added a new endpoint with the help of GitHub Copilot! You saw how Copilot predicted the next block of code you were likely looking for and provided the suggestion inline, helping save you the effort of typing it out manually. Let's start down the path of performing more complex operations by [exploring our project](./2-explore-project.md).
81+
You've added a new endpoint with the help of GitHub Copilot! You saw how Copilot predicted the next block of code you were likely looking for and provided the suggestion inline, helping save you the effort of typing it out manually. Let's start down the path of performing more complex operations by [exploring our project][walkthrough-next].
7882

7983
## Resources
8084

81-
- [Code suggestions in your IDE with GitHub Copilot](https://docs.github.com/en/copilot/using-github-copilot/getting-code-suggestions-in-your-ide-with-github-copilot)
82-
- [Code completions with GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/ai-powered-suggestions)
83-
- [Prompt crafting](https://code.visualstudio.com/docs/copilot/prompt-crafting)
85+
- [Code suggestions in your IDE with GitHub Copilot][copilot-suggestions]
86+
- [Code completions with GitHub Copilot in VS Code][vscode-copilot]
87+
- [Prompt crafting][prompt-crafting]
88+
89+
90+
| [← Workshop setup][walkthrough-previous] | [Next: Helping GitHub Copilot understand context →][walkthrough-next] |
91+
|:-----------------------------------|------------------------------------------:|
8492

85-
**NEXT:** [Exercise 2: Explore your project with Copilot](./2-explore-project.md)
93+
[breeds-endpoint]: http://localhost:5100/api/breeds
94+
[client-code]: /client/
95+
[copilot-suggestions]: https://docs.github.com/en/copilot/using-github-copilot/getting-code-suggestions-in-your-ide-with-github-copilot
96+
[flask-routing]: https://flask.palletsprojects.com/en/stable/quickstart/#routing
97+
[http-methods]: https://www.w3schools.com/tags/ref_httpmethods.asp
98+
[prompt-crafting]: https://code.visualstudio.com/docs/copilot/prompt-crafting
99+
[server-code]: /server/
100+
[vscode-copilot]: https://code.visualstudio.com/docs/copilot/ai-powered-suggestions
101+
[walkthrough-previous]: ./0-setup.md
102+
[walkthrough-next]: ./2-explore-project.md

content/1-hour/2-explore-project.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Helping GitHub Copilot understand context
22

3+
| [← Coding with GitHub Copilot][walkthrough-previous] | [Next: Providing custom instructions →][walkthrough-next] |
4+
|:-----------------------------------|------------------------------------------:|
5+
36
The key to success when coding (and much of life) is context. Before we add code to a codebase, we want to understand the rules and structures already in place. When working with an AI coding assistant such as GitHub Copilot the same concept applies - the quality of suggestion is directly proportional to the context Copilot has. Let's use this opportunity to both explore the project we've been given and how to interact with Copilot to ensure it has the context it needs to do its best work.
47

58
## Scenario
@@ -8,7 +11,7 @@ Before adding new functionality to the website, you want to explore the existing
811

912
## Chat participants and extensions
1013

11-
GitHub Copilot Chat has a set of available [chat participants](https://code.visualstudio.com/docs/copilot/copilot-chat#_chat-participants) and [extensions](https://docs.github.com/en/copilot/using-github-copilot/using-extensions-to-integrate-external-tools-with-copilot-chat) available to you to both provide instructions to GitHub Copilot and access external services. Chat participants are helpers which work inside your IDE and have access to your project, while extensions can call external services and provide information to you without having to open separate tools. We're going to focus on one core chat participant - `@workspace`.
14+
GitHub Copilot Chat has a set of available [chat participants][chat-participants] and [extensions][copilot-extensions] available to you to both provide instructions to GitHub Copilot and access external services. Chat participants are helpers which work inside your IDE and have access to your project, while extensions can call external services and provide information to you without having to open separate tools. We're going to focus on one core chat participant - `@workspace`.
1215

1316
`@workspace` creates an index of your project and allows you to ask questions about what you're currently working on, to find resources inside the project, or add it to the context. It's best to use this when the entirety of your project should be considered or you're not entirely sure where you should start looking. In our current scenario, since we want to ask questions about our project, `@workspace` is the perfect tool for the job.
1417

@@ -26,12 +29,21 @@ GitHub Copilot Chat has a set of available [chat participants](https://code.visu
2629

2730
## Summary and next steps
2831

29-
You've explored context in GitHub Copilot, which is key to generating quality suggestions. You saw how you can use chat participants to help guide GitHub Copilot, and how with natural language you can explore the project. Let's see how we can provide even more context to Copilot chat through the use of [Copilot instructions](./3-copilot-instructions.md).
32+
You've explored context in GitHub Copilot, which is key to generating quality suggestions. You saw how you can use chat participants to help guide GitHub Copilot, and how with natural language you can explore the project. Let's see how we can provide even more context to Copilot chat through the use of [Copilot instructions][walkthrough-next].
3033

3134
## Resources
3235

33-
- [Copilot Chat cookbook](https://docs.github.com/en/copilot/copilot-chat-cookbook)
34-
- [Use Copilot Chat in VS Code](https://code.visualstudio.com/docs/copilot/copilot-chat)
35-
- [Copilot extensions marketplace](https://github.com/marketplace?type=apps&copilot_app=true)
36+
- [Copilot Chat cookbook][copilot-cookbook]
37+
- [Use Copilot Chat in VS Code][copilot-chat-vscode]
38+
- [Copilot extensions marketplace][copilot-marketplace]
39+
40+
| [← Coding with GitHub Copilot][walkthrough-previous] | [Next: Providing custom instructions →][walkthrough-next] |
41+
|:-----------------------------------|------------------------------------------:|
3642

37-
**NEXT:** [Add Copilot instructions for additional context](./3-copilot-instructions.md)
43+
[chat-participants]: https://code.visualstudio.com/docs/copilot/copilot-chat#_chat-participants
44+
[copilot-chat-vscode]: https://code.visualstudio.com/docs/copilot/copilot-chat
45+
[copilot-cookbook]: https://docs.github.com/en/copilot/copilot-chat-cookbook
46+
[copilot-extensions]: https://docs.github.com/en/copilot/using-github-copilot/using-extensions-to-integrate-external-tools-with-copilot-chat
47+
[copilot-marketplace]: https://github.com/marketplace?type=apps&copilot_app=true
48+
[walkthrough-previous]: ./1-add-endpoint.md
49+
[walkthrough-next]: ./3-copilot-instructions.md

content/1-hour/3-copilot-instructions.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Providing custom instructions
22

3+
| [← Coding with GitHub Copilot][walkthrough-previous] | [Next: Add the filter feature →][walkthrough-next] |
4+
|:-----------------------------------|------------------------------------------:|
5+
36
There are always key pieces of information anyone generating code for your codebase needs to know - the technologies in use, coding standards to follow, project structure, etc. Since context is so important, as we've discussed, we likely want to ensure Copilot always has this information as well. Fortunately, we can provide this overview through the use of Copilot instructions.
47

58
## Scenario
@@ -21,8 +24,8 @@ Here are some guidelines to consider when creating a Copilot instructions file:
2124
- languages, frameworks and libraries in use.
2225
- required assets to be generated (such as unit tests) and where they should be placed.
2326
- any language specific rules such as:
24-
- utilize [type hints](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html) in Python.
25-
- use [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) rather than the `function` keyword in TypeScript.
27+
- utilize [type hints][type-hints] in Python.
28+
- use [arrow functions][arrow-functions] rather than the `function` keyword in TypeScript.
2629
- If you notice GitHub Copilot consistently provides an unexpected suggestion (e.g. using class components for React), add those notes to the instructions file.
2730

2831
## Create a Copilot instructions file
@@ -40,8 +43,8 @@ Let's create a Copilot instructions file. We'll start by asking Copilot to gener
4043
4144
5. Note the function signature is similar to `def validate_dog_age(age)` without type hints.
4245
43-
> [!NOTE]
44-
> Because LLMs are probabilistic rather than deterministic, the exact code will vary.
46+
> [!NOTE]
47+
> Because LLMs are probabilistic rather than deterministic, the exact code will vary.
4548
4649
6. Create a new file in the **.github** folder called **copilot-instructions.md**.
4750
7. Add the markdown to the file necessary which provides information about the project structure and requirements:
@@ -77,8 +80,8 @@ Whenever you make a call to Copilot chat, the references dialog indicates all fi
7780
Create a Python function to validate dog age. Ensure age is between 0 and 20. Throw an error if it is outside this range.
7881
```
7982
80-
> [!TIP]
81-
> You can use up arrow to resend previous prompts to Copilot chat.
83+
> [!TIP]
84+
> You can use up arrow to resend previous prompts to Copilot chat.
8285
8386
4. Note the references now includes the instructions file and provides information gathered from it.
8487
@@ -90,15 +93,23 @@ Whenever you make a call to Copilot chat, the references dialog indicates all fi
9093
def validate_dog_age(age: int):
9194
```
9295
93-
> [!NOTE]
94-
> The exact code generated will vary, but the new Python suggestion should now utilize type hints.
96+
> [!NOTE]
97+
> The exact code generated will vary, but the new Python suggestion should now utilize type hints.
9598
9699
## Summary and next steps
97100
98-
Copilot instructions improves the quality of suggestions, and ensures better alignment with the desired practices you have in place. With the groundwork in place, let's [add new functionality to our website](./4-add-feature.md)!
101+
Copilot instructions improves the quality of suggestions, and ensures better alignment with the desired practices you have in place. With the groundwork in place, let's [add new functionality to our website][walkthrough-next]!
99102
100103
## Resources
101104
102-
- [Adding repository custom instructions for GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
105+
- [Adding repository custom instructions for GitHub Copilot][custom-instructions]
106+
107+
108+
| [← Coding with GitHub Copilot][walkthrough-previous] | [Next: Add the filter feature →][walkthrough-next] |
109+
|:-----------------------------------|------------------------------------------:|
103110
104-
**NEXT:** [Add a new feature to your website](./4-add-feature.md)
111+
[arrow-functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
112+
[custom-instructions]: https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot
113+
[type-hints]: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
114+
[walkthrough-previous]: ./2-explore-project.md
115+
[walkthrough-next]: ./4-add-feature.md

0 commit comments

Comments
 (0)