Markdown Converter
Agent skill for markdown-converter
| [← Coding with GitHub Copilot][walkthrough-previous] | [Next: Add the filter feature →][walkthrough-next] |
Sign in to like and favorite skills
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.
Before we begin larger updates to the site with the help of Copilot, we want to ensure Copilot has a good understanding of how we're building our application. As a result, we're going to add a Copilot instructions file to the repository.
Copilot instructions is a markdown file is placed in your .github folder. It becomes part of your project, and in turn to all contributors to your codebase. You can use this file to indicate various coding standards you wish to follow, the technologies your project uses, or anything else important for Copilot Chat to understand when generating suggestions.
[!IMPORTANT] The copilot-instructions.md file is included in every call to GitHub Copilot Chat, and will be part of the context sent to Copilot. Because there is always a limited set of tokens an LLM can operate on, a large Copilot instructions file can obscure relevant information. As such, you should limit your Copilot instructions file to project-wide information, providing an overview of what you're building and how you're building it. If you need to provide more specific information for particular tasks, you can create prompt files.
Here are some guidelines to consider when creating a Copilot instructions file:
function keyword in TypeScript.Let's create a Copilot instructions file. We'll start by asking Copilot to generate a block of code, then add the instructions file, then ask the same question again to see the changes.
Return to your IDE with your project open.
Close any tabs you may have open in your IDE to ensure Copilot chat has an empty context.
Select the
+ icon towards the top of Copilot chat to begin a new chat.
Open Copilot Chat and send the following prompt:
Create a Python function to validate dog age. Ensure age is between 0 and 20. Throw an error if it is outside this range.
Note the function signature is similar to
def validate_dog_age(age) without type hints.
[!NOTE] Because LLMs are probabilistic rather than deterministic, the exact code will vary.
Create a new file in the .github folder called copilot-instructions.md.
Add the markdown to the file necessary which provides information about the project structure and requirements:
# Dog shelter This is an application to allow people to look for dogs to adopt. It is built in a monorepo, with a Flask-based backend and Astro-based frontend. ## Backend - Built using Flask and SQLAlchemy - Use type hints ## Frontend - Built using Astro and Svelte - TypeScript should use arrow functions rather than the function keyword - Pages should be in dark mode with a modern look and feel
Save the file.
Whenever you make a call to Copilot chat, the references dialog indicates all files used to generate the response. Once you create a Copilot instructions file, you will see it's always included in the references section. Since you included directions to use type hints, you'll notice the code suggestions will follow this guidance.
Close all files currently open in VS Code or your Codespace. (This will ensure we are working with an empty context.)
Select the
+ icon in GitHub Copilot chat to start a new chat.
Send Copilot chat the same prompt you used previously:
Create a Python function to validate dog age. Ensure age is between 0 and 20. Throw an error if it is outside this range.
[!TIP] You can use up arrow to resend previous prompts to Copilot chat.
Note the references now includes the instructions file and provides information gathered from it.

Note the resulting Python now utilizes type hints, and the function signature will resemble the following:
def validate_dog_age(age: int):
[!NOTE] The exact code generated will vary, but the new Python suggestion should now utilize type hints.
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!