github star gitee star atomgit star PyPI Downloads AI 编程 AI 交流群

大家好,我是正在实战各种AI项目的程序员晚枫。

今天学习Skills技能系统,这是OpenClaw的插件机制。通过开发Skill,你可以为AI添加任意自定义能力。


什么是Skill?

Skill是OpenClaw的扩展模块,可以:

  • 添加新的工具函数
  • 集成第三方服务
  • 封装业务逻辑
  • 复用和分享功能

Skill vs 内置工具

特性内置工具Skill
来源OpenClaw自带用户开发/社区贡献
安装开箱即用需要安装
功能通用操作特定场景
更新随版本更新独立维护

Skill目录结构

1
2
3
4
5
6
7
8
9
my-skill/
├── SKILL.md # Skill说明文档
├── index.js # 主入口文件
├── package.json # 依赖配置
├── tools/ # 工具实现
│ ├── search.js
│ └── calculate.js
└── assets/ # 静态资源
└── logo.png

开发第一个Skill

步骤1:创建目录

1
2
mkdir -p ~/.openclaw/skills/my-first-skill
cd ~/.openclaw/skills/my-first-skill

步骤2:编写SKILL.md

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# My First Skill

## 描述
我的第一个OpenClaw Skill,提供天气查询功能。

## 工具

### get_weather
获取指定城市的天气信息。

参数:
- city (string): 城市名称
- date (string, optional): 日期,默认为今天

返回:
- temperature: 温度
- condition: 天气状况
- humidity: 湿度

步骤3:实现工具

创建 tools/weather.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const axios = require('axios');

async function get_weather({ city, date = 'today' }) {
const response = await axios.get(
`https://api.weather.com/v1/current?city=${encodeURIComponent(city)}`
);

return {
temperature: response.data.temp,
condition: response.data.condition,
humidity: response.data.humidity
};
}

module.exports = { get_weather };

步骤4:注册Skill

创建 index.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const { get_weather } = require('./tools/weather');

module.exports = {
name: 'my-first-skill',
version: '1.0.0',
description: '天气查询Skill',
author: 'your-name',

tools: {
get_weather: {
handler: get_weather,
description: '获取城市天气',
parameters: {
city: { type: 'string', required: true },
date: { type: 'string', required: false }
}
}
}
};

步骤5:启用Skill

1
2
3
4
5
6
{
"skills": {
"enabled": ["my-first-skill"],
"directory": "~/.openclaw/skills"
}
}

使用Skill

安装后,AI会自动识别并使用Skill中的工具:

1
2
3
4
5
6
7
8
9
10
11
12
你:北京今天天气怎么样?

AI:我来查一下北京的天气。
🔧 Using tool: get_weather (from my-first-skill)
city: 北京

📤 Result:
温度: 8°C
天气: 晴
湿度: 45%

北京今天晴天,温度8°C,湿度45%,适合出行!

分享与安装Skill

分享给他人

1
2
3
# 打包Skill
cd ~/.openclaw/skills/my-first-skill
tar czf my-first-skill.tar.gz .

安装社区Skill

1
2
3
4
5
6
7
8
9
10
11
# 从GitHub安装
openclaw skills install https://github.com/user/my-skill

# 从本地安装
openclaw skills install ./my-skill.tar.gz

# 列出已安装Skills
openclaw skills list

# 卸载Skill
openclaw skills uninstall my-skill

下节预告

下一讲学习移动端节点配对,在手机上也能够使用OpenClaw。

👉 继续阅读:第22讲-移动端节点配对


💬 加入学习交流群

Skill开发问题?加群交流:

👉 点击加入交流群


推荐:AI Python编程实战营

🎁 限时福利:送《利用Python进行数据分析》实体书

👉 点击了解详情


---## 📚 完整学习路线这是OpenClaw入门课程的第X讲。查看完整课程大纲:👉 **OpenClaw入门课程大纲**课程包含30讲,从安装部署到实战项目,带你全面掌握OpenClaw。

课程导航

上一篇: 第20讲-Webhook集成

下一篇: 第22讲-移动端节点配对**


PS:Skill系统是OpenClaw的扩展生态。开发一个好的Skill,不仅能解决自己的问题,还能帮助整个社区。


💬 联系我

平台账号/链接
微信扫码加好友
微博@程序员晚枫
知乎@程序员晚枫
抖音@程序员晚枫
小红书@程序员晚枫
B 站Python 自动化办公社区

主营业务:AI 编程培训、企业内训、技术咨询

🎓 AI 编程实战课程

想系统学习 AI 编程?程序员晚枫的 AI 编程实战课 帮你从零上手!