How to Create Custom GitHub Copilot Prompt Files
A guide on creating reusable prompt files for GitHub Copilot in VS Code to automate common tasks.
Prompt files are a great way to automate repetitive tasks with GitHub Copilot. Think of them as saved scripts for the chat. Instead of typing out a long instruction every time, you can just run a prompt file.
I use this to automate creating new cookbook metadata on my site.
Create the Prompt File
- Create a folder named
.github/prompts
at the root of your project. - Inside that folder, create a new file with a
.prompt.md
extension. For example,new-cookbook.prompt.md
.
Write the Prompt
A prompt file has two parts: a YAML frontmatter for configuration and a Markdown body for the instructions.
Here’s an example based on how I automate new cookbook creation. This
new-cookbook.prompt.md
file asks for a title and then uses a separate
instructions file to do the work.
---
description: "1. Create a new cookbook"
mode: "agent"
---
# Task: Create New Cookbook
You will help me create a new cookbook metadata file.
**Always follow the rules in [my instructions](../copilot-instructions.md). Pay
close attention to my "Writing Style Rules" and the "Cookbook & Recipe
Concept".**
## User Input:
(You will be prompted for these if not provided)
- **Cookbook Title:** `${input:title:Foundry Cookbook}`
- **First Recipe Idea:** `${input:recipeIdea:How to do multichannel test}`
- **File Slug:** `${input:slug:foundry}`
---
## Step 1: Draft Description
Based on the **Title** and **First Recipe Idea**, draft a `description` for the
cookbook.
- **Constraint:** The description must be **max 150 characters**.
- **Style:** It must follow my writing style and the cookbook concept from the
instructions.
- **Example:** "My personal cookbook for VS Code. It's where I keep my notes on
how to customize the editor, like making a new theme or changing GitHub
Copilot settings. Just a collection of solutions for myself so I can find them
again."
Ask for my approval before continuing.
## Step 2: Create File
Once I approve the description, create the new file:
- **File Path:** `src/content/cookbooks/${slug}.md`
- **Full Content:**
```markdown
---
title: ${title}
description: [Your approved description goes here]
---
```
How to Use It
Once the file is saved, you can run it directly from the VS Code chat.
- Open the GitHub Copilot chat.
- Type
/
and you should see your prompt file in the list. - Select
new-cookbook
and hit enter.
Copilot will then follow the instructions in your prompt file. It’s a simple way to make sure common tasks are done the same way every time.