跳到正文
FunCoding

搜索

搜索文档、Skill 和 MCP

用 Chat 解释、修改和测试代码

围绕项目理解、代码生成、修复、测试与新项目组织提示。

先选择合适的 Chat 模式,再给出目标、相关代码和约束。Ask 用于理解和建议;需要执行编辑与命令时转到 Agent。以下英文提示保留官方用法,实际提问可以使用自己的语言。

理解项目

先选中函数或加入文件引用,再问 what sorting algorithm does this function use。跨文件问题先提供相关文件,再问 how are these files related。

VS Code 可使用 @workspace how are notifications scheduled;JetBrains 的对应项目参与者示例是 @project how are notifications scheduled。Eclipse 可以通过回形针加入多个文件。各 IDE 的具体引用方法见上下文与附件。

生成和改进代码

可以先给出明确目标,例如 write a function to sum all numbers in a list,再补充语言、参数类型或错误处理要求。对已有代码可询问:

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

这些是任务提示示例,不保证自动满足项目约束。评估返回的代码,再通过当前 IDE 提供的插入或编辑操作应用。

修复问题

当前文件包含错误时,可用 /fix 请求修复。为了让问题更明确,附上相关代码和错误信息,并说明希望保留的行为。不要仅凭生成回答判断错误已经解决;继续检查修改及实际运行结果。

生成测试

对已有代码,官方给出的常见入口是:

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

/tests 面向现有代码生成测试。如果准备先写测试再写实现,直接描述目标行为,例如 Add tests for a JavaScript function that should sum a list of integers,无需使用 /tests。

VS Code 新项目与 Notebook

/new 可以根据描述提出目录结构,例如:

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

检查建议的文件树并点击文件名预览内容,再使用回答中的创建按钮生成项目。

创建 Jupyter Notebook 的官方示例为:

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

这些命令属于该指南的 VS Code 标签页,不代表其他 IDE 都具有相同入口。

编辑器与终端问题

VS Code 中可用 @vscode 询问调试、配色和键位设置,用 @terminal 询问命令行操作。@terminal #terminalLastCommand 可用于解释最近命令及其错误。输入 /、@ 或 # 后查看界面列出的当前能力,避免照搬另一个客户端的命令集合。