diff --git a/docs/en/customization/skills.md b/docs/en/customization/skills.md index 2cf84553f3b..0a48afb0085 100644 --- a/docs/en/customization/skills.md +++ b/docs/en/customization/skills.md @@ -8,8 +8,29 @@ Compared to pasting the same instructions into a prompt every time, Skills offer Skill files must be placed in a [known scan directory](#skill-locations). Two file structures are supported: -- **Directory form (recommended)**: Create a subdirectory under the Skills directory, name the main file `SKILL.md`, and place scripts, reference materials, and other supporting files in the same directory. When both `/SKILL.md` and a same-named `.md` exist in the same directory, the subdirectory takes precedence. -- **Flat form**: Use a single `.md` file directly; the Skill name is taken from the filename (minus `.md`). +- **Directory form (recommended)**: Create a subdirectory under the skills directory with the main file named `SKILL.md`, and place scripts, reference material, and other supporting files alongside it. +- **Flat form**: Skip the subdirectory and drop a single `.md` file directly into the skills directory — handy for simple Skills that need no supporting files. + +Both structures register a Skill; they differ only in how the files are organized: + +```text +skills/ +├── review-pr/ # Directory form → Skill name review-pr +│ ├── SKILL.md # Main file +│ └── checklist.md # Supporting file, referenced via ${KIMI_SKILL_DIR} +└── commit.md # Flat form → Skill name commit +``` + +How the Skill name is derived: + +- Directory form: from the required frontmatter `name` field (see the table below); by convention the subdirectory carries the same name — `review-pr/SKILL.md` with `name: review-pr` registers as `review-pr`. +- Flat form: `name` may be omitted, falling back to the filename without the `.md` extension — `commit.md` registers as `commit`. The extension is stripped only from the registered Skill name; the file on disk must keep its `.md` extension to be picked up by the scanner, so don't actually create an extensionless `commit` file. +- When both `/SKILL.md` and `.md` exist in the same directory, the directory form wins and the flat file is ignored. + +Two limitations of the flat form: + +- Only `.md` files placed directly at the top level of a skills directory are recognized; loose `.md` files inside subdirectories (other than `SKILL.md`) are not treated as Skills. +- A flat Skill has no directory of its own, so `${KIMI_SKILL_DIR}` points at the skills directory itself — switch to the directory form whenever the Skill needs supporting files. ### File Format @@ -39,7 +60,7 @@ Please handle code according to the following guidelines: | Field | Description | | --- | --- | -| `name` | Skill name (case-insensitive). Required in directory-form `SKILL.md`; flat `.md` uses the filename | +| `name` | Skill name (case-insensitive). Required in directory-form `SKILL.md`; flat `.md` falls back to the filename without the `.md` extension | | `description` | One-line summary the model uses to decide when to invoke. Required in directory-form `SKILL.md`; flat `.md` falls back to the first non-empty body line (up to 240 characters) | | `type` | Skill type: `prompt` (default), `inline` (same as `prompt`), `flow` (manual invocation only). Other values are skipped | | `whenToUse` | Description of when the Skill should be triggered. Also accepts `when-to-use` and `when_to_use` | diff --git a/docs/zh/customization/skills.md b/docs/zh/customization/skills.md index a392deae79d..213dd6de849 100644 --- a/docs/zh/customization/skills.md +++ b/docs/zh/customization/skills.md @@ -8,8 +8,29 @@ Agent Skills 是 Kimi Code CLI 扩展模型能力的轻量机制。一个 Skill Skill 文件需放在[已知的扫描目录](#skill-存放位置)中。支持两种文件结构: -- **目录形式(推荐)**:在 Skills 目录下创建一个子目录,主文件命名为 `SKILL.md`,可在同目录下放置脚本、参考资料等辅助文件。同目录下同时存在 `/SKILL.md` 和同名 `.md` 时,以子目录为准。 -- **扁平形式**:直接使用单个 `.md` 文件,Skill 名称取文件名(去掉 `.md`)。 +- **目录形式(推荐)**:在 Skills 目录下创建一个子目录,主文件命名为 `SKILL.md`,可在同目录下放置脚本、参考资料等辅助文件。 +- **扁平形式**:不建子目录,把一个 `.md` 文件直接放在 Skills 目录下,适合不需要辅助文件的简单 Skill。 + +两种结构都会注册出 Skill,区别只在文件组织方式: + +```text +skills/ +├── review-pr/ # 目录形式 → Skill 名 review-pr +│ ├── SKILL.md # 主文件 +│ └── checklist.md # 辅助文件,正文用 ${KIMI_SKILL_DIR} 引用 +└── commit.md # 扁平形式 → Skill 名 commit +``` + +Skill 名的推导规则: + +- 目录形式取 frontmatter 的 `name` 字段(必填,见下文表格);惯例让子目录名与 `name` 保持一致——`review-pr/SKILL.md` 里写 `name: review-pr`,注册为 `review-pr`。 +- 扁平形式的 `name` 可省略,省略时取文件名去掉 `.md` 扩展名:`commit.md` 注册为 `commit`。注意「去掉 `.md`」只发生在注册后的 Skill 名上——磁盘上的文件必须带 `.md` 扩展名才会被扫描到,不要真的创建一个没有扩展名的 `commit` 文件。 +- 同一目录下 `/SKILL.md` 与 `.md` 同时存在时,以目录形式为准,扁平文件被忽略。 + +扁平形式还有两点限制: + +- 只有直接放在 Skills 目录顶层的 `.md` 文件会被识别;子目录里散放的 `.md`(`SKILL.md` 除外)不会被当作 Skill。 +- 扁平 Skill 没有自己的目录,`${KIMI_SKILL_DIR}` 指向 Skills 目录本身,不便携带辅助文件——需要辅助文件时请改用目录形式。 ### 文件格式 @@ -39,7 +60,7 @@ arguments: | 字段 | 说明 | | --- | --- | -| `name` | Skill 名称,大小写不敏感。目录型 `SKILL.md` 必填,扁平 `.md` 省略时取文件名 | +| `name` | Skill 名称,大小写不敏感。目录型 `SKILL.md` 必填;扁平 `.md` 省略时取文件名(不含 `.md` 扩展名) | | `description` | 一行总结,模型用它判断何时使用。目录型必填,扁平 `.md` 省略时取正文第一行非空内容(截至 240 字符) | | `type` | 类型:`prompt`(默认)、`inline`(同 `prompt`)、`flow`(仅手动调用)。其他值被跳过 | | `whenToUse` | 触发场景描述,也接受 `when-to-use`、`when_to_use` 写法 |