跳转到主要内容
在你的存储库中创建一个 AGENTS.md 文件来自定义 Agent 的行为(Agents.md 也同样有效)。Agent 会读取此文件并遵循你提供的所有指令。 Agent 会在两个位置搜索 AGENTS.md 文件。它会先检查文档目录,然后检查存储库根目录。如果这两个位置都有 AGENTS.md 文件,Agent 将使用文档目录中的那个。 添加你希望 Agent 遵循的任何指令。Agent 会将这些指令追加到它的 system prompt(系统提示词)中,因此这些指令会应用于所有任务,无论你是在控制台中、在 Slack 上,还是通过 API 使用 Agent。

在 AGENTS.md 中应包含的内容

可以考虑添加以下说明:
  • 风格偏好:与你的文档相关的文风、语气、格式和术语。
  • 代码规范:在示例中使用的编程语言、框架和编码约定。
  • 内容要求:针对不同类型页面应包含哪些部分或信息。
  • 项目背景:与你的产品、架构或用户群体相关的具体细节,用于制定文档相关决策。

AGENTS.md 文件示例

AGENTS.md
# Documentation agent instructions

## Code examples
- Use TypeScript for all code examples. Our users are primarily TypeScript developers.
- Always include error handling in API call examples.
- Show both success and error response examples for all endpoints.
- Include import statements at the top of code examples.

## API documentation standards
- Every endpoint must document: authentication requirements, rate limits, and common error codes.
- Use real-world parameter values in examples (not foo/bar placeholders).
- Include a complete request/response cycle for each endpoint.

## Style and formatting
- Write for developers with 2-5 years of experience. Don't oversimplify, but explain non-obvious concepts.
- Use active voice and second person ("you").
- Date format: ISO 8601 (YYYY-MM-DD).
- When referencing UI elements, use bold: **Settings** button.

## What to include
- Add prerequisite sections to guides when users need API keys, environment setup, or dependencies.
- Include "Next steps" sections linking to related documentation.
- Add troubleshooting sections for common issues we see in support tickets.