注意
本文的此版本是关于 GitHub 网站上的自定义说明。 对其他环境单击上述选项卡。
关于自定义 Copilot 响应
GitHub Copilot 如果提供了足够的上下文,它可以根据个人偏好、团队的工作方式、你使用的工具或项目的具体信息来定制响应。 可以创建自定义说明,自动为你添加此信息,而不是重复将此上下文详细信息添加到提示中。 附加信息虽然不会显示,但可供Copilot使用,以便生成更高质量的响应。
注意
由于 AI 的非确定性性质,Copilot 在执行您的自定义指令时可能无法每次都以完全相同的方式操作。
自定义说明的类型
有三种主要类型的自定义指令,可用于在 GitHub 网站上自定义 Copilot 的响应。
-
** [个人说明](#about-personal-instructions)** 适用于你在GitHub网站上与Copilot对话进行的所有对话。 此类指令可用于指定个人偏好设置,例如首选语言或响应样式,确保根据个人需求定制响应。 -
** [存储库自定义说明](#about-repository-custom-instructions)** 适用于特定存储库上下文中的对话。 它们可用于定义项目特定的编码标准、框架或工具。 例如,可以指定存储库使用 TypeScript 和特定库,确保所有参与者的响应一致。 -
** [组织自定义说明](#about-organization-custom-instructions)** 适用于网站上的组织 GitHub 上下文中的对话。 此类指令非常适合强制实施组织范围的偏好设置,例如公共语言或安全准则。 组织的自定义说明只能由组织所有者为拥有Copilot业务或Copilot Enterprise订阅的组织设置。
关于个人指令
注意
在 GitHub 中使用 GitHub Copilot 聊天助手仅支持个人自定义说明。
可以通过添加个人说明来自定义 Copilot对话 在 GitHub.com 上的响应方式,这些说明仅适用于你。 在 Copilot对话 页面以及 GitHub.com 上的弹出窗口中执行此操作。 请参阅“为 GitHub Copilot 添加个人自定义说明”。
关于存储库自定义指令
可以使用以下CopilotGitHub.com三种类型的存储库自定义说明:
-
全仓库内的自定义指令,适用于在仓库上下文中发出的所有请求****。
这些是在仓库的
copilot-instructions.md目录中的.github文件中指定的。 -
特定于路径的自定义指令,适用于在匹配指定路径的文件上下文中发出的请求****。
在存储库中
.github/instructions目录中或其下的一个或多个NAME.instructions.md文件中指定这些内容。通过使用特定于路径的指令,可以避免使用仅适用于特定类型的文件或特定目录中的信息重载全仓库内的指令。
-
**代理说明**类似于适用于整个存储库的自定义指令,但目前不受所有 Copilot 功能的支持。这些在名为
AGENTS.md、CLAUDE.md或GEMINI.md的文件中指定。
有关跨不同 Copilot 功能对这些类型的存储库自定义指令的支持的详细信息,请参阅 支持不同类型的自定义说明。
有关精选的示例集合,请参阅 自定义说明。
关于组织自定义指令
注意
**支持:** 组织自定义说明目前仅支持 Copilot对话 在 GitHub.com、Copilot代码审查 在 GitHub.com 和 Copilot 云代理 在 GitHub.com。
组织所有者可以为Copilot添加指示,以便根据组织的需求和偏好定制响应。 例如,可以选择始终 Copilot 以公司选择的语言或特定样式做出响应。
在组织 Copilot 设置中定义的自定义说明适用于组织的所有成员,无论他们的 Copilot 订阅是否来自该组织。
以下是可以添加的说明的一些示例:
Always respond in Spanish.Do not generate code blocks in responses.For questions related to security, use the Security Docs Knowledge Base.
自定义指令的优先级
多种类型的自定义指令可以应用于发送到 Copilot的请求。 个人指令采用最高优先级。 接下来是存储库说明,然后组织说明将优先安排在最后。 但是,向 Copilot提供了所有相关指令集。
以下列表显示优先级的完整顺序,此列表中的指令高于列表中的较低优先级:
-
**个人指示** -
**存储库** 自定义说明:- 路径相关的任何适用文件中的说明
-
**库范围内的**`.github/copilot-instructions.md` 文件中的说明 -
**代理** 说明(例如,在 `AGENTS.md` 文件中)
-
**组织**自定义指令
尽可能避免提供冲突的指令集。 如果担心响应质量,可以暂时禁用存储库说明。 请参阅“为GitHub Copilot添加存储库自定义说明”。
添加自定义指令
自定义指令由自然语言指令组成,在后者是简短的自包含语句时最有效。 在选择是否在个人、存储库或组织级别添加说明时,请考虑要其适用的范围。
下面是每种自定义指令类型的一些常见用例和示例: * 个人说明:
- 首选单个语言:
Always respond in Portuguese. - 单个响应首选项:
Explain a single concept per line. Be clear and concise. -
**存储库自定义指令:**- 编码标准:
Use early returns whenever possible. - 框架:
Use Vue with the PrimeVue library.或Use Typescript rather than Javascript. - 代码样式首选项:
Use camel case for variable names.
- 编码标准:
-
**组织自定义指令:**- 描述如何回答某些问题:
For questions related to security, use the Security Docs Knowledge Base or advise people to consult with #security on Slack. - 仅使用一种语言的公司的首选语言:
Always respond in Portuguese. - 组织范围的首选项:
Do not generate code blocks in responses.
- 描述如何回答某些问题:
注意
- 数据变量.copilot.copilot_code-review_short %} 该系统仅读取任何自定义指令文件的前 4,000 个字符。 任何超出此限制的指令都不会影响由 Copilot代码审查 生成的评审。 此限制不适用于 Copilot对话 或 Copilot 云代理。
- 评审拉取请求时,Copilot 使用拉取请求基础分支中的自定义指令。 例如,如果你的拉取请求旨在将
my-feature-branch合并到main,Copilot 将使用main中的自定义指令。
编写有效的自定义说明
添加到自定义说明文件的说明应是简短的自包含语句,这些语句为 Copilot 提供相关信息,以帮助它在此存储库中工作。 由于这些说明随每个聊天消息一起发送,因此它们应广泛适用于你将在存储库上下文中发出的大多数请求。
用于说明文件的确切结构因项目和需求而异,但以下准则提供了一个很好的起点:
- 提供正在处理的项目的概述,包括其用途、目标和任何相关的背景信息。
- 包括存储库的文件夹结构,包括与项目相关的任何重要目录或文件。
- 指定应遵循的编码标准和约定,例如命名约定、格式规则和最佳做法。
- 包括项目中使用的任何特定工具、库或框架,以及任何相关的版本号或配置。
以下说明文件是这些实践生效的一个示例:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Folder Structure
- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
你还应考虑仓库的大小和复杂度。 以下类型的指令仅适用于只有少数参与者的小型存储库,但对于大型和多样化的存储库,这可能会导致问题****:
- 要求在提供的回答中引用外部资源
- 有关按特定风格回答的说明
- 要求始终以特定详细级别的信息来回答
例如,以下指令可能无法获得预期结果****:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
后续步骤
-
[AUTOTITLE](/copilot/customizing-copilot/adding-personal-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/customizing-copilot/adding-organization-custom-instructions-for-github-copilot)
延伸阅读
-
[AUTOTITLE](/copilot/concepts/agents/copilot-memory) -
[AUTOTITLE](/copilot/reference/customization-cheat-sheet)
注意
本文的这个版本涉及 VS Code 的自定义指令和提示文件。 对其他环境单击上述选项卡。
关于自定义 Copilot 响应
GitHub Copilot 如果提供了足够的上下文来执行此操作,则可以提供根据团队工作方式、你使用的工具或项目细节而定制的响应。 可以在存储库中创建自动为你添加此信息的文件,而不是重复将此上下文详细信息添加到提示中。
有两种类型的文件可以在VS Code中用于向Copilot提供上下文和说明。
-
**存储库自定义说明** 允许您在存储库的上下文中指定需要考虑的说明和首选项 Copilot 。 -
**提示文件**(公共预览版),使你可以将常用的提示指令和相关上下文保存在 Markdown 文件 (`*.prompt.md`) 中,以便在聊天提示中重复使用。 提示文件仅适用于 VS Code、Visual Studio 和 JetBrains IDE。
虽然自定义说明有助于将代码库范围的上下文添加到每个 AI 工作流,但提示文件则使你能够向特定聊天交互添加说明。
注意
由于 AI 的非确定性性质,Copilot 在执行您的自定义指令时可能无法每次都以完全相同的方式操作。
关于存储库自定义指令
可以使用以下三种类型的存储库自定义指令 VS Code:
-
全仓库内的自定义指令,适用于在仓库上下文中发出的所有请求****。
这些是在仓库的
copilot-instructions.md目录中的.github文件中指定的。 -
特定于路径的自定义指令,适用于在匹配指定路径的文件上下文中发出的请求****。
在存储库中
.github/instructions目录中或其下的一个或多个NAME.instructions.md文件中指定这些内容。通过使用特定于路径的指令,可以避免使用仅适用于特定类型的文件或特定目录中的信息重载全仓库内的指令。
-
**代理说明**类似于适用于整个存储库的自定义指令,但目前不受所有 Copilot 功能的支持。这些在名为
AGENTS.md、CLAUDE.md或GEMINI.md的文件中指定。
有关跨不同 Copilot 功能对这些类型的存储库自定义指令的支持的详细信息,请参阅 支持不同类型的自定义说明。
有关精选的示例集合,请参阅 自定义说明。
关于提示文件
注意
提示文件是 公共预览版 且可能被更改。
通过提示文件,你可以使用额外的上下文生成和共享可重用的提示说明。 提示文件是一个存储在工作区中的 Markdown 文件,它与现有的 Copilot对话 中的写作提示格式保持一致(例如,Rewrite #file:x.ts)。 这允许混合自然语言说明、额外的上下文,甚至链接到其他提示文件作为依赖项。
常见用例包括:
-
**代码生成**。 为组件、测试或迁移创建可重用的提示(例如,React 窗体或 API 模拟)。 -
**领域专业知识**。 通过提示(例如,安全做法或合规性检查)分享专业知识。 -
**团队协作**。 记录模式和指南,并参考规范和文档。 -
**加入**。 为复杂流程或特定项目模式编写分步指南。
你在工作区中可以有多个提示文件,每个提示文件都定义一个用于不同目的的提示。
示例
以下示例演示了如何使用提示文件。
-
`New React form.prompt.md` - 包含有关使用 React 生成窗体的可重用任务的说明。Your goal is to generate a new React form component. Ask for the form name and fields if not provided. Requirements for the form: - Use form design system components: [design-system/Form.md](../docs/design-system/Form.md) - Use `react-hook-form` for form state management: - Always define TypeScript types for your form data - Prefer *uncontrolled* components using register - Use `defaultValues` to prevent unnecessary rerenders - Use `yup` for validation: - Create reusable validation schemas in separate files - Use TypeScript types to ensure type safety - Customize UX-friendly validation rules -
`API security review.prompt.md` - 包含有关 REST API 安全做法的可重用信息,这些信息可用于进行 REST API 的安全评审。Secure REST API review: - Ensure all endpoints are protected by authentication and authorization - Validate all user inputs and sanitize data - Implement rate limiting and throttling - Implement logging and monitoring for security events …
有关如何启用、创建和使用提示文件的信息,请参阅 为GitHub Copilot添加存储库自定义说明。
编写有效的自定义说明
添加到自定义说明文件的说明应是简短的自包含语句,这些语句为 Copilot 提供相关信息,以帮助它在此存储库中工作。 由于这些说明随每个聊天消息一起发送,因此它们应广泛适用于你将在存储库上下文中发出的大多数请求。
用于说明文件的确切结构因项目和需求而异,但以下准则提供了一个很好的起点:
- 提供正在处理的项目的概述,包括其用途、目标和任何相关的背景信息。
- 包括存储库的文件夹结构,包括与项目相关的任何重要目录或文件。
- 指定应遵循的编码标准和约定,例如命名约定、格式规则和最佳做法。
- 包括项目中使用的任何特定工具、库或框架,以及任何相关的版本号或配置。
以下说明文件是这些实践生效的一个示例:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Folder Structure
- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
你还应考虑仓库的大小和复杂度。 以下类型的指令仅适用于只有少数参与者的小型存储库,但对于大型和多样化的存储库,这可能会导致问题****:
- 要求在提供的回答中引用外部资源
- 有关按特定风格回答的说明
- 要求始终以特定详细级别的信息来回答
例如,以下指令可能无法获得预期结果****:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
后续步骤
-
[AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/tutorials/use-custom-instructions) -
[AUTOTITLE](/copilot/reference/customization-cheat-sheet)
注意
此版本的文章是关于Visual Studio中的自定义说明和提示文件。 对其他环境单击上述选项卡。
关于自定义 Copilot 响应
GitHub Copilot 如果提供了足够的上下文来执行此操作,则可以提供根据团队工作方式、你使用的工具或项目细节而定制的响应。 可以在存储库中创建自动为你添加此信息的文件,而不是重复将此上下文详细信息添加到提示中。
有两种类型的文件可用于在Visual Studio中为Copilot提供上下文和说明。
-
**存储库自定义说明** 允许您指定在存储库上下文中工作时要考虑的说明和首选项 Copilot 。 -
**提示文件** 允许你在 Markdown 文件中保存常见的提示说明和相关上下文,`*.prompt.md`然后你可以在聊天提示中重复使用这些说明。 提示文件仅适用于 VS Code、Visual Studio 和 JetBrains IDE。
虽然自定义说明有助于将代码库范围的上下文添加到每个 AI 工作流,但提示文件则使你能够向特定聊天交互添加说明。
注意
由于 AI 的非确定性性质,Copilot 在执行您的自定义指令时可能无法每次都以完全相同的方式操作。
关于存储库自定义指令
可以使用以下两种类型的存储库自定义说明 Visual Studio:
-
**全仓库内的自定义指令**,适用于在仓库上下文中发出的所有请求。这些在存储库的
copilot-instructions.md目录中的.github文件中指定。 -
**特定于路径的自定义指令**,适用于在匹配指定路径的文件上下文中发出的请求。这些值在存储库中
NAME.instructions.md目录内或其下的一个或多个.github/instructions文件中指定。通过使用特定于路径的指令,可以避免使用仅适用于特定类型的文件或特定目录中的信息重载全仓库内的指令。
有关跨不同 Copilot 功能的每种存储库自定义说明的支持的详细信息,请参阅 支持不同类型的自定义说明。
有关精选的示例集合,请参阅 自定义说明。
关于提示文件
通过提示文件,你可以使用额外的上下文生成和共享可重用的提示说明。 提示文件是一个 Markdown 文件,存储在您的工作区中,用于模仿现有的 Copilot对话 写作提示格式(例如,Rewrite #file:x.ts)。 这允许混合自然语言说明、额外的上下文,甚至链接到其他提示文件作为依赖项。
常见用例包括:
-
**代码生成**。 为组件、测试或迁移创建可重用的提示(例如,React 窗体或 API 模拟)。 -
**领域专业知识**。 通过提示(例如,安全做法或合规性检查)分享专业知识。 -
**团队协作**。 记录模式和指南,并参考规范和文档。 -
**加入**。 为复杂流程或特定项目模式编写分步指南。
你在工作区中可以有多个提示文件,每个提示文件都定义一个用于不同目的的提示。
示例
以下示例演示了如何使用提示文件。
-
`New React form.prompt.md` - 包含有关使用 React 生成窗体的可重用任务的说明。Your goal is to generate a new React form component. Ask for the form name and fields if not provided. Requirements for the form: - Use form design system components: [design-system/Form.md](../docs/design-system/Form.md) - Use `react-hook-form` for form state management: - Always define TypeScript types for your form data - Prefer *uncontrolled* components using register - Use `defaultValues` to prevent unnecessary rerenders - Use `yup` for validation: - Create reusable validation schemas in separate files - Use TypeScript types to ensure type safety - Customize UX-friendly validation rules -
`API security review.prompt.md` - 包含有关 REST API 安全做法的可重用信息,这些信息可用于进行 REST API 的安全评审。Secure REST API review: - Ensure all endpoints are protected by authentication and authorization - Validate all user inputs and sanitize data - Implement rate limiting and throttling - Implement logging and monitoring for security events …
有关如何创建和使用提示文件的信息,请参阅 为GitHub Copilot添加存储库自定义说明。
编写有效的自定义说明
添加到自定义说明文件的说明应是简短的自包含语句,这些语句为 Copilot 提供相关信息,以帮助它在此存储库中工作。 由于这些说明随每个聊天消息一起发送,因此它们应广泛适用于你将在存储库上下文中发出的大多数请求。
用于说明文件的确切结构因项目和需求而异,但以下准则提供了一个很好的起点:
- 提供正在处理的项目的概述,包括其用途、目标和任何相关的背景信息。
- 包括存储库的文件夹结构,包括与项目相关的任何重要目录或文件。
- 指定应遵循的编码标准和约定,例如命名约定、格式规则和最佳做法。
- 包括项目中使用的任何特定工具、库或框架,以及任何相关的版本号或配置。
以下说明文件是这些实践生效的一个示例:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Folder Structure
- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
你还应考虑仓库的大小和复杂度。 以下类型的指令仅适用于只有少数参与者的小型存储库,但对于大型和多样化的存储库,这可能会导致问题****:
- 要求在提供的回答中引用外部资源
- 有关按特定风格回答的说明
- 要求始终以特定详细级别的信息来回答
例如,以下指令可能无法获得预期结果****:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
后续步骤
-
[AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/reference/customization-cheat-sheet)
注意
本文的此版本介绍 JetBrains IDE 中的自定义说明和提示文件。 对其他环境单击上述选项卡。
关于自定义 Copilot 响应
GitHub Copilot 如果提供了足够的上下文来执行此操作,则可以提供根据团队工作方式、你使用的工具或项目细节而定制的响应。 可以在存储库中创建自定义说明文件,自动为你添加此信息,而不是重复将此上下文详细信息添加到提示中。
可以使用两种类型的文件在 JetBrains IDE 中为Copilot提供上下文和指令:
-
**仓库自定义指令** 允许您在仓库环境中指定需要考虑的指令和偏好配置 Copilot 。 -
**提示文件**(公共预览版),使你可以将常用的提示指令和相关上下文保存在 Markdown 文件 (`*.prompt.md`) 中,以便在聊天提示中重复使用。 提示文件仅适用于 VS Code、Visual Studio 和 JetBrains IDE。
虽然自定义说明有助于将代码库范围的上下文添加到每个 AI 工作流,但提示文件则使你能够向特定聊天交互添加说明。
注意
由于 AI 的非确定性性质,Copilot 在执行您的自定义指令时可能无法每次都以完全相同的方式操作。
关于存储库自定义指令
在 JetBrains IDE 中,存储库自定义说明由在存储库中创建的单个文件.github/copilot-instructions.md组成。 添加到文件的说明应为简短的独立语句,这些语句提供上下文或相关信息,以补充Copilot提示。
对仓库自定义指令的支持
有关各种环境中支持哪种类型的自定义说明的详细信息,请参阅 支持不同类型的自定义说明。
自定义指令的用例
自定义说明的常见用例包括:
-
**测试生成。** 创建测试生成指令,例如指定特定测试框架的使用。 -
**代码评审。** 指定查看代码的指令,例如告诉审阅者查找代码中的特定错误。 -
**提交消息生成。** 编写用于生成提交消息的指令,例如格式或要包含的信息类型。
示例
此 .github/copilot-instructions.md 文件示例包含三条针对 Copilot 的指令。
We use Bazel for managing our Java dependencies, not Maven, so when talking about Java packages, always give me instructions and code samples that use Bazel.
We always write JavaScript with double quotes and tabs for indentation, so when your responses include JavaScript code, please follow those conventions.
Our team uses Jira for tracking items of work.
有关精选的示例集合,请参阅 自定义说明。
关于提示文件
注意
提示文件 公共预览版,并且可能更改。
通过提示文件,你可以使用额外的上下文生成和共享可重用的提示说明。 提示文件是一个 Markdown 文件,仿照现有的 Copilot对话 写作提示格式(例如,Rewrite #file:x.ts),存储在工作区中。 这允许混合自然语言指令和其他上下文。
常见用例包括:
-
**代码生成**。 为组件、测试或迁移创建可重用的提示(例如,React 窗体或 API 模拟)。 -
**领域专业知识**。 通过提示(例如,安全做法或合规性检查)分享专业知识。 -
**团队协作**。 记录模式和指南,并参考规范和文档。 -
**加入**。 为复杂流程或特定项目模式编写分步指南。
你在工作区中可以有多个提示文件,每个提示文件都定义一个用于不同目的的提示。
示例
以下示例演示了如何使用提示文件。
-
`New React form.prompt.md` - 包含有关使用 React 生成窗体的可重用任务的说明。Your goal is to generate a new React form component. Ask for the form name and fields if not provided. Requirements for the form: - Use form design system components: [design-system/Form.md](../docs/design-system/Form.md) - Use `react-hook-form` for form state management: - Always define TypeScript types for your form data - Prefer *uncontrolled* components using register - Use `defaultValues` to prevent unnecessary rerenders - Use `yup` for validation: - Create reusable validation schemas in separate files - Use TypeScript types to ensure type safety - Customize UX-friendly validation rules -
`API security review.prompt.md` - 包含有关 REST API 安全做法的可重用信息,这些信息可用于进行 REST API 的安全评审。Secure REST API review: - Ensure all endpoints are protected by authentication and authorization - Validate all user inputs and sanitize data - Implement rate limiting and throttling - Implement logging and monitoring for security events …
有关精选的示例集合,请参阅 提示文件。
编写有效的自定义说明
添加到自定义说明文件的说明应是简短的自包含语句,这些语句为 Copilot 提供相关信息,以帮助它在此存储库中工作。 由于这些说明随每个聊天消息一起发送,因此它们应广泛适用于你将在存储库上下文中发出的大多数请求。
用于说明文件的确切结构因项目和需求而异,但以下准则提供了一个很好的起点:
- 提供正在处理的项目的概述,包括其用途、目标和任何相关的背景信息。
- 包括存储库的文件夹结构,包括与项目相关的任何重要目录或文件。
- 指定应遵循的编码标准和约定,例如命名约定、格式规则和最佳做法。
- 包括项目中使用的任何特定工具、库或框架,以及任何相关的版本号或配置。
以下说明文件是这些实践生效的一个示例:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Folder Structure
- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
你还应考虑仓库的大小和复杂度。 以下类型的指令仅适用于只有少数参与者的小型存储库,但对于大型和多样化的存储库,这可能会导致问题****:
- 要求在提供的回答中引用外部资源
- 有关按特定风格回答的说明
- 要求始终以特定详细级别的信息来回答
例如,以下指令可能无法获得预期结果****:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
后续步骤
-
[AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/tutorials/use-custom-instructions) -
[AUTOTITLE](/copilot/reference/customization-cheat-sheet)
注意
本文的此版本介绍 Xcode 中的自定义说明。 对其他环境单击上述选项卡。
关于自定义 Copilot 响应
GitHub Copilot 如果提供了足够的上下文来执行此操作,则可以提供根据团队工作方式、你使用的工具或项目细节而定制的响应。 可以在存储库中创建自定义说明文件,自动为你添加此信息,而不是重复将此上下文详细信息添加到提示中。 其他信息不会显示在聊天输入框中,但可用于Copilot以便它生成更高质量的回复。
注意
由于 AI 的非确定性性质,Copilot 在执行您的自定义指令时可能无法每次都以完全相同的方式操作。
关于存储库自定义指令
在 Xcode 中,存储库自定义说明由在存储库中创建的单个文件.github/copilot-instructions.md组成。 添加到文件的说明应为简短的独立语句,这些语句添加上下文或相关信息以支持Copilot提示。
对仓库自定义指令的支持
有关各种环境中支持哪种类型的自定义说明的详细信息,请参阅 支持不同类型的自定义说明。
自定义指令的用例
存储库自定义说明的常见用例包括:
-
**测试生成。** 创建测试生成指令,例如指定特定测试框架的使用。 -
**代码评审。** 指定查看代码的指令,例如告诉审阅者查找代码中的特定错误。 -
**提交消息生成。** 编写用于生成提交消息的指令,例如格式或要包含的信息类型。
示例
此 .github/copilot-instructions.md 文件示例包含三条针对 Copilot 的指令。
We use Bazel for managing our Java dependencies, not Maven, so when talking about Java packages, always give me instructions and code samples that use Bazel.
We always write JavaScript with double quotes and tabs for indentation, so when your responses include JavaScript code, please follow those conventions.
Our team uses Jira for tracking items of work.
有关精选的示例集合,请参阅 自定义说明。
编写有效的自定义说明
添加到自定义说明文件的说明应是简短的自包含语句,这些语句为 Copilot 提供相关信息,以帮助它在此存储库中工作。 由于这些说明随每个聊天消息一起发送,因此它们应广泛适用于你将在存储库上下文中发出的大多数请求。
用于说明文件的确切结构因项目和需求而异,但以下准则提供了一个很好的起点:
- 提供正在处理的项目的概述,包括其用途、目标和任何相关的背景信息。
- 包括存储库的文件夹结构,包括与项目相关的任何重要目录或文件。
- 指定应遵循的编码标准和约定,例如命名约定、格式规则和最佳做法。
- 包括项目中使用的任何特定工具、库或框架,以及任何相关的版本号或配置。
以下说明文件是这些实践生效的一个示例:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Folder Structure
- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
你还应考虑仓库的大小和复杂度。 以下类型的指令仅适用于只有少数参与者的小型存储库,但对于大型和多样化的存储库,这可能会导致问题****:
- 要求在提供的回答中引用外部资源
- 有关按特定风格回答的说明
- 要求始终以特定详细级别的信息来回答
例如,以下指令可能无法获得预期结果****:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
后续步骤
-
[AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/tutorials/use-custom-instructions) -
[AUTOTITLE](/copilot/reference/customization-cheat-sheet)
注意
本文的此版本介绍 Eclipse 中的自定义说明。 对其他环境单击上述选项卡。
如何定制化Copilot响应
GitHub Copilot 如果提供了足够的上下文来执行此操作,则可以提供根据团队工作方式、你使用的工具或项目细节而定制的响应。 可以在存储库中创建自定义说明文件,自动为你添加此信息,而不是重复将此上下文详细信息添加到提示中。 附加信息不会显示在聊天输入框中,但可供 Copilot 使用,以便生成更高质量的响应。
在 Eclipse 中,可以使用两种类型的存储库自定义指令为 Copilot 提供上下文和说明:
-
**工作区自定义指令**,适用于工作区中的所有项目,并使你能够在单个文件中指定工作区范围的说明和首选项。 -
**适用于特定项目的自定义说明**。
注意
由于 AI 的非确定性性质,Copilot 在执行您的自定义指令时可能无法每次都以完全相同的方式操作。
关于存储库自定义指令
**工作区自定义指令**,适用于工作区中的所有项目,并使你能够指定工作区范围的说明和首选项。 可以在 Eclipse 中使用自定义工作区说明来提供上下文和指令给 Copilot 。
**Project自定义说明**由在project中创建的单个文件`.github/copilot-instructions.md`组成。 添加到文件的说明应为简短的自包含语句,这些语句添加背景信息或相关信息以补充 Copilot 提示。
常见用例包括:
-
**测试生成。** 创建测试生成指令,例如指定特定测试框架的使用。 -
**代码评审。** 指定查看代码的指令,例如告诉审阅者查找代码中的特定错误。 -
**提交消息生成。** 编写用于生成提交消息的指令,例如格式或要包含的信息类型。
示例
此 .github/copilot-instructions.md 文件示例包含三条针对 Copilot 的指令。
We use Bazel for managing our Java dependencies, not Maven, so when talking about Java packages, always give me instructions and code samples that use Bazel.
We always write JavaScript with double quotes and tabs for indentation, so when your responses include JavaScript code, please follow those conventions.
Our team uses Jira for tracking items of work.
有关精选的示例集合,请参阅 自定义说明。
编写有效的自定义说明
添加到自定义说明文件的说明应是简短的自包含语句,这些语句为 Copilot 提供相关信息,以帮助它在此存储库中工作。 由于这些说明随每个聊天消息一起发送,因此它们应广泛适用于你将在存储库上下文中发出的大多数请求。
用于说明文件的确切结构因项目和需求而异,但以下准则提供了一个很好的起点:
- 提供正在处理的项目的概述,包括其用途、目标和任何相关的背景信息。
- 包括存储库的文件夹结构,包括与项目相关的任何重要目录或文件。
- 指定应遵循的编码标准和约定,例如命名约定、格式规则和最佳做法。
- 包括项目中使用的任何特定工具、库或框架,以及任何相关的版本号或配置。
以下说明文件是这些实践生效的一个示例:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Folder Structure
- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
你还应考虑仓库的大小和复杂度。 以下类型的指令仅适用于只有少数参与者的小型存储库,但对于大型和多样化的存储库,这可能会导致问题****:
- 要求在提供的回答中引用外部资源
- 有关按特定风格回答的说明
- 要求始终以特定详细级别的信息来回答
例如,以下指令可能无法获得预期结果****:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
后续步骤
-
[AUTOTITLE](/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) -
[AUTOTITLE](/copilot/tutorials/use-custom-instructions) -
[AUTOTITLE](/copilot/reference/customization-cheat-sheet)