OpenClaw
11·4 分钟阅读·免费

Skills 技能系统

Skills 技能系统

Skills 是 OpenClaw 的可安装扩展包,让 Agent 具备预定义的专业能力。


1. 从零写一个自定义 Skill

以「SEO 文章摘要生成器」为例,完整演示从设计到测试的全过程。

第一步:确定 Skill 需要哪些输入

参数类型说明
urlstring文章 URL(可选)
contentstring文章内容(可选,和 url 二选一)
langstring输出语言,默认 zh

第二步:创建 YAML 文件

yaml
# ~/.openclaw/skills/seo-summary.yaml
name: "seo-summary"
version: "1.0.0"
description: "生成 SEO 优化的文章摘要(meta description)"
timeout: 60
parameters:
- name: "content"
type: "string"
required: true
description: "文章正文内容"
- name: "lang"
type: "string"
required: false
default: "zh"
enum: ["zh", "en"]
prompt_template: |
请为以下文章生成一段 SEO 摘要(meta description):
 
文章内容:
{{content}}
 
要求:
- 语言:{{lang}}
- 长度:120-160 个字符
- 包含文章核心关键词
- 吸引用户点击,不要标题党
- 只输出摘要内容,不要任何解释
 
model:
prefer: "anthropic/claude-sonnet-4-5"
fallback: "deepseek/deepseek-chat"

第三步:加载并测试

bash
# 放入 skills 目录后重启
openclaw gateway restart
 
# 验证语法
openclaw skills validate seo-summary
 
# 手动测试(不经过 Agent)
openclaw skills test seo-summary \
--content "OpenClaw 是一个开源的 AI Agent 框架,支持 Telegram、飞书等多种消息渠道..." \
--lang "zh"

第四步:在对话里使用

bash
用 seo-summary 为这篇文章生成摘要:[粘贴文章内容]

2. Skill 定义完整格式参考

yaml
name: "translator"
version: "1.0.0"
description: "多语言翻译技能"
timeout: 60 # 超时秒数(默认 60)
parameters:
- name: "text"
type: "string"
required: true
description: "待翻译的文本"
- name: "target_lang"
type: "string"
required: true
enum: ["en", "zh", "ja", "ko"]
- name: "style"
type: "string"
required: false
default: "formal"
enum: ["formal", "casual"]
prompt_template: |
请将以下文本翻译成 {{target_lang}}(风格:{{style}}):
{{text}}
要求:保持原文语气,专业术语准确,符合目标语言习惯
model:
prefer: "anthropic/claude-sonnet-4-5"
fallback: "deepseek/deepseek-chat"

将 YAML 文件放到 ~/.openclaw/skills/ 后重启网关即可加载。


3. 启用内置 Skills

openclaw.json 里启用内置技能(注意是 JSON 格式):

json
{
"skills": {
"builtin": {
"code_review": { "enabled": true },
"data_analysis": { "enabled": true },
"text_summarization": { "enabled": true },
"web_search": {
"enabled": true,
"config": { "engine": "google" }
},
"translate": { "enabled": true },
"image_describe": { "enabled": true }
}
}
}

4. 安装社区 Skills

bash
# 浏览可用 Skills
openclaw skills list --remote
 
# 安装
openclaw skills install wechat-publisher
openclaw skills install competitor-watch
 
# 查看已安装
openclaw skills list
 
# 卸载
openclaw skills uninstall wechat-publisher

5. 常用内置技能一览

Skill功能
code_review代码质量审查
data_analysis数据分析与计算
text_summarization长文内容摘要
web_search调用搜索引擎
translate多语言翻译
image_describe图片内容识别

6. Skill 组合:工作流

将多个 Skill 组合成多步工作流:

yaml
# skills/blog-pipeline.yaml
name: "blog-pipeline"
description: "博客文章全流程:选题 -> 大纲 -> 成文 -> SEO"
steps:
- skill: "outline_generator"
input:
topic: "{{user_topic}}"
- skill: "content_writer"
input:
outline: "{{step.1.output}}"
- skill: "seo_optimizer"
input:
content: "{{step.2.output}}"

触发工作流:

bash
openclaw skills run blog-pipeline --topic "AI Agent 入门指南"

或直接在对话里说:

用 blog-pipeline 帮我写一篇关于 OpenClaw 安装的博客

7. 调试 Skill

Skill 安装后 Agent 不使用它

  • 确认 YAML 语法正确(用 openclaw skills validate translator
  • 确认文件已放到 ~/.openclaw/skills/ 目录
  • 重启网关:openclaw gateway restart
  • 在对话里明确指定:「用 translator skill 帮我翻译这段话」

Skill 执行报错

bash
# 查看 Skill 执行日志
openclaw logs --follow --filter skills
 
# 手动测试 Skill(不经过 Agent)
openclaw skills test translator --text "Hello world" --target_lang "zh"

模型调用超时

Skill 里默认超时是 60 秒,处理长文本时可能不够:

yaml
# 在 Skill YAML 里加超时配置
timeout: 120

Skills 让 Agent 像人类专家一样具备专业能力。社区市场持续增长,许多现成 Skill 可直接复用。