注意
智能体技能适用于 Copilot 编码智能体、GitHub Copilot 命令行界面 和 Visual Studio Code 预览版中的智能体模式。 VS Code 稳定版即将支持。
智能体技能是指令、脚本和资源的文件夹,Copilot 可在相关时加载这些文件夹,以提高其在专用任务中的性能。 有关详细信息,请参阅“关于代理技能”。
创建和添加技能
要创建代理技能,你需要编写一个SKILL.md文件,并可选择其他资源,例如补充的 Markdown 文件或脚本,这些资源可以在SKILL.md说明中引用。
若要添加技能,你可以将 SKILL.md 文件和任何附属资源保存到某个位置,Copilot 知道要到此位置查找技能。 这可以位于存储库中,也可以位于主目录中。
-
创建一个
skills目录来存储技能,以及将来可能需要创建的任何其他目录。对于特定于单个存储库的项目技能,请将技能存储在
.github/skills或.claude/skills下方。对于跨项目共享的个人技能,将你的技能存储在
~/.copilot/skills或~/.claude/skills下面。 -
为新技能创建子目录。 每个技能都应有自己的目录(例如
.github/skills/webapp-testing)。技能子目录名称应为小写,对空格使用连字符。
-
在技能子目录中,创建包含
SKILL.md技能说明的文件。重要
技能文件必须命名
SKILL.md。`SKILL.md` 文件是带有 YAML frontmatter 的 Markdown 文件。 在最简单的形式中,它们包括:- YAML 前页
*
名称 (必需):技能的唯一标识符。 这必须是小写的,对空格使用连字符。 通常,这与技能目录的名称匹配。
-
**描述**(必需):该技能的功能以及 Copilot 应何时使用它的说明。 -
**许可证** (可选):适用于此技能的许可证的说明。
-
- Markdown 正文,包含 Copilot 应遵循的指令、示例和指南。
- YAML 前页
*
名称 (必需):技能的唯一标识符。 这必须是小写的,对空格使用连字符。 通常,这与技能目录的名称匹配。
-
(可选)将脚本、示例或其他资源添加到技能的目录中。
例如,如果要编写用于在不同格式之间转换图像的技能,则可以包含用于将 SVG 图像转换为 PNG 的脚本。 技能说明应告诉 Copilot 何时以及如何使用这些资源。
示例 SKILL.md 文件
对于 项目技能,此文件将位于 .github/skills/github-actions-failure-debugging 存储库的目录中。
对于 个人技能,此文件将位于目录中 ~/.copilot/skills/github-actions-failure-debugging 。
--- name: github-actions-failure-debugging description: Guide for debugging failing GitHub Actions workflows. Use this when asked to debug failing GitHub Actions workflows. --- To debug failing GitHub Actions workflows in a pull request, follow this process, using tools provided from the GitHub MCP Server: 1. Use the `list_workflow_runs` tool to look up recent workflow runs for the pull request and their status 2. Use the `summarize_job_log_failures` tool to get an AI summary of the logs for failed jobs, to understand what went wrong without filling your context windows with thousands of lines of logs 3. If you still need more information, use the `get_job_logs` or `get_workflow_run_logs` tool to get the full, detailed failure logs 4. Try to reproduce the failure yourself in your own environment. 5. Fix the failing build. If you were able to reproduce the failure yourself, make sure it is fixed before committing your changes.
---
name: github-actions-failure-debugging
description: Guide for debugging failing GitHub Actions workflows. Use this when asked to debug failing GitHub Actions workflows.
---
To debug failing GitHub Actions workflows in a pull request, follow this process, using tools provided from the GitHub MCP Server:
1. Use the `list_workflow_runs` tool to look up recent workflow runs for the pull request and their status
2. Use the `summarize_job_log_failures` tool to get an AI summary of the logs for failed jobs, to understand what went wrong without filling your context windows with thousands of lines of logs
3. If you still need more information, use the `get_job_logs` or `get_workflow_run_logs` tool to get the full, detailed failure logs
4. Try to reproduce the failure yourself in your own environment.
5. Fix the failing build. If you were able to reproduce the failure yourself, make sure it is fixed before committing your changes.
Copilot 如何使用智能体技能
执行任务时,Copilot 将根据您的提示和技能描述决定何时使用您的技能。
当 Copilot 选择使用某项技能时,SKILL.md 文件将注入智能体的上下文中,使智能体能够访问你的指令。 然后,它可以按照这些说明执行操作,并使用你在技能目录中包含的任何脚本或示例。
技能与自定义指令的对比
你可以同时使用技能和自定义指令,教 Copilot 如何在你的存储库中工作以及如何执行特定任务。
我们建议将自定义指令用作几乎与每个任务相关的简单指令(例如有关存储库编码标准的信息),将技能用于 Copilot 仅在相关时才应访问的更详细指令。
若要了解有关存储库自定义说明的详细信息,请参阅 为 GitHub Copilot 添加存储库自定义说明。