Skip to content

Skills 与 ClawHub(按官方 Tools/Skills)

先区分三个概念

概念定义用途示例
Skill任务知识与流程模板"如何做"发布检查、代码审查
Tool可调用执行能力"能做什么"执行命令、浏览器操作
Plugin扩展渠道或工具来源"接入什么"新渠道、新工具源

参考:

Skill 结构

txt
~/.openclaw/skills/
└── my-skill/
    ├── SKILL.md           # 入口文件(必需)
    ├── references/        # 参考资料
    │   ├── guide.md
    │   └── examples.md
    ├── scripts/           # 可执行脚本
    │   └── check.sh
    ├── assets/            # 模板与示例
    │   └── template.yaml
    └── tests/             # 测试用例
        └── test.md

SKILL.md 模板

markdown
# SKILL.md

## name

release-readiness-check

## description

用于发布前检查评测、监控、回滚配置是否齐备。

## triggers

- 发布前自动触发
- 手动调用:`/skill release-check --version {version}`

## inputs

| 参数      | 类型   | 必填 | 说明             |
| --------- | ------ | ---- | ---------------- |
| version   | string | 是   | 发布版本号       |
| changelog | string | 否   | 变更说明文件路径 |

## workflow

1. Gather:读取变更与评测报告
2. Decide:检查门禁阈值
3. Execute:生成风险分级
4. Verify:校验输出完整性

## outputs

```json
{
  "risk_level": "low|medium|high",
  "blocking_issues": ["issue1"],
  "recommendations": ["rec1"]
}
```

## examples

### 示例 1:正常发布

输入:版本 1.2.0,评测通过
输出:风险等级 low,建议发布

### 示例 2:评测未通过

输入:版本 1.3.0,评测成功率 88%
输出:风险等级 high,建议阻塞

## references

- [评测与迭代](/ai-best-practices/evaluation)
- [工程落地手册](/ai-best-practices/engineering-playbook)

## version

- 1.0.0 (2026-03-08): 初始版本

## ClawHub 的定位

ClawHub 是 Skills 的分发与复用入口,适合团队沉淀可迁移工作流。

### ClawHub 功能

- **发现**:浏览社区 Skills
- **安装**:一键安装到本地
- **发布**:分享自己的 Skills
- **版本管理**:跟踪 Skill 更新

### 使用 ClawHub

```bash
# 搜索 Skill
openclaw skills search "code review"

# 安装 Skill
openclaw skills install release-check

# 查看 Skill 详情
openclaw skills show release-check

# 更新 Skill
openclaw skills update release-check

# 发布 Skill 到 ClawHub
openclaw skills publish my-skill
```

## Skill 设计建议(开发者视角)

### 1. 单一职责

一个 Skill 只解决一个高频任务域:

```yaml
# ✅ 好的设计
- code-review: 代码审查
- release-check: 发布检查
- incident-report: 事故报告

# ❌ 不好的设计
- do-everything: 做所有事情
```

### 2. 明确输入输出

```yaml
inputs:
  - name: code_path
    type: string
    required: true
    description: 代码路径

  - name: review_depth
    type: enum
    values: [quick, standard, deep]
    default: standard

outputs:
  - name: review_result
    type: object
    schema:
      issues: array
      suggestions: array
      score: number
```

### 3. 错误处理

```yaml
error_handling:
  - error: input_invalid
    action: return_error
    message: 'Invalid input: {details}'

  - error: tool_unavailable
    action: fallback
    fallback_skill: simple-check

  - error: timeout
    action: return_partial
    message: Partial results due to timeout
```

### 4. 可测试性

```markdown
## tests

### 测试用例 1:正常流程

input:
version: "1.0.0"
changelog: "docs/CHANGELOG.md"
expected:
risk_level: "low"
blocking_issues: []

### 测试用例 2:评测未通过

input:
version: "1.0.0"
eval_result: "failed"
expected:
risk_level: "high"
blocking_issues: ["eval_failed"]
```

## Skill 治理建议(产品经理视角)

### 按 业务链路管理

```yaml
skill_categories:
  development:
    - code-review
    - test-generator
    - doc-writer

  release:
    - release-check
    - changelog-generator
    - deploy-monitor

  operations:
    - incident-report
    - log-analyzer
    - alert-manager
```

### 版本管理

```yaml
skill_versions:
  release-check:
    current: 1.2.0
    history:
      - version: 1.2.0
        date: 2026-03-08
        changes: [Add security check]
      - version: 1.1.0
        date: 2026-03-01
        changes: [Add performance check]
```

### 审批策略

```yaml
skill_approvals:
  - skill: exec:*
    requires_approval: true
    approvers: [admin]

  - skill: write:sensitive
    requires_approval: true
    approvers: [admin, security]
```

## 团队落地模板

### 第 1 周:选 3 个高频任务

```markdown
- [ ] 代码审查
- [ ] 发布检查
- [ ] 事故报告
```

### 第 2 周:每个 Skill 增加示例

```markdown
- 成功样例
- 失败样例
- 边界情况
```

### 第 3 周:复盘和优化

```yaml
review_metrics:
  code-review:
    hit_rate: 85% # 成功调用率
    rewrite_rate: 10% # 需要重写的比例
    user_satisfaction: 4.2/5
```

### 第 4 周:持续迭代

```yaml
iteration_plan:
  - optimize: code-review
    focus: 减少误报
  - add: deploy-monitor
    priority: high
```

## CLI 入口

```bash
# Skill 管理
openclaw skills list                    # 列出已安装 Skills
openclaw skills search <keyword>        # 搜索 Skills
openclaw skills install <name>          # 安装 Skill
openclaw skills update <name>           # 更新 Skill
openclaw skills remove <name>           # 移除 Skill

# Skill 开发
openclaw skills create <name>           # 创建 Skill
openclaw skills test <name>             # 测试 Skill
openclaw skills validate <name>         # 验证 Skill
openclaw skills publish <name>          # 发布 Skill

# Skill 使用
openclaw skills run <name> [options]    # 运行 Skill
openclaw skills info <name>             # 查看 Skill 信息
```

## 最佳实践

### 1. 命名规范

```yaml
# ✅ 好的命名
- release-readiness-check
- code-review-automation
- incident-report-generator

# ❌ 不好的命名
- check
- review
- report
```

### 2. 文档完整

```markdown
# 必需内容

- name: 技能名称
- description: 简短描述
- inputs: 输入参数
- outputs: 输出格式
- examples: 使用示例

## 推荐内容

- references: 参考资料
- version: 版本历史
- author: 作者信息
```

### 3. 渐进式复杂度

```txt
# 版本 1.0:基础功能
workflow:
  - step: check
  - step: report

# 版本 2.0:增加配置
workflow:
  - step: check
    config:
      depth: standard
  - step: report
    format: markdown

# 版本 3.0:增加自动化
workflow:
  - step: check
    auto_fix: true
  - step: report
    notify: true
```