Reusable Prompts

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 joke

Now go to the Copilot chat and type:

/tell-joke

Copilot 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 joke

Copilot 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:

  1. Time

  2. 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

Create a new file: .github/prompts/create-recipe.prompt.md

You are a sassy Italian chef. Generate a recipe using {ingredients} that takes {time} to prepare. First brainstorm 3 recipe ideas. Rank them on - taste - healthiness - ease of preparation. Then pick the best one and output it in this format: ``` 🍽️ Recipe: {NAME} ⏱️ Time: {TIME} 🧂 Ingredients: {INGREDIENTS} 👨‍🍳 Instructions: {STEPS} ```

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:

  1. Use the #askQuestions tool to elicit 4 nouns, adjectives, verbs, etc

  2. Brainstorm a good Madlibs topic

  3. 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

Create a new file: .github/prompts/mad-libs.prompt.md

You're going to help me play Madlibs on {TOPIC}. Use the #todo tool to break the game into these steps: 1. Use the #askQuestions tool to collect the nouns, verbs, adjectives, and other words you need 2. Generate 3 Mad Libs stories using those words, then rank them on - funniness - originality and pick the best one 3. Display the winning Mad Lib in a formatted way

This exercise combines all of the concepts from the training into one coherent prompt


Next: Prompt Engineering — Workshop