# 自定义 Agent 行为 (/zh/agent/customize)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 496 · updated: 2026-07-30 -->
Related: [将 agent 添加到 Slack](/zh/agent/slack.md), [编写高效提示词](/zh/agent/effective-prompts.md), [工作流](/zh/agent/workflows.md)

在你的文档项目根目录下创建一个 `.mintlify/AGENTS.md` 文件，用来自定义 Agent 的行为（`Agents.md` 也是可接受的文件名）。

<Warning>
  将你的 `AGENTS.md` 文件放在 `.mintlify/` 目录内，而不是放在项目根目录下。如果你将文件存放在项目根目录下，你的自定义指令将通过 `/agents.md` 路径公开访问。`.mintlify/` 目录不会被公开提供服务，因此当你的 `AGENTS.md` 文件位于该目录中时，它不会被公开访问。

  如果你必须将 `AGENTS.md` 文件存放在项目根目录或其他目录中，请将其添加到你的 [`.mintignore`](/zh/organize/mintignore) 文件中，以将其从文档站点中排除。
</Warning>

添加你希望 Agent 遵循的任何指令。Agent 会将这些指令追加到它的 system prompt（系统提示词）中，因此这些指令会应用于所有任务，无论你是在控制台中、在 Slack 上，还是通过 API 使用 Agent。

<div id="what-to-include-in-agentsmd">
  ## 在 AGENTS.md 中应包含的内容 [#在-agentsmd-中应包含的内容]
</div>

可以考虑添加以下说明：

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

<div id="example-agentsmd-file">
  ## AGENTS.md 文件示例 [#agentsmd-文件示例]
</div>

```markdown title=".mintlify/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.
```
