Prompt files turn repeated GitHub Copilot chat requests into slash commands. You write the instructions once in a Markdown file, save it in your Visual Studio Code profile, and run it from any repository with /command-name.
The example below builds a /commit command. It checks your Git changes, decides whether to commit staged changes or stage everything, writes a conventional commits message, creates the commit, and stops before pushing.
- Docs: VS Code - Prompt Files
- Examples: github/awesome-copilot
Why Use a Prompt File?
You can ask Copilot to commit your work with plain English:
Analyze my changes, write a Conventional Commit message, commit the changes, and do not push.
That works once. The next time, you still need to remember the staging rules, the message format, and the "do not push" guardrail.
A prompt file captures those rules. You call /commit, and Copilot receives the same instructions each time.
Prompt files fit personal workflows better than always-on custom instructions. You invoke them when you need them, and they can contain task-specific steps that would be noisy in a global instruction file.
Store It in Your VS Code User Profile
VS Code supports prompt files in two scopes:
| Scope | Location | Visibility |
|---|---|---|
| Workspace |
.github/prompts/ folder in your repo |
Only that project |
| User profile | VS Code user data directory | All repositories opened with that VS Code profile |
Use the user profile for commands like /commit, /review, or /pr. On Windows, user prompt files live in:
%APPDATA%\Code\User\prompts\
Create this file:
%APPDATA%\Code\User\prompts\commit.prompt.md
VS Code uses the filename as the slash command name, so commit.prompt.md becomes /commit.
Use Chat: New Prompt File from the Command Palette and choose User, or create the file in the directory above. If you use multiple VS Code profiles, create the prompt in the profile where you want the command.
To sync prompts across machines, enable Settings Sync and include Prompts and Instructions.
Prompt File Structure
A prompt file has YAML frontmatter and a Markdown body:
---
description: "Short description shown in autocomplete"
agent: "agent"
model: "Claude Sonnet 4.6"
tools: ['search/codebase', 'vscode/askQuestions']
---
## Your Instructions Here
Detailed step-by-step instructions for the AI...
Use frontmatter to control how Copilot runs the prompt:
| Field | Purpose |
|---|---|
description |
Shown when browsing commands - helps you remember what it does |
name |
Overrides the slash command name - defaults to the filename |
agent |
Which agent runs it: ask (read-only), agent (can run tools/commands), plan
|
model |
Pins a model, such as Claude Sonnet 4.6 or GPT-4o
|
tools |
Restrict available tools to a specific set |
argument-hint |
Hint text shown in the chat input field |
For a commit workflow, agent: "agent" matters. The ask agent can explain a commit message, but it cannot run git diff, git add, or git commit. Pin the model if you want consistent behavior instead of whichever model you last selected in chat.
Build the /commit Command
Paste this into commit.prompt.md:
---
description: "Review git changes, generate a commit message following best practices, and commit (without pushing)"
agent: "agent"
model: "Claude Sonnet 4.6"
---
## Task
You are creating a Git commit for the current repository.
1. **Confirm context** - Run `git rev-parse --show-toplevel`. If this is not a Git repository, stop and explain the problem.
2. **Check status** - Run `git status --short` and `git diff --cached --stat` to determine whether changes are already staged.
3. **Choose the commit set:**
- **Staged changes exist** - Analyze only the staged diff (`git diff --cached`). Do NOT stage additional files. Commit only what is already staged.
- **Nothing staged** - Analyze all unstaged changes (`git diff` and `git status`). Stage everything (`git add -A`) before committing.
4. **Analyze intent** - Combine two sources of context:
- **Git diff**: Read enough context to understand the *purpose* of each change, not just the diff lines.
- **Chat history**: Review the recent conversation for task descriptions, decisions, and rationale that explain *why* these changes were made. Prefer the user's own wording when it captures intent well.
5. **Protect commit quality** - If the diff mixes unrelated changes, ask before committing.
6. **Write the message** - Use the Conventional Commits format below.
7. **Commit** - Write the commit message to a temporary file and run `git commit -F <file>`. Delete the temporary file after the commit. **Do NOT push.**
8. **Report** - After a successful commit, print the full commit message in a fenced code block so the user can review what was committed.
## Commit Message Format
<type>(<optional scope>): <subject>
<body - what and why, not how>
<optional footer>
### Rules
- **subject**: imperative mood, no period, max 72 chars (e.g., "Add retry logic for flaky API calls")
- **type**: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `perf`, `style`, `ci`, `build`
- **scope**: affected module / area (omit if change is cross-cutting)
- **body**: wrap at 72 chars; explain *motivation* and *trade-offs* when the diff isn't self-explanatory; bullet list for multi-part changes
- **footer**: `BREAKING CHANGE:` or issue refs when applicable
### Quality Checklist
- One logical change per commit - if the diff covers unrelated changes, ask before committing
- Avoid generic messages ("fix stuff", "update code", "WIP")
- Reference the *what* and *why*; the diff already shows *how*
The temporary message file avoids command-line quoting problems with multi-line commit messages.
How to Use It
- Open any repository in VS Code
- Make some changes to your code
- Open the Chat view
- Type
/commitand press Enter - The AI analyzes your changes, writes a message, and commits
If you staged specific files first, /commit commits only those staged files. If nothing is staged, it stages the full working tree before committing.
That behavior makes the command useful in two modes:
| Situation | What /commit does |
|---|---|
| You staged a curated change set | Commits only the staged files |
| You have unstaged work | Stages everything and commits it |
Use /commit after a conversation where Copilot helped you make the change. The prompt tells Copilot to use the chat history, so the commit body can capture the reason behind the work, not only the diff.
Refine the Prompt
Good prompt files read like a checklist for a capable teammate:
- Give Copilot an exact workflow - command order, branch conditions, and stopping points
- Name forbidden actions -
Do NOT pushbelongs in the prompt, not in your memory - Define the output shape - commit format, wrapping, and final report
- Ask Copilot to stop when the diff mixes unrelated work
- Keep the prompt focused on one job
Test the prompt in a throwaway repository before using it on important work. Open the prompt file and use the play button in the editor title area, or run /commit from Chat.
Create Prompt Files with Copilot
You can generate prompt files with Copilot. In VS Code Chat, type:
/create-prompt
Describe the task, choose User or Workspace scope, then edit the generated file. You can also ask Copilot to turn a useful chat session into a reusable prompt.
Prompt Files vs Custom Instructions vs Agent Skills
| Feature | Custom Instructions | Prompt Files | Agent Skills |
|---|---|---|---|
| Activation | Automatic (always-on) | Manual (/command) |
Manual (/command) |
| Scope | Project or user | Project or user | Project (portable) |
| Complexity | Simple rules | Single-file workflow | Multi-file with scripts/resources |
| Shareability | Copy the file | Copy the file | Install via gh skill
|
| Best for | Coding standards | Personal workflows | Reusable team capabilities |
Use a prompt file when you need a slash command for one repeated task. Use custom instructions when you want rules applied to all requests. Use agent skills when the workflow needs scripts, supporting files, or a package others can install.
More User-Level Prompt Ideas
-
/review- perform a focused code review of staged changes -
/pr- create a pull request with a well-structured description -
/test- generate tests for the current file following your team's conventions -
/refactor- suggest and apply refactoring improvements -
/doc- generate documentation for the selected code
Top comments (0)