|
| 1 | +## Step 1: Setting Up Copilot Instructions |
| 2 | + |
| 3 | +You're a teacher at Mergington High School who creates homework assignments and coding exercises for students. You maintain a static website to share these assignments and want to establish general standards for AI assistants to ensure consistent code quality and project structure. |
| 4 | + |
| 5 | +You've heard Copilot Instructions can help with that! |
| 6 | + |
| 7 | +<details> |
| 8 | +<summary>Website screenshot 📸</summary><br/> |
| 9 | + |
| 10 | +You will run this website in the first activity! |
| 11 | + |
| 12 | +<img width="600" alt="screenshot of homework website" src="https://github.com/user-attachments/assets/2383b6e9-64d5-4907-94b3-b67153efb008" /> |
| 13 | + |
| 14 | +</details> |
| 15 | + |
| 16 | +### 📖 Theory: What are repository custom instructions? |
| 17 | + |
| 18 | +Repository custom instructions let you provide Copilot with repository-specific guidance and preferences that help it understand your project context and standards. By creating a `.github/copilot-instructions.md` file, you can ensure that Copilot's suggestions consistently follow your project conventions and coding standards. |
| 19 | + |
| 20 | +The complete set of instructions will be automatically added to all requests that you submit to Copilot Chat in your repository. |
| 21 | + |
| 22 | +> [!TIP] |
| 23 | +> Keep instructions short and focused on the "how" of the project. This could be purpose, folder structure, coding standards, key tools, expected formats, etc. |
| 24 | +
|
| 25 | +See the [GitHub Docs: Repository Custom Instructions](https://docs.github.com/en/copilot/how-tos/custom-instructions/adding-repository-custom-instructions-for-github-copilot) page for more information. |
| 26 | + |
| 27 | +### ⌨️ Activity: Explore the Educational Website Project |
| 28 | + |
| 29 | +To work with custom instructions, let's first set up our development environment and explore the project structure. |
| 30 | + |
| 31 | +1. Right-click the below button to open the **Create Codespace** page in a new tab. Use the default configuration. |
| 32 | + |
| 33 | + [](https://codespaces.new/{{full_repo_name}}?quickstart=1) |
| 34 | + |
| 35 | +1. Confirm the **Repository** field is your copy of the exercise, not the original, then click the green **Create Codespace** button. |
| 36 | + |
| 37 | + - ✅ Your copy: `/{{full_repo_name}}` |
| 38 | + - ❌ Original: `/skills/customize-your-github-copilot-experience` |
| 39 | + |
| 40 | +1. Wait a moment for Visual Studio Code to load in your browser and for all extensions to install. |
| 41 | + |
| 42 | + - Ensure the **Live Preview** extension is activated. |
| 43 | + - Ensure the **Python** extension is activated. |
| 44 | + |
| 45 | +1. Right-click on `index.html` and select **Show Preview** to see the website in action. |
| 46 | + |
| 47 | + > ❕ **Important**: Keep the preview tab open to see the live updates. We will be making edits throughout the exercise. |
| 48 | +
|
| 49 | +1. Explore the project structure: |
| 50 | + |
| 51 | + - Browse the `assets/` folder to see the website assets (CSS, JavaScript, images). |
| 52 | + - Look at the `assignments/` folder to understand the existing assignment formats. |
| 53 | + - Review `index.html` in the root directory to see the main website structure. |
| 54 | + - Review `config.json` in the root directory to see how the assignments are set up. |
| 55 | + |
| 56 | +### ⌨️ Activity: Create Repository Copilot Instructions |
| 57 | + |
| 58 | +Now that you've explored the project, let's create custom instructions to help Copilot understand your educational website project. |
| 59 | + |
| 60 | +1. In VS Code, create a new file called `.github/copilot-instructions.md` |
| 61 | + |
| 62 | + > ❕ **Important:** Make sure the file name is correct. This specific filename is required for Copilot to recognize it. |
| 63 | +
|
| 64 | +1. Add the following content so Copilot understands the project's purpose, structure, and requirements: |
| 65 | + |
| 66 | + ```markdown |
| 67 | + # Project Description |
| 68 | + |
| 69 | + This project is an educational website for sharing homework assignments and coding exercises with students. Students can browse, view, and download assignments directly from the portal. |
| 70 | + |
| 71 | + ## Project Structure |
| 72 | + |
| 73 | + - [`assignments/`](../assignments/) Each homework assignment is stored in its own subfolder with a consistent structure. |
| 74 | + - [`templates/`](../templates/) Reusable templates for new content |
| 75 | + - [`assets/`](../assets/) Contains the website assets including CSS, JavaScript, images, and configuration files |
| 76 | + - [`index.html`](../index.html) The main website page that serves as a static portal for browsing and viewing assignments. Content is configurable via [`config.json`](../config.json) file to dynamically generate assignment lists and details. |
| 77 | + |
| 78 | + ## Project Guidelines |
| 79 | + |
| 80 | + - Maintain consistent styling across all pages |
| 81 | + - Keep file and folder names descriptive and organized |
| 82 | + |
| 83 | + ## Educational Standards |
| 84 | + |
| 85 | + When generating content for this project: |
| 86 | + |
| 87 | + - **Learning-focused**: All content should be designed with clear learning objectives and appropriate difficulty levels |
| 88 | + - **Student-friendly**: Use clear, encouraging language that motivates students |
| 89 | + ``` |
| 90 | + |
| 91 | +1. Test your instructions by asking Copilot about the project: |
| 92 | + |
| 93 | + >  |
| 94 | + > |
| 95 | + > ```prompt |
| 96 | + > Briefly explain this project to me |
| 97 | + > ``` |
| 98 | +
|
| 99 | +1. Notice that Copilot uses your custom instructions as a reference in the response. |
| 100 | +
|
| 101 | + <img width="504" height="183" alt="image" src="https://github.com/user-attachments/assets/2214ed9e-c165-4440-a23e-d2d33c0231a9" /> |
| 102 | +
|
| 103 | +1. Commit the `.github/copilot-instructions.md` file to the `main` branch and push it to GitHub. |
| 104 | +
|
| 105 | +1. Wait for Mona to prepare the next step! |
| 106 | +
|
| 107 | +<details> |
| 108 | +<summary>Having trouble? 🤷</summary><br/> |
| 109 | +
|
| 110 | +- The `.github/copilot-instructions.md` file should be at the root of the `.github` folder |
| 111 | +- Make sure you committed and pushed the changes. |
| 112 | +
|
| 113 | +</details> |
0 commit comments