如何撰写出色的 agents.md:来自2500多个代码库的经验教训

We recently released a new GitHub Copilot feature: custom agents defined in agents.md files. Instead of one general assistant, you can now build a team of specialists: a @docs-agent for technical writing, a @test-agent for quality assurance, and a @security-agent for security analysis. Each agents.md file acts as an agent persona, which you define with frontmatter and custom instructions.

我们最近发布了一个新的 GitHub Copilot 功能:在 agents.md 文件中定义的自定义代理。您现在可以构建一个专家团队,而不是一个通用助手:一个用于技术写作的 @docs-agent,一个用于质量保证的 @test-agent,以及一个用于安全分析的 @security-agent。每个 agents.md 文件充当代理角色,您可以通过前言和自定义指令来定义它。

agents.md is where you define all the specifics: the agent’s persona, the exact tech stack it should know, the project’s file structure, workflows, and the explicit commands it can run. It’s also where you provide code style examples and, most importantly, set clear boundaries of what not to do.

agents.md 是您定义所有细节的地方: 代理的人物角色, 它应该了解的确切技术栈, 项目的文件结构, 工作流程, 以及它可以运行的明确命令。这里也是您提供代码风格示例的地方,最重要的是,设定明确的禁止事项。

The challenge? Most agent files fail because they’re too vague. “You are a helpful coding assistant” doesn’t work. “You are a test engineer who writes tests for React components, follows these examples, and never modifies source code” does.

挑战是什么?大多数代理文件失败是因为它们太模糊。“你是一个有帮助的编码助手”不起作用。“你是一个为React组件编写测试的测试工程师,遵循这些示例,并且绝不修改源代码”则有效。

I analyzed over 2,500 agents.md files across public repos to understand how developers were using agents.md files. The analysis showed a clear pattern of what works: provide your agent a specific job or persona, exact commands to run, well-defined boundaries to follow, and clear examples of good output for the agent to follow. 

我分析了超过 2,500 个 agents.md 文件,来自公共仓库,以了解开发人员如何使用 agents.md 文件。分析显示出一个明确的模式:为你的代理提供一个特定的工作或角色、确切的命令、明确的边界以及清晰的良好输出示例供代理遵循。

Here’s what the successful ones do differently.

成功的代理与众不同之处在于。

My analysis of over 2,500 agents.md files revealed a clear divide between the ones that fail and the ones that work. The successful agents aren’t just vague helpers; they are specialists. Here’s what the best-performing ...

开通本站会员,查看完整译文。

Главная - Вики-сайт
Copyright © 2011-2025 iteam. Current version is 2.148.1. UTC+08:00, 2025-11-23 23:43
浙ICP备14020137号-1 $Гость$