プロンプトの例
この記事では、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.
コードベースの理解と探索
プロジェクトの仕組みの理解、特定の機能の場所の特定、コードの関係性の調査には、#codebaseとともにAskエージェントを使用してください。
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?
コードの生成と編集
複数ファイルの作成にはAgentを、特定の場所へのピンポイントな編集にはインラインチャット(⌘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
テストと品質保証
テストの生成や、失敗したテストの修正にはAgentを使用してください。
Add unit tests for the user service.
Fix the failing tests #testFailure
デバッグと問題の修正
ファイル横断的な問題の修正にはAgentを、まずは根本原因を理解したい場合にはAskを使用してください。
Fix the issues in #problems
Why is this function returning undefined?
ソース管理の利用
保留中の変更を扱ったり、リリースドキュメントを生成したりするにはチャットを活用しましょう。
Summarize the #changes
Generate release notes based on the #changes
外部リソースの利用
Web上のコンテンツを参照するには#fetchを使用するか、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の作成、編集、操作にはAgentを使用してください。
/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 クックブック