# 创建自定义自动化 (/zh/automations/create)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 1079 · updated: 2026-07-31 -->
Related: [预定义自动化](/zh/automations/reference.md), [管理自动化](/zh/automations/manage.md), [用于 agent 和自动化的集成](/zh/automations/integrations.md), [折叠面板](/zh/components/accordions.md)

自定义自动化使用你编写的指令，按计划、在仓库推送时或在已连接的集成事件发生时运行 agent。当[预定义自动化](/zh/automations/reference)无法覆盖你需要的行为，或者你希望将自己的提示词与特定的上下文仓库和集成组合在一起时，使用自定义自动化。有关所有自动化共享的触发器、更新模式和配置选项的概述，请参见[自动化](/zh/automations)。

<div id="prerequisites">
  ## 前置条件 [#前置条件]
</div>

* 一个已连接到 GitHub 或 GitLab 仓库的 Mintlify 项目
* 对于 GitHub：在你计划用于自动化的每个仓库上都安装 [Mintlify GitHub 应用](/zh/deploy/github)
* 对于 GitLab：已连接的 GitLab 账户（请参见下方[GitLab 设置](#gitlab-setup)）

<div id="create-a-custom-automation">
  ## 创建自定义自动化 [#创建自定义自动化]
</div>

<Note>
  agent 运行在受限互联网访问的隔离沙箱中。它无法在运行时安装额外的包或工具。引用不可用工具的提示词可能产生意外结果或失败。
</Note>

1. 在控制台中打开 [Automations](https://app.mintlify.com/products/automations) 页面。
2. 点击 **Create a custom automation**。
3. 配置自动化名称、触发器、指令、上下文仓库、集成和更新模式。有关各字段的详细说明，请参见[配置](/zh/automations/manage#configurations)。
4. 点击 **Create automation**。

<Tip>
  你也可以让 [Slack 中的 agent](/zh/agent/slack#manage-automations) 为你创建自动化，只需描述你希望该自动化执行的操作。
</Tip>

<div id="write-effective-instructions">
  ## 撰写有效的指令 [#撰写有效的指令]
</div>

有效的自动化指令聚焦于单一任务，并定义清晰、可验证的结果。由于 agent 是非确定性的，自动化结果会有所差异，但格式良好的指令能产生更一致的结果。

* **描述结果。** 告诉 agent 一次成功的运行应该是什么样的。
* **撰写流程。** 给 agent 一份按步骤执行的指南。
* **保持范围窄。** 将复杂任务拆分到多个自动化中，而不是合并到一个提示词里。

更多示例和模式请参见[使用自动化](/zh/guides/use-automations)。

<Tip>
  审查你自定义自动化的输出，以确认它们按预期运行。更新你的指令以改进结果。
</Tip>

## GitLab 设置 [#gitlab-设置]

要在自动化中使用 GitLab 仓库，请通过 [GitLab OAuth](https://app.mintlify.com/settings/organization/gitlab-oauth) 设置页面连接每个项目。请连接自动化涉及的所有仓库——你的文档仓库以及任何触发或上下文仓库。你必须在每个项目中至少具有 Maintainer 角色。

<Note>
  自动化需要付费的 GitLab 套餐。代理使用短期项目访问令牌来访问仓库，GitLab 的 Free 套餐不支持此功能。
</Note>

<div id="delete-a-custom-automation">
  ## 删除自定义自动化 [#删除自定义自动化]
</div>

删除自动化是永久性的，会移除其配置和运行历史。

1. 在控制台中打开 [Automations](https://app.mintlify.com/products/automations) 页面。
2. 点击自动化旁边的 <Icon icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M21.3175 7.14139L20.8239 6.28479C20.4506 5.63696 20.264 5.31305 19.9464 5.18388C19.6288 5.05472 19.2696 5.15664 18.5513 5.36048L17.3311 5.70418C16.8725 5.80994 16.3913 5.74994 15.9726 5.53479L15.6357 5.34042C15.2766 5.11043 15.0004 4.77133 14.8475 4.37274L14.5136 3.37536C14.294 2.71534 14.1842 2.38533 13.9228 2.19657C13.6615 2.00781 13.3143 2.00781 12.6199 2.00781H11.5051C10.8108 2.00781 10.4636 2.00781 10.2022 2.19657C9.94085 2.38533 9.83106 2.71534 9.61149 3.37536L9.27753 4.37274C9.12465 4.77133 8.84845 5.11043 8.48937 5.34042L8.15249 5.53479C7.73374 5.74994 7.25259 5.80994 6.79398 5.70418L5.57375 5.36048C4.85541 5.15664 4.49625 5.05472 4.17867 5.18388C3.86109 5.31305 3.67445 5.63696 3.30115 6.28479L2.80757 7.14139C2.45766 7.74864 2.2827 8.05227 2.31666 8.37549C2.35061 8.69871 2.58483 8.95918 3.05326 9.48012L4.0843 10.6328C4.3363 10.9518 4.51521 11.5078 4.51521 12.0077C4.51521 12.5078 4.33636 13.0636 4.08433 13.3827L3.05326 14.5354C2.58483 15.0564 2.35062 15.3168 2.31666 15.6401C2.2827 15.9633 2.45766 16.2669 2.80757 16.8741L3.30114 17.7307C3.67443 18.3785 3.86109 18.7025 4.17867 18.8316C4.49625 18.9608 4.85542 18.8589 5.57377 18.655L6.79394 18.3113C7.25263 18.2055 7.73387 18.2656 8.15267 18.4808L8.4895 18.6752C8.84851 18.9052 9.12464 19.2442 9.2775 19.6428L9.61149 20.6403C9.83106 21.3003 9.94085 21.6303 10.2022 21.8191C10.4636 22.0078 10.8108 22.0078 11.5051 22.0078H12.6199C13.3143 22.0078 13.6615 22.0078 13.9228 21.8191C14.1842 21.6303 14.294 21.3003 14.5136 20.6403L14.8476 19.6428C15.0004 19.2442 15.2765 18.9052 15.6356 18.6752L15.9724 18.4808C16.3912 18.2656 16.8724 18.2055 17.3311 18.3113L18.5513 18.655C19.2696 18.8589 19.6288 18.9608 19.9464 18.8316C20.264 18.7025 20.4506 18.3785 20.8239 17.7307L21.3175 16.8741C21.6674 16.2669 21.8423 15.9633 21.8084 15.6401C21.7744 15.3168 21.5402 15.0564 21.0718 14.5354L20.0407 13.3827C19.7887 13.0636 19.6098 12.5078 19.6098 12.0077C19.6098 11.5078 19.7888 10.9518 20.0407 10.6328L21.0718 9.48012C21.5402 8.95918 21.7744 8.69871 21.8084 8.37549C21.8423 8.05227 21.6674 7.74864 21.3175 7.14139Z&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M15.5195 12C15.5195 13.933 13.9525 15.5 12.0195 15.5C10.0865 15.5 8.51953 13.933 8.51953 12C8.51953 10.067 10.0865 8.5 12.0195 8.5C13.9525 8.5 15.5195 10.067 15.5195 12Z&#x22; stroke=&#x22;currentColor&#x22; stroke-width=&#x22;1.5&#x22;/></svg>" /> 设置按钮。
3. 点击 **Delete**。
