# 初めてのプロンプト ファイル

任意のプログラミング言語で動くこの簡単なコードの説明の例を使って、Copilot プロンプト ファイルを初めて作成します。

> \[!NOTE]
>
> * Copilot プロンプト ファイルは パブリック プレビュー 段階であり、変更される可能性があります。 プロンプト ファイルは、VS Code、Visual Studio、および JetBrains IDE でのみ使用できます。「[GitHub Copilotの応答をカスタマイズする方法](/ja/copilot/concepts/prompting/response-customization#about-prompt-files)」を参照してください。
> * 特定の言語とシナリオ向けの、コミュニティに投稿されたプロンプト ファイルの例については、[Awesome GitHub Copilot Customizations](https://github.com/github/awesome-copilot/blob/main/docs/README.prompts.md) リポジトリを参照してください。

## カスタマイズについて

次の 2 種類のファイルを使って、GitHub Copilot の応答をカスタマイズできます。

* **カスタム指示** では、ユーザーのすべての対話に対して GitHub Copilot がどのように動作する必要があるかについての実行時のガイダンスを提供します。 入門の例については、「[初めてのカスタム指示](/ja/copilot/tutorials/customization-library/custom-instructions/your-first-custom-instructions)」を参照してください。
* **プロンプト ファイル (パブリック プレビュー)** では、必要に応じて呼び出すことができる、特定のタスクに対する再利用可能なプロンプトを定義します。 プロンプト ファイルは、VS Code、Visual Studio、および JetBrains IDE でのみ使用できます。

## 初めてのプロンプト ファイル

明確かつ適切に記述されたコードの説明を書くのに役立つ、この簡単なプロンプト ファイルを使って始めます。

### コードの説明のプロンプト

```text copy
---
agent: 'agent'
description: 'Generate a clear code explanation with examples'
---

Explain the following code in a clear, beginner-friendly way:

Code to explain: ${input:code:Paste your code here}
Target audience: ${input:audience:Who is this explanation for? (e.g., beginners, intermediate developers, etc.)}

Please provide:

* A brief overview of what the code does
* A step-by-step breakdown of the main parts
* Explanation of any key concepts or terminology
* A simple example showing how it works
* Common use cases or when you might use this approach

Use clear, simple language and avoid unnecessary jargon.
```

## テストする

1. 上記のプロンプト ファイルを `explain-code.prompt.md` として `.github/prompts` フォルダーに保存します。

2. Visual Studio Code で コパイロットチャット ビューに、「`/explain-code`」と入力します。

   Copilot は、エージェント モードがまだ選ばれていない場合はそれに切り替わり、コードと対象者の種類を入力するようユーザーに求めます。

3. 次のように入力します。

   ```text copy
   The code is `function fibonacci(n) { return n <= 1 ? n : fibonacci(n-1) + fibonacci(n-2); }`. The audience is beginners.
   ```

## 参考資料

* Visual Studio Code ドキュメントの「[Visual Studio Code でプロンプト ファイルを使う](https://code.visualstudio.com/docs/copilot/customization/prompt-files)」- プロンプト ファイルの作成と使用の方法に関する情報
* [GitHub Copilotの応答をカスタマイズする方法](/ja/copilot/concepts/response-customization) - GitHub Copilot での応答カスタマイズの概要
* [優れた GitHub Copilot カスタマイズ](https://github.com/github/awesome-copilot/blob/main/docs/README.prompts.md) - コミュニティに投稿されたカスタム プロンプト ファイルや、特定の言語やシナリオ向けのその他のカスタマイズのリポジトリ