iTranslated by AI
Loading multiple instruction files in VS Code Copilot
Copilot refers to the .github/copilot-instructions.md file by default.
However, it seems it doesn't read additional files even if you include references like foo/bar.md within that file, which is often inconvenient.
Configuring in VS Code
I found in the VS Code configuration documentation that you can add settings like the following:
"github.copilot.chat.codeGeneration.instructions": [
{
"file": ".rules/rules.md"
}
],
There are also several other types of instructions (though I haven't tested them):
-
github.copilot.chat.testGeneration.instructions- Instructions for test code generation -
github.copilot.chat.reviewSelection.instructions- Instructions for code reviews -
github.copilot.chat.commitMessageGeneration.instructions- Instructions for commit message generation
It also seems possible to add instructions via text instead of a file (I haven't tested this either).
Utilizing Symbolic Links
When organizing instruction content into files, you might want to share common rule files across multiple projects.
In such cases, using symbolic links is convenient.
$ ln -s ~/.config/rules/rules ./.rules
If there are parts you don't want to involve in the project, you could add them to .gitignore (perhaps .config/.git/ignore is better?).
.rules/**/*
This allows you to reuse the same settings across projects you want to share.
How to Verify
When you run Copilot, there is a small collapsible display like "2 references used". You can verify whether it is being read by expanding this.
It's also a good idea to have it respond with something like "Please say XXX if you have read this file" to confirm.
Discussion