When it comes to configuring the behavior of GitHub Copilot,
another interesting feature are chat instructions, which you can
also generate right from inside here.
Now, what is that all about? The idea behind chat instructions,
see, you can use the AI for generating them,
general instructions which you know you want the
AI to follow over and over again. Now here, when you
use generate instructions, it generates an instructions file
automatically based on your existing code base, which can be useful if you're
using GitHub Copilot in an existing code base, and you wanna make sure that
it uses the same coding style and rules you are
using in that code base. So for example, here, it generated
instructions that made it very clear which tech stack we're using and
which patterns we're using. So it analyzes your code base to
architecture, which patterns, which approaches you're using so that
future generations follow these patterns.
Now, you're not limited to automatically
You can also do it manually, and there are different ways of doing
that. Locally in your workspace, there is this .GitHub folder, which
already stores my prompt file and so on.
And if I click on chat instructions here, I can add a new instruction
file to that folder in the end, or as we just did it, generate them
automatically. But now I'll do it manually.
Store it locally or again globally if you have instructions
projects, and then here, I could have my Python rules
instruction file. Now with those instructions, you can
control to which prompts or which tasks
they should apply to. Apply_to simply takes a path
pattern. So if I would, for example, say to py, it would
only apply to Python files, but not to Markdown or other code files,
and then you simply add your instructions as normal text.
In the end, it will be dynamically injected into your
scenes. That's how you can think of these
It's a prompt extension that will automatically be loaded
when the AI wants to edit a Python file, for example.
So here we could say prefix_all_my functions with
max. Obviously, not necessarily something you wanna
do, but a good way of showing how instructions
In reality, you would use this to encode best
approaches you want the AI to use or certain rules you want it to
follow. But with such an instruction file
added, we could then say update main.py,
and it will automatically load this instructions file, as you see here
under references. It loaded it because I'm
working on a py file, and it understands
prefixed with max because that's in the instruction file.
Again, just an example, but shows you how they work,
and the great thing about these instructions is, of course, not just
set them up globally, but you also commit them with your
so all your colleagues have them too, and you can also share them across
So here it's now going ahead and it prefixed all these functions with
max. Good? I don't know, but it was my instruction and it followed
it.