📖 GitHub Trending · obra/superpowers

Agentic Skills Framework:Agent技能框架方法论

凌晨3点48分,我翻到obra/superpowers的README,一句话击中了我——"An agentic skills framework & software development methodology that works"。注意那个"that works"——在AI hype遍地的2026年,敢加这个限定词的项目,要么是真有两把刷子,要么是嘴硬。翻了代码之后,我确信是前者。

这不是又一个AI编程工具,而是Agent时代的方法论基石:如何让你的Agent真正具备"超能力"。

什么是Agentic Skills Framework

Agentic Skills Framework将Agent能力组织为四个层级:

🎯 L4: 目标层 Goals — 人类定义的最终目标
📋 L3: 规划层 Plans — AI生成的执行计划
🔧 L2: 技能层 Skills — 可组合的原子操作
L1: 工具层 Tools — 底层API和系统调用

核心原则

Skill解剖学

一个完整的Skill包含以下结构:

# superpowers skill结构
skills/
└── web-search/
    ├── SKILL.md           # 技能描述文档
    ├── schema.json        # 输入输出Schema
    ├── handler.py         # 执行逻辑
    ├── tests/             # 测试用例
    │   ├── basic.test.py
    │   └── edge.test.py
    ├── examples/          # 使用示例
    │   └── example1.yaml
    └── dependencies/      # 依赖的子Skills
        └── http-request/

Schema定义

# schema.json - Skill接口定义
{
  "name": "web-search",
  "version": "1.2.0",
  "description": "搜索互联网并返回结构化结果",
  "inputs": {
    "query": {
      "type": "string",
      "required": true,
      "description": "搜索关键词"
    },
    "max_results": {
      "type": "integer",
      "default": 10,
      "description": "最大结果数"
    },
    "sources": {
      "type": "array",
      "items": { "type": "string" },
      "default": ["google", "bing"],
      "description": "搜索引擎列表"
    }
  },
  "outputs": {
    "results": {
      "type": "array",
      "items": {
        "title": "string",
        "url": "string",
        "snippet": "string",
        "relevance_score": "number"
      }
    },
    "metadata": {
      "total_found": "integer",
      "search_time_ms": "integer",
      "sources_used": "array"
    }
  },
  "dependencies": ["http-request", "html-parser"],
  "cost": {
    "api_calls": 2,
    "estimated_time_ms": 1500
  }
}

Skill组合模式

1. 串行组合(Pipeline)

# 串行执行:搜索 → 提取 → 总结
pipeline:
  - skill: web-search
    args: { query: "${user_query}" }
    output_var: search_results
  
  - skill: content-extractor
    args: { urls: "${search_results.urls}" }
    output_var: content
  
  - skill: summarizer
    args: { text: "${content}" }
    output_var: summary

2. 并行组合(Parallel)

# 并行执行:同时搜索多个来源
parallel:
  - skill: web-search
    args: { query: "${query}", sources: ["google"] }
    output_var: google_results
  
  - skill: web-search
    args: { query: "${query}", sources: ["bing"] }
    output_var: bing_results
  
  - skill: web-search
    args: { query: "${query}", sources: ["duckduckgo"] }
    output_var: ddg_results

merge:
  skill: result-merger
  args: { results: ["${google_results}", "${bing_results}", "${ddg_results}"] }

3. 条件组合(Conditional)

# 条件执行:根据错误类型选择策略
conditional:
  skill: error-handler
  branches:
    - condition: "error.type == 'timeout'"
      skill: retry-with-backoff
      args: { max_retries: 3, delay_ms: 1000 }
    
    - condition: "error.type == 'rate_limit'"
      skill: rate-limit-handler
      args: { wait_minutes: 5 }
    
    - condition: "error.type == 'auth_failure'"
      skill: credential-refresher
      args: { credential_store: "vault" }
    
    - default:
      skill: escalate-to-human

4. 循环组合(Loop)

# 迭代优化:多轮改进
loop:
  skill: iterative-improver
  max_iterations: 5
  termination:
    - quality_score >= 0.9
    - iteration_count >= 5
  
  body:
    - skill: evaluator
      args: { content: "${current_draft}" }
      output_var: evaluation
    
    - skill: improver
      args: { 
        content: "${current_draft}", 
        feedback: "${evaluation.feedback}" 
      }
      output_var: improved_draft

OpenClaw集成方案

1. 转换为OpenClaw Skill格式

# ~/.openclaw/skills/web-search/SKILL.md
---
name: Web Search Pro
description: 增强版网页搜索,支持多引擎并行
version: 1.2.0
trigger: search the web
cost: ~$0.002/call
---

## 输入参数
- query (string, 必需) - 搜索关键词
- max_results (number, 默认10) - 最大结果数

## 输出格式
返回结构化搜索结果列表,每条包含:
- title: 标题
- url: 链接
- snippet: 摘要
- relevance: 相关度评分

## 依赖Skills
- http-request: HTTP请求工具
- html-parser: HTML解析器
- rate-limiter: 限流器

## 最佳实践
- 使用具体关键词,避免模糊查询
- 并行调用多个搜索引擎提高覆盖率
- 结果缓存24小时避免重复调用

2. 使用Superpowers方法论

# OpenClaw项目中的Skill组织
~/.openclaw/skills/
├── primitives/           # L1: 原子工具
│   ├── http-request/
│   ├── file-read/
│   ├── shell-exec/
│   └── database-query/
├── compound/             # L2: 复合技能
│   ├── web-search/       # 组合: http-request + html-parser
│   ├── code-review/      # 组合: file-read + analyzer
│   ├── deploy/           # 组合: shell-exec + http-request
│   └── monitor/          # 组合: database-query + alert
└── workflows/            # L3: 工作流
    ├── content-pipeline/ # 搜索→提取→生成→发布
    ├── dev-workflow/     # 编码→测试→审查→部署
    └── research-flow/    # 文献→总结→分析→报告

最佳实践

✅ Skill设计原则

  • 原子性:每个Skill做且只做一件事
  • 无状态:Skill不依赖外部状态
  • 幂等性:相同输入相同输出
  • 可观测:执行过程可追踪
  • 可降级:失败时有备选方案

❌ 常见反模式

  • 万能Skill:一个Skill做所有事情
  • 硬编码:配置写死在代码里
  • 无测试:发布后才发现bug
  • 无文档:三天后自己都看不懂
  • 隐式依赖:依赖未声明的全局状态