# AI 编程助手与 skill.md

GitBook 提供了一个 [skill.md](https://gitbook.com/docs/skill.md) 文件，用于教会 AI 编码助手如何正确编辑 GitBook 文档。在本地编辑 GitBook 文档时，可将其作为“项目规则”使用。

这非常适合 [Git 同步 ](/docs/documentation/zh/getting-started/git-sync.md)你在本地编辑文档，然后提交更改以更新文档站点的工作流程。该参考文件涵盖了 GitBook 的 Markdown 扩展、自定义块、配置文件以及最佳实践。

#### 下载

{% file src="/files/ed7b3e62c19a5166f9f01a187914f1eb9f434996" %}

{% hint style="info" %}
**更喜欢在 GitBook 编辑器中使用 AI 写作？**

GitBook 还提供 [GitBook Agent](/docs/documentation/zh/gitbook-agent/what-is-gitbook-agent.md) 用于 AI 辅助文档编写的功能，可直接在你的编辑器中使用。本指南适用于更喜欢使用 Claude Code 或 Cursor 等外部编码助手的团队。
{% endhint %}

### skill.md 包含什么

* 所有自定义块的完整语法参考
* 配置文件格式（`.gitbook.yaml`, `SUMMARY.md`, `.gitbook/vars.yaml`)
* Frontmatter 选项和布局控制
* 变量和表达式语法
* 用于选择合适块类型的决策表
* 常见陷阱和最佳实践

将此文件添加到你的 AI 编码助手中，可为其提供有关为 GitBook 文档创建、编辑和格式化内容所需的信息。这意味着该助手将遵循 GitBook 功能的既定框架和最佳实践。

### 通过 URL 使用 skill.md

大多数 AI 编码助手都支持项目特定指令。你可以在项目配置中引用该技能文件，只需提供技能文件的 URL，这样助手就会知道如何使用 GitBook 语法。

### 在本地使用 skill.md

你也可以下载该技能文件并将其包含到你的仓库中。首先，将 skill.md 下载到仓库根目录，然后在你的编码助手的规则文件中引用它： `“读取仓库根目录中的 skill.md，以了解 GitBook 语法和最佳实践”` .

这种方法可离线工作，并允许进行团队特定的修改。

{% hint style="warning" %}
请记得在 GitBook 添加新功能时，更新本地仓库中的最新 skill.md 文件。
{% endhint %}

### 测试 AI 生成的内容

务必始终审查并测试 AI 助手生成的内容——既要检查技术准确性，也要检查格式是否正确。

在使用基于 skill 文件训练的 AI 助手时，你应该：

* 验证任何自定义块是否能在 GitBook 中正确渲染
* 检查所有内部链接是否有效
* 确认 frontmatter 为有效的 YAML
* 测试变量是否引用了正确的作用域

{% hint style="warning" %}
**注意：** AI 助手偶尔可能会生成错误的语法，或者忘记关闭自定义块。在提交之前务必检查更改。
{% endhint %}

### GitBook Agent

更愿意直接在 GitBook 中工作？ [GitBook Agent](/docs/documentation/zh/gitbook-agent/what-is-gitbook-agent.md) 为你在 GitBook 编辑器中提供 AI 辅助工作流程——无论你是否使用 Git Sync。

Agent 具备你文档的完整上下文，并且已经接受训练，知道如何以最佳方式使用 GitBook 的块和功能。Agent 可帮助你起草内容、进行更新，并在 GitBook 应用内为不同使用场景优化你的文档。

<a href="/pages/155dafccc07f944f2a09205d69e1c7ba7bea602a" class="button primary">发现 GitBook Agent</a>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.com/docs/documentation/zh/creating-content/ai-coding-assistants-and-skillmd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
