最新资讯
reddit.com OpenAI 称 Astra 仅满足 10% 安全任务标准 dev.to FreeToken:在自有 GPU 上运行前沿 MoE 模型及其内存需求 dev.to 当 AI Agent 说“完成”时,究竟完成了什么? dev.to 部署 Underdog Bark 3.0 Pro:逐字转写、自定义后端与分块设置 dev.to 为艰难对话构建 AI:五个 Agent、一条安全正则与一位盲评监督者 techcrunch.com Palo Alto Networks 洽谈以 5 亿美元收购 AI Agent 安全初创公司 Clutch theinformation.com 黄仁勋被要求就涉华间谍指控向国会作简报 www.infoq.com Edera 推出 Object Capability Bounded Authority,试图将凭证与 AI Agent 工作负载隔离 wechat 这波杀疯了!旗舰级模型不限量、1个月视频额度免费领 bloomberg.com AI 抛售蔓延至信用市场,软银领跌亚洲美元债 dev.to 如何在专用 GPU 服务器上用 OpenAI 兼容 API 部署 LLM dev.to 审计 153 份 Claude Code 与 Codex 会话记录:User-Agent 与 URL 中的邮箱泄露
多元动态
登录 注册
智能体 github.blog · @Christopher Harrison

GitHub Copilot 入门:如何让 Copilot 理解你的代码库

原文 我的收藏

GitHub 官方博客介绍四种为 Copilot 定制项目上下文的方式:在 .github/copilot-instructions.md 中定义仓库级约定,在 .github/instructions 下用 applyTo 字段创建路径级指令,把可复用流程(如测试与 lint 检查)打包为 .github/skills 下的 agent skills 并在 SKILL.md 中说明适用时机,以及使用自定义 agent 处理更大任务、通过 MCP 服务器(如 Playwright)连接外部工具与数据源。

AI推荐理由 GitHub 官方博客的实操教程,具体介绍了四种让 Copilot 理解代码库的机制:仓库级 .github/copilot-instructions.md 自定义指令、带 applyTo 字段的路径级指令文件、.github/skills 下的 agent skills(含 SKILL.md 描述触发条件与脚本)、自定义 agent 以及通过 MCP 服务器(如 Playwright)连接外部工具。信息密度高、可操作性强,对使用 Copilot 的开发者有直接参考价值;局限是属入门系列教程,无新模型或新功能发布,正文在自定义 agent 部分被截断。

72

正文

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. Start with custom instructions Suppose you ask Copilot to add a custom page size to an application. Making the change is only part of the job. The new code should also follow the patterns your team already uses. Repository custom instructions give Copilot that baseline context. Add a .github/copilot-instructions.md file to define guidance that applies across the repository, such as your preferred architecture, naming conventions, or expectations for testing and validation. You can also create path-specific instruction files inside .github/instructions. These files use an applyTo field to tell Copilot when the guidance is relevant. When Copilot works on a matching file, it can use both the repository-wide instructions and the more specific guidance. That lets you keep the broad rules in one place without forcing every file type into the same mold. Package repeatable procedures as agent skills Custom instructions are useful for standards that should shape many tasks. But some guidance only matters when Copilot is performing a particular procedure, such as running quality checks, preparing a release, or debugging a failed workflow. That’s where agent skills come in. A skill is a folder containing instructions and, optionally, scripts and other resources that Copilot can load when they’re relevant. Project-level skills can live in .github/skills, with each skill in its own subfolder. For example, a .github/skills/quality-checks folder could contain a SKILL.md file that explains: When Copilot should use the skill. Which scripts run the project’s tests and linting. What each script checks. How to troubleshoot common failures. The description in SKILL.md helps Copilot determine when the skill applies. After updating the interface, Copilot can load the quality-checks skill and follow the project’s established process for testing and linting instead of guessing which commands to run. Use a custom agent for broader, specialized work Some tasks are larger than a single procedure. An accessibility review, for example, may require Copilot to inspect components, templates, styles, and interactions across multiple files. Custom agents let you create specialized versions of Copilot for work like this. A repository-level agent profile lives in .github/agents and can define the agent’s purpose, instructions, tools, and relevant project context. Use a custom agent when a recurring type of work benefits from a dedicated role or perspective, especially when the task may span multiple files and draw on several tools or sources of context. Connect Copilot to external tools with MCP servers Instructions, skills, and agents help Copilot understand how to work within your project. MCP servers expand what it can access and do beyond the repository. MCP servers connect Copilot to external tools, data sources, and services. A documentation server can give it access to framework guidance, while a server such as Playwright can let it open and interact with your application in a browser. You can browse available MCP servers in the Copilot app or add a custom one. Once Playwright is configured, you can ask: Use the Playwright MCP server to test the functionality manually. Copilot can then use Playwright to open the application in a browser and interact with it much as you would. That gives it a way to verify not only that the code passes automated checks, but also that the updated interface behaves as expected. Choose the right type of customizations These customizations solve different problems, but they become more useful when you combine them: Custom instructions define the conventions Copilot should follow across the repository or for particular files. Agent skills package repeatable procedures that Copilot can load when they’re relevant. Custom agents provide focused expertise and guidance for broader tasks. MCP servers connect Copilot to external tools, services, and data sources, expanding what Copilot can do. Take this with you Giving Copilot useful project context starts with four questions: What project convention do I keep explaining? What multi-step procedure do I repeat? What complex task could benefit from a dedicated custom agent? What outside tool or source does Copilot need? Not sure where to begin? The community has shared ready-made instructions, skills, agents, and more through Awesome Copilot. Find one that addresses a workflow you already repeat, review what it contains, and adapt it to your repository’s tools and standards. Start small: choose one convention you keep explaining, add it to .github/copilot-instructions.md, and see how Copilot applies it to your next task. Try using the GitHub Copilot app > The post GitHub Copilot app for Beginners: How to teach Copilot about your codebase appeared first on The GitHub Blog.

来源报道 · 1 篇 · 以下链接均前往原始媒体

← 返回精选动态 原文

更多内容