{"meta":{"title":"第一个提示文件","intro":"使用这个适用于任何编程语言的简单代码解释示例，创建你的第一个 Copilot 提示文件。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/tutorials","title":"教程"},{"href":"/zh/copilot/tutorials/customization-library","title":"定制化库"},{"href":"/zh/copilot/tutorials/customization-library/prompt-files","title":"提示文件"},{"href":"/zh/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file","title":"第一个提示文件"}],"documentType":"article"},"body":"# 第一个提示文件\n\n使用这个适用于任何编程语言的简单代码解释示例，创建你的第一个 Copilot 提示文件。\n\n> \\[!NOTE]\n>\n> * Copilot 提示文件为 公共预览版，可能随时更改。 提示文件仅适用于 VS Code、Visual Studio 和 JetBrains IDE。请查看 [关于自定义GitHub Copilot 响应](/zh/copilot/concepts/prompting/response-customization#about-prompt-files)。\n> * 如需获取社区提供的有关特定语言和场景的提示文件示例，请参阅[出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/docs/README.prompts.md)仓库。\n\n## 关于自定义\n\n可以使用两类文件来自定义 GitHub Copilot 的响应：\n\n* **自定义说明**为 GitHub Copilot 在你的所有交互中的行为方式提供持续指导。 有关入门示例，请参阅[首条自定义说明](/zh/copilot/tutorials/customization-library/custom-instructions/your-first-custom-instructions)。\n* **提示文件（公共预览版）** 定义你可在需要时调用的特定任务的可重用提示。 提示文件仅适用于 VS Code、Visual Studio 和 JetBrains IDE。\n\n## 第一个提示文件\n\n从这个简单的提示文件开始，它帮助你编写清晰、规范的代码解释。\n\n### 代码解释提示\n\n```text copy\n---\nagent: 'agent'\ndescription: 'Generate a clear code explanation with examples'\n---\n\nExplain the following code in a clear, beginner-friendly way:\n\nCode to explain: ${input:code:Paste your code here}\nTarget audience: ${input:audience:Who is this explanation for? (e.g., beginners, intermediate developers, etc.)}\n\nPlease provide:\n\n* A brief overview of what the code does\n* A step-by-step breakdown of the main parts\n* Explanation of any key concepts or terminology\n* A simple example showing how it works\n* Common use cases or when you might use this approach\n\nUse clear, simple language and avoid unnecessary jargon.\n```\n\n## 测试一下\n\n1. 将上面的提示文件另存为 `explain-code.prompt.md`，并将其保存在 `.github/prompts` 文件夹中。\n\n2. 在 Visual Studio Code 中，显示 副驾驶聊天 视图，然后输入 `/explain-code`。\n\n   Copilot 将切换为代理模式（如果尚未选择此模式），并提示你输入一些代码和一个受众类型。\n\n3. 输入：\n\n   ```text copy\n   The code is `function fibonacci(n) { return n <= 1 ? n : fibonacci(n-1) + fibonacci(n-2); }`. The audience is beginners.\n   ```\n\n## 其他阅读材料\n\n* Visual Studio Code 文档中的[使用 Visual Studio Code 中的提示文件](https://code.visualstudio.com/docs/copilot/customization/prompt-files) - 有关如何创建和使用提示文件的信息\n* [关于自定义GitHub Copilot 响应](/zh/copilot/concepts/response-customization) - GitHub Copilot 中的响应自定义概述\n* [出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/docs/README.prompts.md) - 社区提供的自定义提示文件的仓库以及特定语言和场景的其他自定义内容"}