Reusable Prompts
Every prompt you've written so far lives only in the chat. Reusable prompts let you save a prompt to a file and invoke it with a slash command — any time, by anyone on your team.
Because they're files, reusable prompts can be checked into version control alongside your code. That means they evolve with your project, your team can improve them over time, and everyone runs the same prompt rather than each person writing their own from scratch.
Set up
In your project, create this folder structure:
.github/
prompts/Any file inside .github/prompts/ with the name something.prompt.md becomes a slash command called /something.
Create your first one: .github/prompts/tell-joke.prompt.md
Tell me a dad jokeNow go to the Copilot chat and type:
/tell-jokeCopilot will read the file and run it. That's it.
Parameters
A static prompt is useful, but parameters make reusable prompts genuinely powerful. Use curly braces {} (or another obvious delimeter) to mark where input should go:
Tell me a {JOKE_TYPE} joke.Now, when you invoke the prompt, you can pass a value right after the slash command:
/tell-joke
JOKE_TYPE = knock knock jokeCopilot maps "knock knock" to {JOKE_TYPE} automatically — it's smart enough to figure out what you mean. If you don't pass a value, Copilot will most likely ask you for it.
You don’t need to explicitly specify
JOKE_TYPE = knock knock joke, generally Copilot can figure it out if you just do/tell-joke knock knock
You can have as many parameters as you need. The agent handles them flexibly — you don't need to follow a rigid format, just make the curly-brace label descriptive enough to be understood.
Control the Output Format
You can also define exactly how the response should be structured. Add a format template to your prompt:
Tell me a {JOKE_TYPE} joke.
Use the following format:
```
🤣{JOKE_TYPE}🤣
joke: {JOKE}
```Copilot will reproduce that structure every time the prompt runs. Consistent format = easier to read, easier to share, easier to build on.
Tree of Thought
Here's one more technique worth adding to your prompts: ask Copilot to brainstorm multiple options before committing to one.
Update your tell-joke.prompt.md to include:
Tell me a {JOKE_TYPE} joke.
Use the following format:
```
🤣{JOKE_TYPE}🤣
joke: {JOKE}
```
Before responding, generate 3 joke ideas, rank them on:
- Funniness
- Originality
Then pick the best one and Now Copilot evaluates its own ideas before giving you an answer. This tends to produce better, more considered output — especially for creative tasks.
✏️ Exercise 1: Recipe Prompt
Create a reusable prompt instructing the agent to give you a recipe
Add 2 parameters:
Time
Ingredients
Have the agent generate 3 recipes, rank them on taste, healthiness, and ease of creation, then pick the best one and display it.
BONUS:
Add a persona for the type of chef the agent is
Have the recipe output in a particular format you define
If you don't pass values for {INGREDIENTS} and {TIME}, Copilot should ask you for them.
✏️ Exercise 2: Mad Libs (Capstone)
Write a reusable prompt for playing a Mad Libs game
Instruct the agent to use the #todo tool. On your own, break down the process of running the Mad Libs game into 3 steps.
ex:
Use the
#askQuestionstool to elicit 4 nouns, adjectives, verbs, etcBrainstorm a good Madlibs topic
Write the Madlibs and present a formatted version to the user
BONUS:
Use parameters to control the story topic
Use tree-of-thought to have the agent rank 3 different madlibs on custom criteria
This exercise combines all of the concepts from the training into one coherent prompt