プロンプトの例
この記事では、Visual Studio Codeのチャット機能について、さまざまなシナリオやエージェントにおけるプロンプト例を紹介します。これらの例を参考に、自身の開発タスクに合わせて効果的なプロンプトを作成してください。
VS Codeでのチャットを初めて利用する場合は、チャットの開始方法を確認するか、プロンプト作成のベストプラクティスをご覧ください。
一般的なコーディングおよび技術に関する質問
Askエージェントを使用して、コーディングの概念、技術トピック、一般的なプログラミングに関する質問に素早く回答を得られます。
What is a linked list?
Provide 3 ways to implement a search feature in React.
Explain the difference between async/await and promises.
コードベースの理解と探索
Askエージェントと#codebaseを組み合わせて使用すると、プロジェクトの仕組みを理解したり、特定の機能を特定したり、コードの関係性を探索したりできます。
Explain how authentication works in #codebase
Where is the database connection string configured? #codebase
How do I build this #codebase?
Which testing framework is used for #calculator.test.js?
コードの生成と編集
複数ファイルの作成にはエージェントを使用し、ピンポイントの編集にはインラインチャット(⌘I (Windows, Linux Ctrl+I))を使用してください。
Add a login button and style it based on #styles.css
Create a meal-planning web app using React and Node.js
Refactor this code to use async/await
テストと品質保証
エージェントを使用して、テストの生成や失敗したテストの修正を行います。
Add unit tests for the user service.
Fix the failing tests #testFailure
デバッグと問題の修正
ファイル間での問題修正にはエージェントを使用し、根本原因を理解するためにはAskを使用してください。
Fix the issues in #problems
Why is this function returning undefined?
ソース管理の操作
チャットを使用して、保留中の変更を処理したり、リリースドキュメントを生成したりできます。
Summarize the #changes
Generate release notes based on the #changes
外部リソースの活用
#fetchを使用してWeb上のコンテンツを参照するか、GitHub MCPサーバーを使用して公開GitHubリポジトリ内のコード例を検索できます。
How do I use the 'useState' hook in react 18? #fetch https://18.react.dev/reference/react/useState#usage
Build an API endpoint to fetch address info, use the template from GitHub repo contoso/api-templates
What are the top #extensions for this workspace?
ターミナルおよびコマンドラインタスク
ターミナルインラインチャットを使用して、シェルコマンドやターミナル操作に関するヘルプを得られます。
How do I install npm packages?
List the top 5 largest files in the src directory
undo the last git commit
Jupyter Notebookの操作
エージェントを使用して、Jupyter Notebookの作成、編集、操作を行います。
/newNotebook use pandas and seaborn to read and visualize the titanic dataset. Show key information from the dataset.
Create a notebook to read data from #housing.csv and plot the distribution of prices
Make sure the data is cleaned before visualizing and processing it
Show the correlation between different features in the dataset
マルチターン会話の例
チャットでは、同じセッション内でのフォローアッププロンプトをサポートしています。マルチターン会話を使用して、結果を反復し、AIの出力を調整してください。
最初のプロンプト
Create a REST API with Express.js that has endpoints for users and products
フォローアッププロンプト
Add input validation and error handling to both endpoints
Now add unit tests for the validation logic
以前の応答を基にすることで、AIは以前の手順からのコンテキストを維持し、より一貫性のあるコードを生成します。
効果的なプロンプトを作成するためのヒント
- 具体的に記述する: 達成したいこと、使用する技術、期待される出力形式などの詳細を含めてください。
- コンテキストを追加する: #-メンションを使用して、ファイル、シンボル、または
#codebase、#changes、#problemsといったコンテキスト変数を参照してください。 - 反復する: 単純なプロンプトから開始し、応答に基づいて調整します。フォローアップの質問をして、結果を向上させてください。
- 複雑なタスクを分割する: すべてを一度に要求するのではなく、大きなタスクを小さく管理しやすい手順に分割してください。
プロンプト作成のベストプラクティスや、プロンプトへのコンテキストの追加について詳しく学びましょう。
関連リソース
- チャットの概要
- チャットプロンプトへのコンテキストの追加
- インラインチャット
- GitHubドキュメントのCopilot Chat クックブック