Improve Copilot Git Commit with Custom Instruction
GitHub Copilot is an AI-powered code editor that can help you write code faster by suggesting code snippets, completing functions, and it even can help you generate Git commit messages which suggests commit messages based on the code changes.
In VSCode, you can find this feature in the Source Control panel within commit message input. It appears as a sparkle icon. You can simply click on this icon to generate the commit message.

It’s that easy and straightforward to use. But there’s one problem: the message generated feels pretty generic. What if you want to enforce specific pattern like Commitizen, or include description?
Fortunately, Github Copilot allows you to do that. Let’s see how:
Modify Github Copilot Instruction
To improve Copilot’s commit messages, we need to configure custom instructions in VSCode:
First, we need to go the VSCode Settings. You can hit Ctrl + , or Cmd + , if you’re on a macOS.
Search for Commit Message Generation Instruction
. You should find at the very top of the result, as seen below:

Click on the Edit in settings.json under the section. This should generate the key required in the setting to provide our custom instructions.
{ github.copilot.chat.commitMessageGeneration.instructions: [] }
As we can see above, the setting accepts an array. It means that can provide as multiple instructions to Copilot.
We can provide the instruction as plain text.
For example, we can add a very simple instruction to generate the commit message with the Conventional Commits format.
{ "github.copilot.chat.commitMessageGeneration.instructions": [ { "text": "Use the Conventional Commit message specification." }, { "text": "If possible, explain the details about the changes in commit body." } ] }
Before changing the format, Copilot would typically generate the message as Add UUID generation tests for feature.
. After changing it, Github Copilot will write the commit message in all lowercase, and correctly mark the type of change as per the Conventional Commits, as we can see below:

We can add multiple instructions. In this case, I’d like to expand the instruction to add more details about the changes in the commit body.

Using File Instruction
If your custom instruction needs to be detailed, and that it can be pretty long, you can consider adding it in a Markdown or plain text file.
For example, we can add the following in a file:
The commit message should be a brief summary of the changes followed by a blank line and a more detailed explanation. The detailed explanation should be in the form of a paragraph or paragraphs.
Then, we simply reference the file in the config with the file
prop.
{ github.copilot.chat.commitMessageGeneration.instructions: [ { "file": "commit-message-instruction.md" } ] }
Wrapping up
That’s it! You can define the configuration at the User or Workspace level, which will help you ensure that everyone working on your project would generate commit messages that follow the required format in the project, and include the necessary details.
This feature is available in the Github Copilot free tier. If you haven’t used it, give it a try. It is so convenient and I believe will make you even be more productive.