iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🤔

Two Practical Examples of GitHub Copilot Custom Prompts I Actually Found Useful

に公開

Hello, I'm Gyori!
Are you making use of GitHub Copilot's "Custom Prompts"?

Honestly, I wasn't using them much!
To be frank:

  • What I ask is different every time
  • I can't think of specific use cases
  • They didn't seem that convenient

So I didn't have high expectations for custom prompts, but I found a few use cases that were actually quite helpful, so I'd like to introduce two of them!

What are Custom Prompts?

Custom prompts allow you to instantly call up pre-prepared prompts in the chat input field just by typing:

/prompt-name

In short, it's a "mechanism to turn frequently used instructions into shortcuts."

How to create Custom Prompts

  1. Select "Prompt Files" from the gear icon ⚙ in the top right of Copilot Chat in VS Code.

  2. The command palette will open; select "+ New Prompt File".

  3. Select ".github/prompts".

    *The difference between these two is where the prompt file is saved. ".github/prompts" creates a .github directory in the currently open project and generates it there. "User Data" saves it in the user environment, so it can be referenced from all projects. On Windows, this is C:\Users\<username>\AppData\Roaming\Code\User\prompts\.

  4. A custom prompt file will then open, allowing you to customize it.

  5. You can define metadata in the section surrounded by hyphens (YAML front matter). The supported metadata is as follows. Please set them as needed.

Configuration items for Custom Prompts

Item Required Description
name × Defines the /prompt-name specified in the chat field. If not specified, the file name becomes /prompt-name.
agent × Choose which mode (Ask, Agent, etc.) to respond with. If not specified, it will respond in the current mode.
tools × Choose which tools to use. If not specified, the currently specified tools will be used as is.
※Note: Once executed, the tool settings of the last used custom prompt will be carried over in that session.
model × You can specify a model. If not specified, the current model will respond.
description × Displayed as a description of the custom prompt.
argument-hint × A placeholder displayed when you enter /prompt-name.

To be honest, I couldn't really think of many use cases

So far, I've briefly explained how to create custom prompts, but I couldn't really think of many use cases for them. Although you can find custom prompts created by others if you search, they often didn't match my specific development environment or goals, so I didn't feel much motivation to try them.

Rather than adjusting custom prompts, I found it more suitable to proceed step-by-step while interacting with the AI rather than fine-tuning prompts; I felt it was more efficient to spend that time on actual development. Any information I want the AI to reference every time (such as directory structure or coding conventions) is already included in my custom instructions (copilot-instruction.md).

However, as a side note, "Plan mode" is useful.
I use it when establishing execution plans for larger refactors. The workflow of first creating a plan and then proceeding to implementation once I'm satisfied is quite effective. I don't really intend to customize this through custom prompts, though...

After that long introduction,
here are the two use cases that I actually found useful while being skeptical.

Two examples I actually found useful

1. Translation prompt

---
name: translateToJapanese
description: Translates into Japanese
argument-hint: Enter the text you want to translate into Japanese
model: GPT-4o
---
Please translate the selected or attached text into Japanese.
The output should be the translation result only, without any other explanations or annotations.

What it does is super simple. It is a prompt solely for translating English → Japanese.

This was personally convenient for me. Previously, when reading comments or READMEs written in English, I had to copy and paste them into DeepL or Google Translate every time.

This was a subtle source of stress. I had to take my eyes off the editor every time, and while there is a VS Code extension called vscode-google-translate, I eventually stopped using it because the translations were too literal or it felt a bit slow.

This is how it looks with Copilot × Custom Prompts

With Copilot, you just select the English text in your code and enter the following in the chat window. #selection is a Copilot command that includes the currently selected code range in the prompt.

/translateToJapanese #selection

Since tab completion works:

/ja → /translateToJapanese
#sele → #selection

Input is completed in just a few keystrokes.

The quality of the translation is natural Japanese rather than a literal translation, which is great. The experience of being able to ask follow-up questions right there if I have doubts is also excellent. In a similar vein, I think it would be good to create prompts for explaining how to use library functions.

2. Review prompt

---
name: reviewChanges
description: Reports static analysis, type checking, test execution, and code review all at once
argument-hint: Executes the review
model: GPT-5.2-Codex (copilot)
---
Please review the current changes according to the following steps
Never modify the files
Only tell me the review results
If necessary, provide links to the relevant parts

1. Perform static analysis
2. Perform type checking
3. Run tests
4. Perform a code review
5. Return a summary of the review results from 1-4 to the user and finish

## Coding conventions
Coding conventions are described in the following files
- Python: pythonRule.instructions.md
- Typescript: tsRule.instructions.md

## Backend tools
Execute the following commands in the backend/ directory.
Static analysis/Formatter: uv run ruff check
Type check: uv run pyright
Test: uv run pytest
Coverage: uv run pytest --cov=. --cov-report=term-missing

## Frontend tools
Execute the following commands in the frontend/ directory.
Static analysis: npm run lint
Formatter: npm run format
Type check: npm run typecheck

This prompt executes static analysis, type checking, test execution, and code review all at once.
After completing an implementation, just typing /reviewChanges in a separate session is all you need to do.

In Vibe Coding, the loop of review and correction is very important, so this is quite helpful. Of course, you could define a sub-agent to automatically execute the review and correction loop, but I prefer this approach because I believe code quality is better maintained when you check and judge whether to apply those review suggestions with your own eyes (at least for now).

Since this prompt assumes a Python + TypeScript environment, please rewrite the commands according to your own environment.

Tip 1

For prompts that request a series of tasks:

  • Write numbered steps
  • Clearly state the goal of the task

Including these two points helps the AI work without getting lost, which reduces variance in the results.

Tip 2

Be sure to run reviews in a separate session.
This is because Copilot uses the history within the same session (which is extra information for a review) as context for generating responses.

Also, having the same model perform the review is similar to "reviewing your own code," so it's better to avoid it if possible. Choose a model you don't typically use for the review.

To be honest, since Copilot ultimately provides the same prompt to any model internally, it might be better to have tools like Claude Code CLI or Codex CLI perform the review. If you have multiple subscriptions, you should definitely try it!

3. Git Update Prompt (Added on 2/2)

--- 
name: gitPull
description: Updates Git to the latest state
argument-hint: Check out to a specified branch and update Git to the latest state
---
Retrieve the latest changes from the Git repository and update the local branch.
If no branch name is specified by the user, update the current branch.

Execute in the following order:
1. If a branch name is specified by the user, check out to that branch.
2. `git pull`
3. `git fetch -p`
4. Delete unnecessary local branches that remain from remote branches that have been merged and deleted.

I also made something like this.
I used to manually switch, pull, and delete unnecessary branches every time, so this prompt just handles all of that. It should help keep the Git Graph clean.

I feel like using Tasks might be better for this, though... 💦

Bonus: The /savePrompt Command

Finally, here's one feature that might be hit-or-miss but is handy to know.

/savePrompt

There is a command called /savePrompt. This command extracts general instructions based on your previous conversation and creates a new custom prompt for you.

It's worth trying when you think, "This interaction could probably be standardized." However, to be honest, the accuracy isn't that high, so it's recommended to use the generated prompt with the assumption that it will need some manual tweaking.

Summary

I think the best way to use them is not to try and turn everything into a prompt, but rather to extract only those tasks where you find yourself thinking, "I do this same thing every time." If you're interested, please give it a try!

Discussion