教程

OpenClaw Skills 开发指南:从零打造你的专属 AI 工作流插件

OpenClaw Skills 完整开发教程:Skills 工作原理、SKILL.md 文件格式、触发机制(关键词/描述匹配)、脚本和资源文件组织、发布到 ClaWHub 市场,以及 5 个实用 Skill 开发案例(天气/代码审查/日报生成/数据监控/自动翻译)。

2026/3/154分钟 阅读ClaudeEagle

Skills 是 OpenClaw 最强大的扩展机制。一个 Skill 就是一份 SKILL.md 文件——告诉 Claude 如何完成某类特定任务。本文带你从零开发一个 Skill,并介绍 5 个实用案例。

Skill 是什么

当你发送消息给 OpenClaw,它会:

  1. 扫描所有已安装的 Skills
  2. 匹配哪个 Skill 的描述和你的消息最相关
  3. 自动加载对应的 SKILL.md
  4. 按 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 的区别

SkillsCLAUDE.md
触发时机按需触发(消息匹配时)始终加载
范围可安装/分享/复用项目/个人专属
最适合可复用的工作流项目特定规则

来源:OpenClaw Skills - OpenClaw 官方文档

相关文章推荐

教程OpenClaw Skills 开发完全指南:从零编写高质量 SKILL.md 自定义技能文件OpenClaw Skills 开发完整教程:SKILL.md 文件结构详解、自动触发 vs 显式触发原理、三个实战模板(GitHub 仓库管理/每日信息简报/代码健康检查)、让技能精准自动触发的描述写法,以及技能质量标准和 clawhub.ai 使用方法。2026/4/19教程OpenClaw Background Tasks 完全指南:让 AI 在后台自主执行长时间任务(2026)OpenClaw Background Tasks(后台任务)完整指南:Background Tasks 与普通对话的区别(异步执行/不阻塞渠道/可中断恢复)、通过自然语言触发后台任务(「帮我在后台处理...」)、openclaw tasks 命令行管理(list/show/cancel/logs)、任务状态跟踪与完成通知、长时间任务的最佳实践(分批处理/超时设置/错误恢复)、与 Cron Jobs 的区别和选用场景,以及实战案例(批量文件处理/代码库扫描/数据报告生成)。2026/4/2教程Claude Code Skills 自定义命令:打造你的团队专属 AI 工作流Claude Code Skills 自定义命令完整教程:Skills vs CLAUDE.md 使用场景对比、内置 Skills 速览(/batch/simplify/loop)、SKILL.md 文件格式与 Frontmatter 配置、四大实用 Skills 示例(代码审查/部署检查/功能开发/团队 OnBoarding)、传参方式、子代理执行与 Git 团队共享。2026/3/14教程Claude Code 插件开发指南:plugin.json 结构、Skills/Hooks/MCP 集成与官方市场提交Claude Code 插件开发完整指南:独立配置 vs 插件对比(命名空间/适用场景)、5 步快速创建(目录/plugin.json 清单字段/Skill/本地 --plugin-dir 测试/分享)、完整插件目录结构(.claude-plugin/commands/skills/agents/hooks/mcp/.lsp.json/settings.json)、各组件配置示例(Skills SKILL.md/LSP 服务器.lsp.json/默认 settings.json agent 键)、从独立配置迁移步骤对比表、三步调试方法,以及通过 claude.ai 和 Console 提交官方市场的方式。2026/3/8教程Claude Code 插件开发指南:从 plugin.json 到 Skills/Agents/Hooks 打包发布全流程Claude Code Plugin 开发完整指南:独立配置 vs Plugin 选型(短名称 vs 命名空间)、5 分钟创建第一个 Plugin(plugin.json Manifest + SKILL.md)、Plugin 目录结构(skills/agents/hooks/settings/lsp)、LSP 服务器集成、随 Plugin 发布默认 Hooks 设置、--plugin-dir 本地测试、从独立配置迁移(名称变化说明)、Git/npm 发布方式,以及 /plugin install/list/enable/disable/remove 用户命令。2026/3/6教程Claude Code Skills 官方完整指南:从入门到高级模式的权威教程Claude Code Skills 官方文档完整中文整理:Skills vs CLAUDE.md 核心区别;目录结构;存储位置和优先级;实时变更检测和 Monorepo 自动发现;完整 Frontmatter 字段参考(20+字段);字符串替换(动态参数);内容类型(参考类 vs 任务类);调用控制表;Skill 内容生命周期(压缩保留机制);三个高级模式(动态注入/路径限定/Subagent运行);以及内置 Bundled Skills 和权限控制方法。2026/5/10