Skills 是 OpenClaw 的核心扩展机制。本文教你如何从零开发一个 Skill。
什么是 Skills?
Skills 是 OpenClaw 的能力扩展包。通过 Skills,你可以:
- 让 AI 执行特定任务(如调用 API、操作文件)
- 限定 AI 的行为范围(如只做翻译、只写代码)
- 组合多个 Skills 实现复杂工作流
Skills 目录结构
~/.openclaw/workspace/skills/
└── my-skill/
├── SKILL.md # Skill 定义(必需)
├── references/ # 参考文档(可选)
└── scripts/ # 脚本文件(可选)
最简 Skill 示例
创建一个"翻译助手" Skill:
1. 创建目录
mkdir -p ~/.openclaw/workspace/skills/translator
2. 创建 SKILL.md
# Translator Skill
You are a professional translator. Your job is to translate text between languages.
## Behavior
- When user sends text, ask which language to translate to
- Provide accurate, natural translations
- Preserve formatting and structure
## Languages
Supported languages:
- Chinese (zh)
- English (en)
- Japanese (ja)
- Korean (ko)
3. 测试 Skill
重启 Gateway 后,AI 就会按照 Skill 定义的方式工作。
带工具的 Skill
更高级的 Skill 可以调用外部工具。示例:天气查询
SKILL.md
# Weather Skill
You are a weather assistant. Use the get_weather tool to check weather.
## Tools
- get_weather: Get current weather for a city
## Behavior
1. When user asks about weather, call get_weather
2. Present the result in a friendly format
工具定义(在 OpenClaw 配置中)
{
"skills": ["weather"],
"tools": {
"get_weather": {
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"city": { "type": "string" }
},
"execute": "curl -s wttr.in/{city}?format=3"
}
}
}
}
Skill 最佳实践
1. 单一职责
每个 Skill 只做一件事:
| 好的 Skill | 不好的 Skill |
|---|---|
| email-writer | super-assistant |
| code-reviewer | all-in-one |
| meeting-summarizer | do-everything |
2. 明确边界
在 SKILL.md 中清晰定义:
## What I Do
- Write professional emails
- Adjust tone based on recipient
## What I Don't Do
- Send emails (user must do this)
- Read inbox
- Manage calendar
3. 提供示例
## Examples
User: Write an email to my boss about the project delay
Assistant: [Writes professional email explaining delay]
User: 帮我写一封请假邮件
Assistant: [用中文写请假邮件]
发布你的 Skill
完成 Skill 开发后,可以:
- 自己使用:放在
skills/目录 - 分享给他人:打包发 GitHub
- 上架 ClawHub:提交到官方 Skills 市场(需要审核)
实战案例
案例:周报生成器
# Weekly Report Generator
Generate professional weekly reports from bullet points.
## Input Format
User provides:
- What was done this week (bullet points)
- Any blockers or issues
- Plans for next week
## Output Format
# Weekly Report - [Date]
## This Week
- [Formatted accomplishments]
## Blockers
- [Issues and status]
## Next Week
- [Plans]
## Tone
Professional but concise. Suitable for email to manager.
案例:代码解释器
# Code Explainer
Explain code in simple terms for beginners.
## Behavior
1. When user sends code, explain what it does
2. Break down complex parts
3. Use analogies when helpful
4. Suggest improvements
## Output Format
## What this code does
[High-level explanation]
## Line by line
[Detailed breakdown]
## Suggestions
[Optional improvements]
常见问题
Q: Skill 不生效?
确保:
- 文件名是
SKILL.md(大写) - 文件在正确的目录
- 已重启 Gateway
Q: 如何调试 Skill?
在对话中直接问 AI:
"What skills are you using?" "Read your SKILL.md file"
Q: 多个 Skill 冲突?
在配置中指定优先级:
{
"skills": ["skill-a", "skill-b"],
"skillPriority": ["skill-a"]
}
下一步
- 查看官方 Skills:clawhub.com
- 加入社区:discord.gg/clawd
- 阅读文档:docs.openclaw.ai
安装服务
如果你需要帮助配置 Skills 或安装 OpenClaw:
| 套餐 | 价格 | 包含内容 |
|---|---|---|
| 基础安装 | ¥99 | 远程安装 + 基础配置 |
| 高级配置 | ¥299 | 安装 + Telegram/Discord + 2 个 Skills |
| 企业定制 | ¥999 | 安装 + 多平台 + 5 个 Skills + 1 个月支持 |
联系方式:评论区留言或私信
相关文章: