GitHub Copilot Prompt Files - Reusable Prompts as Slash Commands
Turn repeated Copilot prompts into .prompt.md files in .github/prompts and inject them into any chat with /. Setup, format, and the ones I use.
The Problem#
Some prompts I type into Copilot Chat every week: “investigate before you fix, present a plan, wait for approval, then make the minimal change.” Retyping it means I shorten it, and a shortened prompt means Copilot skips steps.
Custom chat modes fix this for whole workflows, but a mode’s prompt and tools apply to the entire conversation. I wanted something I could drop into any chat, in any mode, mid-conversation.
The Solution#
Prompt files. Put a markdown file in .github/prompts/ with a .prompt.md suffix, and Copilot Chat offers it as a slash command. Typing /bug-fix injects the whole file into the conversation.
.github
├── chatmodes
│ └── package-upgrade.chatmode.md
├── copilot-instructions.md
└── prompts
├── bug-fix.prompt.md
├── add-feature.prompt.md
└── code-review.prompt.mdshHow to Do It#
1. Create the file#
Create .github/prompts/<name>.prompt.md. The file name becomes the slash command.
The frontmatter is optional but description is worth setting, since it shows in the / picker:
---
description: 'Systematic bug fix approach for any codebase'
---
# Bug Fix Template
## Before Starting
- Follow behavioral rules: [copilot-instructions.md](../copilot-instructions.md)
- For project technical context: [copilot-project-context.md](../copilot-project-context.md)
## Investigation Phase
1. **Reproduce the issue** - Understand the exact problem and steps to reproduce
2. **Identify affected components** - Find all files and functions involved
3. **Check error logs and console output** - Gather technical details
4. **Review recent changes** - Check git history for related commits
## Analysis Phase
1. **Root cause analysis** - Determine the underlying cause, not just symptoms
2. **Check library documentation** - Consult official docs for known issues or breaking changes
3. **Impact assessment** - Consider what else might be affected by the fix
4. **Solution options** - Identify multiple approaches
5. **Choose minimal fix** - Least risk, least complexity
## Implementation Phase
**🛑 STOP HERE - DO NOT PROCEED WITHOUT USER APPROVAL 🛑**
- Present your analysis above to the user
- Wait for explicit "proceed" confirmation
- Do NOT make any file changes until approved
- State your confidence level (High/Medium/Low)
Only after user approval:
1. **Implement fix** - Make the minimal necessary change
2. **Verify fix works** - Ensure the original issue is resolved
3. **Test related functionality** - Make sure nothing else brokemarkdownOther frontmatter keys you can set:
mode:ask,editoragent, to switch the chat mode when the prompt runstools: restrict which tools the agent may use for this promptmodel: pin a specific model
I leave those out. The prompt should work in whatever mode I’m already in.
2. Use it#
In Copilot Chat, type / and pick the prompt from the list. Anything you type after the command is appended as extra context.
The full file is injected into the conversation, alongside copilot-instructions.md and whatever files you’ve attached:
3. Keep them consistent#
All my prompt files share the same shape:
- A Before Starting block linking to the instructions and project context, so the prompt never duplicates them
- Numbered phases, so Copilot reports progress phase by phase
- A 🛑 STOP gate before anything is edited
- A one-line reminder at the end of what “good” looks like
The three I use most:
- bug-fix.prompt.md: investigate, analyse, stop, fix minimally
- add-feature.prompt.md: requirements, design, plan, stop, build data layer first
- code-review.prompt.md: quality, technical, standards, security checklist, no edits
Tips#
- Prompt files vs chat modes. A chat mode is a persona for the whole conversation (fixed tools, fixed system prompt). A prompt file is a procedure for one request. Use modes for repeatable workflows like package upgrades, prompt files for everything else.
- Don’t put project facts in prompt files. Link to
copilot-project-context.mdinstead, or the two drift apart. See Why Your Copilot Instructions Stop Working. - User-level prompts. VS Code also supports prompt files in your user profile, for prompts you want in every repo. Repo-level ones in
.github/prompts/are shared with the team via git. - Keep them short. The whole file lands in the context window every time you invoke it.
Summary#
A .prompt.md file in .github/prompts/ turns a procedure you keep retyping into a /command that works in any Copilot chat, without the all-or-nothing commitment of a custom chat mode.