Skill 开发指南
Skill 是 Agent 系统的扩展包,由提示词 + 工具脚本 + 参考资料组合而成。通过 Skill,可以为 AI 注入专业领域知识和自定义工具能 力。
Skill 包结构
my-skill.zip
├── SKILL.md # 必须:元数据 + 提示词
├── scripts/ # 可选:SkillScript 工具脚本
│ ├── search.js
│ └── export.js
└── references/ # 可选:参考资料文件
├── api-docs.md
└── examples.json
ZIP 包支持根目录直接放置或一层子目录(如
my-skill/SKILL.md)。
SKILL.md 格式
SKILL.md 使用 YAML frontmatter 声明元数据,Markdown 正文作为给 AI 的提示词。
---
name: "weather-assistant"
description: "天气查询助手,支持全球城市天气查询和预报"
config:
apiKey:
title: "OpenWeather API Key"
type: "text"
secret: true
required: true
unit:
title: "温度单位"
type: "select"
values: ["celsius", "fahrenheit"]
default: "celsius"
detailed:
title: "详细模式"
type: "switch"
default: false
maxDays:
title: "预报天数"
type: "number"
default: 7
---
# 天气查询助手
你可以使用以下工具查询天气信息:
## 工具说明
- **get_weather**: 查询指定城市的当前天气和未来预报
- 参数 `city` 为城市名称(支持中英文)
- 参数 `days` 为预报天数
## 使用规则
1. 用户询问天气时,先确认城市名称
2. 默认返回当前天气 + 3 天预报
3. 温度根据配置的单位显示
元数据字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | Skill 唯一标识名(建议英文 kebab-case) |
description | string | 是 | 简短描述(显示在列表中) |
config | object | 否 | 配置字段定义 |
配置字段类型
| type | 说明 | 特有属性 |
|---|---|---|
text | 文本输入框 | secret: 是否遮盖显示 |
number | 数字输入框 | — |
select | 下拉选择 | values: 选项列表(string[]) |
switch | 开关 | — |
通用属性:
| 属性 | 类型 | 说明 |
|---|---|---|
title | string | 显示标题 |
required | boolean | 是否必填 |
default | unknown | 默认值 |
secret | boolean | 是否为敏感信息 |
用户在管理页面的 Skill 设置中填写配置值。
提示词正文
Markdown 正文部分会作为 AI 的系统提示词注入。编写建议:
- 描述 Skill 提供的工具及其用途
- 说明工具参数的含义和使用规则
- 给出典型使用场景和注意事项
- 如果有参考资料,说明如何查阅
SkillScript 工具脚本
SkillScript 是可被 AI 调用的工具脚本。每个 SkillScript 文件会被注册为一个 LLM tool。
元数据格式
// ==SkillScript==
// @name get_weather
// @description 查询指定城市的天气信息
// @param city string [required] 城市名称,支持中英文
// @param days number 预报天数,默认3天
// @param format string [json,text] 输出格式
// @grant CAT.agent.opfs
// @require https://cdn.example.com/utils.js
// @timeout 60
// ==SkillScript==
元数据字段
| 标签 | 说明 | 示例 |
|---|---|---|
@name | 工具名称(AI 调用时使用) | get_weather |
@description | 工具描述(AI 据此判断何时调用) | 查询城市天气 |
@param | 参数定义(可多个) | 见下方 |
@grant | 需要的 GM API 权限 | CAT.agent.opfs |
@require | 外部库 URL(会被缓存加载) | https://cdn.example.com/lib.js |
@timeout | 执行超时秒数 | 60(默认 300) |