Yesterday I talked about custom instructions as a general way to influence the behavior of Github Copilot in multiple contexts(coding, testing, reviewing, ...) in VS Code. With prompt files you can go one step further, and provide specific instructions for a task.
Let’s give this feature a try.
Active the prompts file feature
First we need to activate this feature:
- Go to File –> Preferences –> Settings.
- Search for Chat and look for the Prompt files setting.
- Click on the Edit in settings.json link.
- The settings.json file is opened with a new
chat.promptFiles
setting already added. - Change the value to
true
. Now VSCode will look for prompt files in the.github/prompts
folder.
Creating a prompt file
Now we are ready to add one or more prompts file to the .github/prompts
folder.
For every task you should create a separate Markdown prompt file.
Generate a new Blazor form component. If the form name and fields are not provided, ask for them.
Requirements for the form:
- Use Bootstrap form components (or specify your preferred UI framework)
- Implement two-way data binding using
@bind
or@bind-value
- Define C# model classes for your form data
- Use Data Annotations for validation
- Create reusable validation attributes in separate files
- Implement custom validation when needed
- Add user-friendly validation messages
- Use
EditForm
andDataAnnotationsValidator
- Implement proper form submission handling
- Include loading states
- Handle success/error states
- Display validation summary if needed
- Follow Blazor component lifecycle best practices
Remark: It is possible to reference other files inside your Markdown prompt file as well:
Generate a new Blazor form component. If the form name and fields are not provided, ask for them.
Requirements for the form:
- Incorporate these general instructions: design-rules/general.md
Using a prompt file
Now we can use our newly created prompt files.
- Open the VSCode Copilot Chat window:
-
Select the Attach Context icon (Ctrl+/), and then select Prompt....
-
Choose a prompt file from the Quick Pick to attach it to your chat request.
-
Now we can either directly send the prompt or include other instructions.