适合初学者的 GitHub Copilot 应用程序:如何向 Copilot 教授您的代码库
了解如何将自定义指令和技能添加到存储库、使用自定义代理以及连接 MCP 服务器(例如 Playwright)。面向初学者的 GitHub Copilot 应用程序:如何向 Copilot 教授代码库一文首先出现在 GitHub 博客 上。

来自 GitHub AI 的官方动态,版本与适用范围以发布方说明为准。
GitHub AI · 查看官方发布中文机器翻译 · 原文附后
正文 · 来源原文
GitHub 高级开发者倡导者
当您使用人工智能时,上下文很重要。每个代码库都有自己的内部规则:组件如何构建、运行哪些脚本以及哪些约定适用于不同的框架和文件类型。
Copilot 可以帮助您在整个项目中进行更改,但当它也了解这些规则时效果最佳。其中大部分知识都可以存储在存储库中,因此 Copilot 可以自动获取它们,而不需要您在每次开始新任务时解释相同的标准、脚本和工作流程。
在面向初学者的 GitHub Copilot 应用程序系列的本期中,我们将介绍四种定制 Copilot 如何与您的项目配合使用的方法:
自定义指令传达了 Copilot 应遵循的约定。代理技能包可重复的程序。定制代理为更大的任务提供专业指导。模型上下文协议 (MCP) 服务器将 Copilot 连接到外部工具和数据源,扩展了它的功能。
让我们看看每个人如何工作以及他们如何一起工作。
从自定义指令开始
假设您要求 Copilot 将自定义页面大小添加到应用程序。做出改变只是工作的一部分。新代码还应该遵循您的团队已经使用的模式。
存储库自定义指令为 Copilot 提供基线上下文。添加 .github/copilot-instructions.md 文件来定义适用于整个存储库的指南,例如您的首选架构、命名约定或测试和验证的期望。
您还可以在 .github/instructions 中创建特定于路径的指令文件。这些文件使用 applyTo 字段来告诉 Copilot 指导何时相关。
当 Copilot 处理匹配文件时,它可以使用存储库范围的指令和更具体的指导。这样您就可以将广泛的规则保留在一个地方,而无需将每种文件类型强制采用同一模式。
将可重复的程序打包为代理技能
自定义指令对于塑造许多任务的标准很有用。但某些指导仅在 Copilot 执行特定过程时才重要,例如运行质量检查、准备发布或调试失败的工作流程。
这就是座席技能的用武之地。技能是一个文件夹,其中包含说明以及可选的脚本和 Copilot 可以在相关时加载的其他资源。项目级技能可以存在于 .github/skills 中,每个技能都位于其自己的子文件夹中。
例如,.github/skills/quality-checks 文件夹可能包含一个 SKILL.md 文件,该文件解释:
副驾驶何时应该使用该技能。哪些脚本运行项目的测试和 linting。每个脚本检查什么。如何排除常见故障。
SKILL.md 中的描述可帮助 Copilot 确定技能何时应用。更新界面后,Copilot 可以加载质量检查技能,并遵循项目既定的测试和 linting 流程,而不是猜测要运行哪些命令。
使用自定义代理进行更广泛的专业工作
查看英文原文
GitHub Copilot app for Beginners: How to teach Copilot about your codebase
Learn how to add custom instructions and skills to your repository, use custom agents, and connect MCP servers like Playwright. The post GitHub Copilot app for Beginners: How to teach Copilot about your codebase appeared first on The GitHub Blog .
正文 · 来源原文
Senior Developer Advocate, GitHub
Context matters when you’re working with AI. Every codebase has its own house rules: how components are structured, which scripts to run, and which conventions apply to different frameworks and file types.
Copilot can help you make changes across a project, but it works best when it knows those rules, too. Much of that knowledge can live inside the repository, so Copilot can pick it up automatically instead of requiring you to explain the same standards, scripts, and workflows every time you start a new task.
In this installment of our GitHub Copilot app for Beginners series, we’ll look at four ways to tailor how Copilot works with your project:
Custom instructions communicate the conventions Copilot should follow. Agent skills package repeatable procedures. Custom agents bring specialized guidance to larger tasks. Model Context Protocol (MCP) servers connect Copilot to external tools and data sources, expanding what it can do.
Let’s look at how each one works and how they can work together.
