Skip to main content

Copilot Chat のプロンプトの例

Copilot Chat のプロンプトとユース ケースの例を取得します。

Copilot Chat にプロジェクトに関する具体的な質問や、ソフトウェア全般に関する質問をすることができます。 また、Copilot Chat に、コードの記述、エラーの修正、テストの記述、およびドキュメント コードを依頼することもできます。

上記のタブを使用して、Copilot Chat を使用している環境を選択します。

次のプロンプト例の中には、チャット参加者 (前に @ が付く)、スラッシュ コマンド (前に / が付く)、またはチャット変数 (前に # が付く) を使用する場合があります。 プロンプトのキーワードについて詳しくは、「IDE で GitHub Copilot に質問する」をご覧ください。

ソフトウェアに関する一般的な質問を行う

Copilot Chat の一般的なソフトウェアに関する質問をすることができます。 次に例を示します。

  • tell me about nodejs web server frameworks
  • how to create an express app
  • @terminal how to update an npm package

プロジェクトに関する質問を行う

プロジェクトに関して Copilot Chat に質問できます。

  • what sorting algorithm does this function use
  • @workspace how are notifications scheduled
  • #file:gameReducer.js #file:gameInit.js how are these files related

Copilot に正しいコンテキストを提供するには、次の方法をいくつか試してください。

  • 関連するコード行を強調表示する
  • #selection#file#editor#codebase、または #git などのチャット変数を使用する
  • @workspace チャット参加者を使用する

コードの記述

variables.product.prodname_copilot_short %} にコードの記述を依頼できます。 次に例を示します。

  • write a function to sum all numbers in a list
  • add error handling to this function
  • @workspace add form validation, similar to the newsletter page

Copilot がコード ブロックを返すと、応答には、コードをコピーするか、カーソルにコードを挿入するか、新しいファイルに挿入するか、ターミナルに挿入するオプションが含まれます。

新しいプロジェクトを設定する

/new スラッシュ コマンドを使用して、新しいプロジェクトを設定します。 次に例を示します。

  • /new react app with typescript
  • /new python django web application
  • /new node.js express server

Copilot はディレクトリ構造を提案し、提案されたファイルと内容を作成するためのボタンを提供します。 提案されたファイルをプレビューするには、提案されたディレクトリ構造でファイル名を選択します。

/newNotebook スラッシュ コマンドを使用して、新しい Jupyter ノートブックを設定します。 次に例を示します。

  • /newNotebook retrieve the titanic dataset and use Seaborn to plot the data

コードの修正、改善、リファクタリング

アクティブなファイルにエラーが含まれている場合は、/fix スラッシュ コマンドを使用して、Copilot にエラーを修正するよう依頼します。

コードを改善またはリファクタリングするための一般的な要求を行うこともできます。

  • how would you improve this code?
  • translate this code to C#
  • add error handling to this function

テストを記述する

/tests スラッシュ コマンドを使用して、Copilot に、アクティブなファイルまたは選択したコードのテストを記述するように依頼します。 次に例を示します。

  • /tests
  • /tests using the Jest framework
  • /tests ensure the function rejects an empty list

スラッシュ コマンドは /tests 、既存のコードのテストを記述します。 コードを書き込む前にテストを記述する (テスト駆動開発) 場合は、/tests コマンドを省略します。 次に例を示します。

  • Add tests for a JavaScript function that should sum a list of integers

Visual Studio Code について質問する

@vscode チャット参加者を使用して、Visual Studio Code に関する具体的な質問をします。 次に例を示します。

  • @vscode tell me how to debug a node.js app
  • @vscode how do I change my Visual Studio Code colors
  • @vscode how can I change key bindings

コマンド ラインについて質問する

@terminal チャット参加者を使用して、コマンド ラインに関する具体的な質問をします。 次に例を示します。

  • @terminal find the largest file in the src directory
  • 最後のコマンドとエラーを説明する @terminal #terminalLastCommand

ソフトウェアに関する一般的な質問を行う

Copilot Chat の一般的なソフトウェアに関する質問をすることができます。 次に例を示します。

  • tell me about nodejs web server frameworks
  • how to create an express app
  • how to update an npm package

プロジェクトに関する質問を行う

プロジェクトに関して Copilot Chat に質問できます。 Copilot に正しいコンテキストを提供するには、次の方法をいくつか試してください。

  • 関連するコード行をハイライトする
  • 関連するファイルを開く
  • #file を使用して、特定のファイルを参照するように Copilot に指示できます
  • #solution を使用して、アクティブ ファイルを参照するように Copilot に指示できます

次に例を示します。

  • what sorting algorithm does this function use
  • #file:gameReducer.js what happens when a new game is requested

コードの記述

variables.product.prodname_copilot_short %} にコードの記述を依頼できます。 次に例を示します。

  • write a function to sum all numbers in a list
  • add error handling to this function

Copilot がコード ブロックを返す際、応答には、コードをコピーするか、新しいファイルに挿入するか、またはコードの出力をプレビューするかのオプションが含まれます。

コードを修正、改善、リファクタリングする

アクティブなファイルにエラーが含まれている場合は、/fix スラッシュ コマンドを使用して、Copilot にエラーを修正するよう依頼します。

コードを改善またはリファクタリングするための一般的な要求を行うこともできます。

  • how would you improve this code?
  • translate this code to C#
  • add error handling to this function

テストを記述する

/tests スラッシュ コマンドを使用して、Copilot に、アクティブなファイルまたは選択したコードのテストを記述するように依頼します。 次に例を示します。

  • /tests
  • /tests using the Jest framework
  • /tests ensure the function rejects an empty list

スラッシュ コマンドは /tests 、既存のコードのテストを記述します。 コードを書き込む前にテストを記述する (テスト駆動開発) 場合は、/tests コマンドを省略します。 次に例を示します。

  • Add tests for a JavaScript function that should sum a list of integers

ソフトウェアに関する一般的な質問を行う

Copilot Chat の一般的なソフトウェアに関する質問をすることができます。 次に例を示します。

  • tell me about nodejs web server frameworks
  • how to create an express app
  • how to update an npm package

プロジェクトに関する質問を行う

プロジェクトに関して Copilot Chat に質問できます。 Copilot に正しいコンテキストを提供するには、次の方法をいくつか試してください。

  • 関連するコード行をハイライトする。
  • 関連するファイルを開く。
  • 参照としてファイルを追加する。 ファイル参照 の使い方について詳しくは、「IDE で GitHub Copilot に質問する」をご覧ください。

次に例を示します。

  • what sorting algorithm does this function use
  • how are these files related (質問内のファイルへの参照を含む)

コードの記述

variables.product.prodname_copilot_short %} にコードの記述を依頼できます。 次に例を示します。

  • write a function to sum all numbers in a list
  • add error handling to this function

Copilot がコード ブロックを返す際、応答には、コードをコピーするか、そのコードをカーソルで挿入するかのオプションが含まれます。

コードを修正、改善、リファクタリングする

アクティブなファイルにエラーが含まれている場合は、/fix スラッシュ コマンドを使用して、Copilot にエラーを修正するよう依頼します。

コードを改善またはリファクタリングするための一般的な要求を行うこともできます。

  • how would you improve this code?
  • translate this code to C#
  • add error handling to this function

テストを記述する

/tests スラッシュ コマンドを使用して、Copilot に、アクティブなファイルまたは選択したコードのテストを記述するように依頼します。 次に例を示します。

  • /tests
  • /tests using the Jest framework
  • /tests ensure the function rejects an empty list

スラッシュ コマンドは /tests 、既存のコードのテストを記述します。 コードを書き込む前にテストを記述する (テスト駆動開発) 場合は、/tests コマンドを省略します。 次に例を示します。

  • Add tests for a JavaScript function that should sum a list of integers