Akemi

使用OpenClaw创建自定义AI技能

2026/03/12

使用OpenClaw创建自定义AI技能

今天我体验了使用OpenClaw创建自定义AI技能的全过程。这不仅仅是一个简单的工具,而是一个完整的工作流,让我能够通过自然语言描述来扩展AI的能力。

背景

我需要一个功能:能够远程在我的Hexo博客上发布文章。具体需求包括:

  1. SSH连接到我的远程服务器(192.168.10.100)
  2. 创建新的Hexo博客文章
  3. 填充Markdown内容
  4. 验证格式是否正确
  5. 等待我确认后部署发布

创建过程

第一步:自然语言描述需求

我直接用中文描述了我的需求,包括服务器信息、操作步骤、触发关键词等细节。OpenClaw理解了我的需求后,主动读取了skill-creator skill的SKILL.md文件,了解创建技能的标准流程。

第二步:初始化Skill结构

OpenClaw使用了skill-creator skill提供的init_skill.py脚本,自动生成了skill的目录结构:

1
python3 /path/to/init_skill.py hexo-blog-poster --path . --resources scripts

生成的目录结构:

1
2
3
hexo-blog-poster/
├── SKILL.md (必需)
└── scripts/ (可选)

第三步:编写SKILL.md

根据我的需求,OpenClaw编写了SKILL.md文件,包含了:

  • Frontmatter: YAML格式的元数据(name和description)
    • name: hexo-blog-poster
    • description: 详细描述了skill的功能和触发条件
  • Body: 具体的工作流程和命令参考

第四步:打包和安装

使用package_skill.py将skill打包成.skill文件(实际是一个zip文件),然后解压到OpenClaw的skills目录中完成安装。

1
2
3
4
python3 package_skill.py hexo-blog-poster
# 生成 hexo-blog-poster.skill

# 解压到 skills/ 目录

Skill说明文档

以下是最终生成的hexo-blog-poster skill的完整说明:

1
2
3
4
---
name: hexo-blog-poster
description: Remote blog post creation for Hexo blogs. Use when user says 发博客 or asks to create/publish a blog post. This skill handles SSH connection to remote server (192.168.10.100), creates new Hexo posts with `hexo new`, populates content, validates Markdown formatting, waits for user confirmation, and deploys via `./hexo.sh` script.
---
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Hexo Blog Poster

Remote blog post creation and deployment for Hexo-based blogs.

## Workflow

### Step 1: Get Inputs

Ask the user for two pieces of information:

1. **File Title (文件标题)**: This will be used for the filename and for `hexo new` command
- Example: `OpenClaw-gen-Skills`

2. **Content Body (正文内容)**: The main Markdown content for the article

### Step 2: Create New Post

1. SSH connect to remote server: `192.168.10.100` (user: `root`, password: `1`)
2. Change to blog directory: `cd /blog`
3. Execute: `hexo new <file_title>`
- `<file_title>` is the file title provided by user
4. This creates: `/blog/source/_post/<file_title>.md`

### Step 3: Populate Content

The generated `.md` file has this structure:

```markdown
---
title: 标题
date: 2026-03-06 15:14:45
tags:
---
正文

Actions:

  1. Summarize and update title field: Read the user-provided content, summarize it to create an appropriate article title, then update the title field in the frontmatter
  2. Populate content: Replace the 正文 section with the user-provided Markdown content
  3. Keep the date field as-is unless instructed to modify
  4. If user provides tags, update the tags field

Step 4: Format Validation

Before proceeding, review entire .md file and check for:

Code block issues:

  • Unclosed ``` code blocks
  • Mismatched code block syntax

Heading hierarchy issues:

  • Inconsistent heading levels (e.g., content that should be ## is marked as ####)
  • Skipped heading levels (e.g., # to ### without ##)

If issues found:

  1. Pause the workflow
  2. Report specific issues to user
  3. Wait for user confirmation to proceed or fix

If no issues: Continue to Step 5

Step 5: Deploy

  1. Return to /blog directory
  2. Execute: ./hexo.sh
  3. Monitor output for git push messages
  4. If push completes without errors: Success
  5. If errors occur: Report to user

Commands Reference

SSH connection:

1
2
ssh root@192.168.10.100
# Password: 1

Create new post:

1
2
cd /blog
hexo new Your Post Title

Deploy:

1
2
cd /blog
./hexo.sh
1
2
3
4
5

## OpenClaw当前状态

**运行环境:**

Runtime: agent=main
Host: DESKTOP-3VAHGJ7
Repo: /home/ws/.openclaw/workspace
OS: Linux 4.4.0-19041-Microsoft (x64)
Node: v22.22.1
Shell: bash
Channel: webchat
Capabilities: none
Thinking: low
Reasoning: off


**模型信息:**
- **当前使用模型**:zai/glm-4.7
- **默认模型**:zai/glm-4.7
- **模型提供商**:Z.AI(智谱AI)

## 技能设计原则

根据skill-creator的指导,OpenClaw在创建这个skill时遵循了以下原则:

1. **简洁性优先**:默认假设AI已经足够智能,只添加必要的上下文信息
2. **渐进式披露**:三级加载系统(metadata → SKILL.md → bundled resources)优化上下文窗口使用
3. **适当的自由度**:根据任务的脆弱性和可变性选择具体的指导程度
4. **模块化资源**:支持scripts/、references/、assets/三种可选资源目录

## 总结

这次体验让我深刻感受到OpenClaw的强大之处:

1. **自然语言驱动**:不需要写代码,用中文描述需求即可
2. **自动化流程**:从初始化到安装,全程自动化处理
3. **标准化规范**:遵循AgentSkills规范,确保skill质量和可维护性
4. **即时可用**:创建完成后立即可用,无需额外配置

通过这种方式,我可以快速创建各种自定义技能,让AI更好地服务于我的特定需求。这不仅仅是写代码,而是在编程AI的行为模式。
CATALOG
  1. 1. 使用OpenClaw创建自定义AI技能
    1. 1.1. 背景
    2. 1.2. 创建过程
      1. 1.2.1. 第一步:自然语言描述需求
      2. 1.2.2. 第二步:初始化Skill结构
      3. 1.2.3. 第三步:编写SKILL.md
      4. 1.2.4. 第四步:打包和安装
    3. 1.3. Skill说明文档
      1. 1.3.1. Step 4: Format Validation
      2. 1.3.2. Step 5: Deploy
    4. 1.4. Commands Reference