Skill Composition
技能编排
流水线
在 OpenClaw 中,技能编排(Skill Composition) 是将多个独立 Skills 组合成有序执行流程的能力。就像乐高积木,你可以把「代码审查」、「安全扫描」、「文档生成」三个技能编排成一个完整的 CI/CD 流水线。
# 定义技能流水线
skills:
- name: code-review
after: []
- name: security-scan
after: [code-review]
- name: doc-generation
after: [security-scan]
- name: pr-creation
after: [doc-generation]
# OpenClaw 执行逻辑
# 1. 执行 code-review
# 2. code-review 完成后,执行 security-scan
# 3. security-scan 完成后,执行 doc-generation
# 4. 最后执行 pr-creation
# 并行执行多个技能
skills:
- name: lint-check
parallel: true
- name: unit-tests
parallel: true
- name: type-check
parallel: true
# 等待所有并行技能完成后继续
after-all:
- name: build-bundle
requires: [lint-check, unit-tests, type-check]
workflow:
- step: detect-language
skill: language-detector
- step: run-linter
skill: "{{language}}-linter"
condition: "language != 'unknown'"
- step: fallback
skill: generic-linter
condition: "language == 'unknown'"
# Skill A 输出数据
# skills/code-analyzer.yaml
outputs:
- name: functions_list
type: array
- name: complexity_score
type: number
# Skill B 读取数据
# skills/refactor-suggester.yaml
inputs:
- name: functions_list
from: code-analyzer
- name: complexity_score
from: code-analyzer
instructions: |
根据 code-analyzer 输出的函数列表,
对复杂度超过 15 的函数提出重构建议。
skill:
name: api-caller
retry_policy:
max_attempts: 3
backoff: exponential
initial_delay: 1000ms
fallback:
skill: api-caller-cache
condition: "error.code == 'RATE_LIMITED'"
# .openclaw/pr-pipeline.yaml
name: "智能 PR 合并流水线"
trigger:
event: pull_request
branches: [main, develop]
pipeline:
- stage: "代码质量检查"
parallel:
- skill: eslint-check
- skill: typescript-check
- skill: unit-tests
- stage: "安全审查"
skill: security-audit
timeout: 300s
- stage: "AI 代码审查"
skill: openclaw-code-review
config:
model: "tencentcodingplan/tc-code-latest"
depth: "detailed"
- stage: "文档更新"
skill: auto-doc
condition: "has_code_changes == true"
- stage: "合并决策"
skill: merge-decider
inputs:
- eslint-check.result
- security-audit.result
- openclaw-code-review.approval
output: merge_decision
- stage: "执行合并"
skill: github-merge
condition: "merge_decision == 'approved'"
notify:
channel: slack
message: "✅ PR #{{pr_number}} 已自动合并"
妙趣AI | OpenClaw 教程合集 | 最后更新:2026-05-22