Have you been prompting GitHub Copilot a lot? Sometimes you might write the same or similar prompts over and over again. It can be super annoying to tell GitHub Copilot how to interpret and react to a prompt every single time we write in the chat. That's where custom instructions come in handy and can really help supercharge your workflow.
Sometimes there are organisation-, company-, or project-specific policies and guidelines that you need to adhere to. For example, you might have set frameworks and tools you use. Your project or community might specify a certain method for naming functions, or guidelines for writing comments. Rather than tell these instructions to Copilot every time, we can save this type of information to make our development even smoother.
There are two main ways we can customise the way GitHub Copilot responds to prompts. These are:
- Custom instructions
- Prompt files
Custom instructions
These are instructions help to guide GitHub Copilot on the way we want GitHub Copilot to behave. Instructions can be given and used in various ways. At the time of writing, these are the custom instructions available:
- Personal custom instructions.
- Repository-wide custom instructions: these will be read by the whole repo.
- Path-specific custom instructions: these will be read by a specific file only.
- Organization custom instructions: used at the Organization level and set by Org Owners with a Copilot Enterprise subscription.
- Agent instructions: used by AI Agents.
Personal custom instructions
This is a way to interact with GitHub Copilot on the web, and provide a way for GitHub Copilot to interpret the prompt we are writing in the chat.
Let's try out personal custom instructions:
- Open GitHub Copilot on the web.
- Enter a prompt to convert numbers into Roman numerals. Something like:
Create a JavaScript function that converts numbers into Roman numerals. - See the output.
Now let's add a custom instruction to change how Copilot interprets the prompt:
- Access your GitHub Copilot settings by going to your Profile → Personal instructions.
- In the pop-up, enter some instructions, such as:
Always do the following when writing functions:
- Add descriptive comments
- Add input validation
- Use returns early to account for error conditions
- Use meaningful variable names
- Include at least one example usage in comments
- Re-enter the same prompt and analyse the differences.
You can read more about custom instructions on the GitHub Docs.
Repository-wide custom instructions
Creating instructions at the repository level is useful for telling GitHub Copilot how to act for a certain project. If you are using specific frameworks, coding languages, or comments, it ensures everyone is on the same page and Copilot can always perform the same for everyone.
For repo-specific instructions, we need to create a copilot-instructions.md file in the .github directory. There are two ways we can achieve this:
- Writing our own from scratch.
- Getting GitHub Copilot to write them for us.
Custom repo instructions should also already be set to on by default:
Let's write our own custom instructions:
- In your editor, open your repo.
- Create a new
copilot-instructions.mdin the.githubdirectory. - Write instructions in natural language using markdown, including something like:
# Project Overview
This project [describe your project]
## Folder Structure
[list the folder structure]
## Libraries and Frameworks
[list any libraries it uses]
## Coding Standards
[list your coding standards]
## UI guidelines
[list your UI guidelines standards]
This can seem like a lot of work, so we can get GitHub Copilot to write custom instructions for us instead. There are a couple of ways we can do this:
- Go to the GitHub Copilot Agents page.
- Select your repo from the dropdown.
- Enter the following:
Your task is [describe the task] by adding a .github/copilot-instructions.md file in the repository.
<Goals>
[outline the goals you want GitHub Copilot to achieve]
</Goals>
<Limitations>
[add limitations such as length or task-specific]
<WhatToAdd>
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:
<HighLevelDetails>
- A summary of what the repository does.
- High-level repository information, such as the size of the repo, the type of the project, the languages, frameworks, or target runtimes in use.
</HighLevelDetails>
Add information about how to build and validate changes so the agent does not need to search and find it each time.
<BuildInstructions>
[put in some build instructions]
</BuildInstructions>
List key facts about the layout and architecture of the codebase to help the agent find where to make changes with minimal searching.
<ProjectLayout>
[add in what the project does and how it works]
</ProjectLayout>
</WhatToAdd>
<StepsToFollow>
[what should GitHub Copilot do, maybe perform search of what's available, scripts etc., then think]
</StepsToFollow>
- Click the arrow or press enter.
- Analyse the output and adjust if needed.
We can also have VS Code do it all for us:
- Open the repo you'd like custom instructions for.
- In the chat menu, click the "Settings icon".
- Click "Generate instructions".
- In the chat window, view the steps GitHub Copilot took.
- Review the
.copilot-instructions.mdfile.
Read more about custom repo instructions on the GitHub Docs.
Path-specific custom instructions
These are similar to repo instructions, but can be created for specific files. This is useful if we only want Copilot to apply logic to a certain file in the repo. Path-specific instructions are currently only supported by VS Code and JetBrains IDEs.
Create path-specific instructions by:
- In your editor, open the repo where you want to make a file-specific instruction.
- Create a new folder called
instructionsunder the.githubdirectory. - Create a new file called
NAME.instructions.md. NAME should indicate the purpose of the instructions. You can create as many of these instructions as you like. - Open the file and on the first line write:
applyTo: "app/models/**/*.rb"to indicate which files you want the instructions to apply to. You can specify multiple files by using a comma:applyTo: "**/*.ts,**/*.tsx". You can also apply the instructions to all files usingapplyTo: "**". This is useful if you're creating multiple instructions and you want some high level instructions to apply to everything and other sub-instructions to apply to specific files. - Add instructions again using natural language in markdown.
Organization custom instructions
Instructions can also be set at the organization level and are useful for enforcing your company's, team's, or community's policies and guidelines. Org custom instructions are currently in public preview, and can only be set by Org Owners with a Copilot Enterprise subscription.
You can read more about it in the GitHub announcement blog post.
Agent instructions
A lot of people are now using AI Agents, and you can write instructions for them too. These instructions are used by AI Agents to dictate how they perform. The AGENTS.md file can sit anywhere in your repository, and is written with natural language in markdown. It's an open format for guiding coding agents. You can also use a CLAUDE.md or GEMINI.md file that will sit in the root of your repo.
Check out the Open AI example of how instructions should be written for coding Agents.
Prompt files
Now that you have a handle on all the custom instructions, let's look at prompt files. These differ as they are reusable prompts for specific tasks that we can call via the chat window. For example, instead of using @workspace in Copilot chat to look at the entire workspace, you can call a custom file you've already created. This is useful for setting up lots of types of prompting files, think explaining code, writing tests, and documentation.
Prompt files are currently in public preview and only available in VS Code and JetBrains IDEs. Let's look at each of these and what they do.
We can create prompt files by doing the following:
- In your editor, open the repository where you want to create a prompt file.
- Create a new folder called
promptsunder the.githubdirectory. - Create a new file in this new folder and name the file
explain-code.prompt.md - Enter the information you want your prompt to output or perform. As an example, you can use this prompt that helps with writing clear and well-documented code:
---
mode: 'agent'
description: 'Generate a clear code explanation with examples'
---
Explain the following code in a clear, beginner-friendly way:
Code to explain: ${input:code:Paste your code here}
Target audience: ${input:audience:Who is this explanation for? (e.g., beginners, intermediate developers, etc.)}
Please provide:
* A brief overview of what the code does
* A step-by-step breakdown of the main parts
* Explanation of any key concepts or terminology
* A simple example showing how it works
* Common use cases or when you might use this approach
Use clear, simple language and avoid unnecessary jargon.
- Go to the GitHub Copilot chat window and switch to "Agent" mode.
- Type
/explain-codeand review the output. - You should also notice that your new prompt file is being used as the reference.
When working with any type of custom prompting, we can always check to see if the instructions we've written above were used by checking which references were used in the chatbox.
Prompt engineering and customising your prompts
Custom instructions and prompt files aren’t just nice-to-haves, they’re powerful ways to shape how GitHub Copilot works for you. Pair these with strong prompting skills and an ethical approach to AI, and you’ll level up your entire development workflow. If you want a refresher, check out the articles on prompt engineering and responsible AI. They’re quick reads that reinforce the principles behind everything we’ve covered here.



Top comments (0)