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 がコード ブロックを返すと、応答には、コードをコピーするか、カーソルにコードを挿入するか、新しいファイルに挿入するか、ターミナルに挿入するオプションが含まれます。
GitHub Advanced Security 機能のアラートに関して質問する
GitHub Advanced Security 機能 (code scanning、secret scanning、および Dependabot alerts) による組織内リポジトリのセキュリティアラートに関して、Copilot に尋ねることができます。 次に例を示します。
How would I fix this alert?
How many alerts do I have on this pull request?
Which line of code is this code scanning alert referencing?
What library is affected by this Dependabot alert?
新しいプロジェクトを設定する
/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