提示示例

本文提供了不同场景和代理下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.

理解和探索你的代码库

使用AskAgent#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?

代码生成与编辑

使用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工具修复文件间的问题,或者先询问以了解根本原因。

Fix the issues in #problems
Why is this function returning undefined?

使用源码管理

使用聊天处理待处理的更改并生成发布文档。

Summarize the #changes
Generate release notes based on the #changes

与外部资源合作

用途#fetch以及#githubRepo用于引用来自网络或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 #githubRepo contoso/api-templates
What are the top #extensions for this workspace?

终端和命令行任务

使用终端内联聊天来获得 shell 命令和终端作的帮助。

How do I install npm packages?
List the top 5 largest files in the src directory
undo the last git commit

使用 Jupyter 笔记本

使用 Agent 来创建、编辑并作 Jupyter 笔记本。

/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.
  • 迭代:从一个简单的提示开始,根据回复不断完善。提出后续问题以提升效果。
  • 拆解复杂任务:不要一次性要求所有任务,而是将大型任务拆分成更小、易于管理的步骤。

了解更多关于题材设计和为题目添加背景的最佳实践。