GitHub Copilot along with its various models are capable of some amazing things. When in Agent mode the AI can create parts of or even entire applications from your written (or spoken!) instructions. You can just feel the vibes (coding), can’t you?
Note
GitHub Copilot Agent mode is more than code completion, it’s an AI-powered agent that can take actions on your behalf within your development environment. It can create entire applications, including all the necessary files, and then compile the app to verify there’s not compile-time errors. When you hear people talk about vibe coding, they’re talking about Agent mode.One thing remains the same though no matter how advanced the AI gets: You have to supply it with clear, detailed, and at times verbose instructions – or prompts – to get the response to do what you want.
There’s a big difference between:
Create a console app that manages the user's todos.
And
Create a console application that manages the user's todos.
The todos will remain only in memory and thus will only be available while the app is running, no persistence.
The application should allow users to add a new item, mark an item as done and delete an item.
Use a loop so the user can continuously choose an action until they explicitly want to quit.
Use the latest version of C# - which is C# 13.
Make sure to apply exception handling.
The code should be legible, favor readability over terseness.
Insert a newline before the opening curly brace of any codeblock (e.g. after if, for, while, etc).
Write clear and concise documentation.
Put a funny emoji at the end of every comment.
It sure would be nice if there was a way that we could combine the terseness of the first prompt – just get to the point and do what we want! – without having to include the boilerplate formatting and best practices instructions every single time we interact with the AI.
There sure is – custom instructions.
Custom instructions
Custom instructions are how you give the AI specific context about your team’s workflow, your particular style preferences, coding standards, etc. Custom instructions are contained in a markdown file and in it you can provide the AI instructions on how to understand your project better.
Custom instructions define how tasks should be performed. Like which technologies are preferred. Or the physical project structure that should be followed. Or what to check for in a code review.
Instead of having to include the common guidelines or rules to get the responses you want in every single chat query, custom instructions automatically incorporate that information with every chat request.
So if your team has specific formatting, error-handling, or naming conventions – custom instructions ensures the AI responses align with them from the very start. And custom instructions help reduce friction when using Copilot. You don’t have to remember to update its code responses to align with your team’s coding standards – or prompt it every single time to produce output that does.
Important
Custom instructions are not taken into account for code completions.Using custom instructions
Sounds good right? So let’s get started with putting a custom instruction into our project. I’m going to walk you through a way that works with both Visual Studio and VS Code. At this time VS Code has a couple of ways to handle instructions which you can read about.
-
In your project create a .github folder at the root of your solution.
-
Then create a file named copilot-instructions.md in that folder.
-
Now, in markdown, enter the instructions. Need some ideas? There’s a great repository of community provided custom instructions. I’m going to use the C# instructions from that repo. Here’s a snippet:
--- description: 'Guidelines for building C# applications' applyTo: '**/*.cs' --- # C# Development ## C# Instructions - Always use the latest version C#, currently C# 13 features. - Write clear and concise comments for each function. ## General Instructions - Make only high confidence suggestions when reviewing code changes. - Write code with good maintainability practices, including comments on why certain design decisions were made. - Handle edge cases and write clear exception handling. - For libraries or external dependencies, mention their usage and purpose in comments.
-
That’s it! Have a project you’re working on loaded, open up GitHub Copilot, switch to Agent mode and ask it to do something.
And after agent mode is finished running, you will see that it used the custom instructions file to inform its responses. If you read through the details, you’ll notice that the AI has output that makes reference to the topics included in the custom instructions file. So it’s just like you passed all the content in copilot-instructions.md along with the prompt!
Summary
You can get responses from the AI in GitHub Copilot that is customized for your team’s needs and project requirements by providing the context with every request. Of course you could provide all of that context manually by typing it into the chat every single time. More realistically though, custom instructions are here for you. Custom instructions allow you to tell the AI how to do something by defining your team’s common guidelines and rules that need to be followed across the project.
Take one of your projects, grab one of the community provided instructions from the Awesome GitHub Copilot and start using them today. Let us know what you think, we can’t wait to see what you build.
The term “vibe coding” is almost never used as a compliment. You know that, right?