Skills 是 OpenClaw 最强大的扩展机制。一个 Skill 就是一份 SKILL.md 文件——告诉 Claude 如何完成某类特定任务。本文带你从零开发一个 Skill,并介绍 5 个实用案例。
Skill 是什么
当你发送消息给 OpenClaw,它会:
- 扫描所有已安装的 Skills
- 匹配哪个 Skill 的描述和你的消息最相关
- 自动加载对应的 SKILL.md
- 按 SKILL.md 的指令执行任务
Skills 的优势:复用、可分享、不需要重复写提示词。
Skill 文件结构
~/.openclaw/skills/my-skill/
SKILL.md # 核心文件(必须)
scripts/ # 辅助脚本
helper.py
templates/ # 模板文件
report.md
README.md # 说明(发布时需要)
SKILL.md 格式
markdown
---
name: weather
description: Get current weather and forecasts for any location
triggers:
- weather
- forecast
- temperature
version: 1.0.0
author: ClaudeEagle
---
# Weather Skill
## Instructions
When the user asks about weather:
1. Extract the location from the user message
2. Fetch weather data using: `curl wttr.in/{location}?format=j1`
3. Parse the JSON response
4. Format a clear weather report with:
- Current temperature (Celsius)
- Conditions (sunny, cloudy, rain...)
- 3-day forecast
5. Reply in the same language as the user's message
## Example Responses
User: 上海今天天气怎么样?
Response: 上海当前天气:22°C,晴天...触发机制说明
Skills 有两种触发方式:
1. 关键词触发:消息包含 triggers 列表里的词
2. 语义匹配:Claude 判断消息意图是否和 description 匹配
建议 description 写得越具体越好,减少误触发。
案例 1:代码审查 Skill
markdown
---
name: code-review
description: Review code snippets for bugs, security issues, and style problems
triggers: [review, code review, 代码审查, 看看这段代码]
---
# Code Review Skill
When user shares code for review:
1. Analyze for: bugs, security vulnerabilities, performance issues, style
2. Rate each issue: CRITICAL / HIGH / MEDIUM / LOW
3. Provide specific fix suggestions with code examples
4. End with a summary score (1-10) and top 3 improvements
Format:
## Issues Found
- [SEVERITY] Description (line X)
Fix: `code`
## Summary
Score: X/10 | Key improvements: ...案例 2:日报生成 Skill
markdown
---
name: daily-report
description: Generate a daily work summary report from git commits and notes
triggers: [日报, daily report, 今日总结, 工作报告]
---
# Daily Report Skill
When asked for a daily report:
1. Run: `git log --since='today 00:00' --author=$(git config user.email) --oneline`
2. Read any notes in ~/daily-notes/$(date +%Y-%m-%d).md if exists
3. Generate a structured report:
- Completed tasks (from git commits)
- In progress
- Blockers
- Plan for tomorrow
4. Save to ~/reports/$(date +%Y-%m-%d).md案例 3:网站监控 Skill
markdown
---
name: site-monitor
description: Check if a website or API endpoint is up and responding correctly
triggers: [check site, 网站检查, 检查接口, is it up]
---
# Site Monitor Skill
When asked to check a URL:
1. Extract URL from message
2. Run: `curl -s -o /dev/null -w '%{http_code}|%{time_total}' {url}`
3. Check status code and response time
4. Report: UP/DOWN, status code, response time in ms
5. If DOWN, suggest possible causes案例 4:自动翻译 Skill
markdown
---
name: translate
description: Translate text between Chinese and English (or other languages)
triggers: [翻译, translate, 英文翻译, 中文翻译]
---
# Translate Skill
1. Detect source language automatically
2. If source is Chinese -> translate to English
3. If source is English -> translate to Chinese
4. For technical content: preserve code blocks and technical terms
5. Provide brief explanation of key terms if needed安装 Skill
bash
# 从 ClaWHub 安装
openclaw skill install weather
openclaw skill install code-review
# 列出已安装的 Skills
openclaw skill list
# 手动安装(把 Skill 目录放到)
~/.openclaw/skills/your-skill/发布到 ClaWHub
bash
# 1. 确保 SKILL.md 有完整的 frontmatter
# 2. 添加 README.md(使用说明)
# 3. 发布
openclaw skill publish发布后在 clawhub.com 上可见,其他用户可以一键安装。
Skills vs CLAUDE.md 的区别
| Skills | CLAUDE.md | |
|---|---|---|
| 触发时机 | 按需触发(消息匹配时) | 始终加载 |
| 范围 | 可安装/分享/复用 | 项目/个人专属 |
| 最适合 | 可复用的工作流 | 项目特定规则 |
来源:OpenClaw Skills - OpenClaw 官方文档