Phase 4 / Ep 20: 高级 Skill 开发 —— 带脚本和资源文件的复杂 Skill
🎯 学习目标:开发企业级复杂 Skill,掌握多脚本协作和资源管理。
1. 复杂 Skill 结构
crm-manager/
├── SKILL.md # 核心指令
├── scripts/
│ ├── search_contacts.py # 搜索联系人
│ ├── add_contact.py # 添加联系人
│ ├── generate_report.py # 生成报告
│ └── utils/
│ └── db_connector.py # 数据库连接器
├── resources/
│ ├── report_template.html # 报告模板
│ ├── email_template.md # 邮件模板
│ └── config.json # 技能配置
└── examples/
├── search_example.md # 搜索示例
└── report_example.md # 报告示例
2. 多脚本协作
SKILL.md 中为每个脚本定义明确的调用场景:
## 可用操作
### 搜索联系人
当用户要查找某人的信息时:
→ 执行 scripts/search_contacts.py --name "张三"
### 添加联系人
当用户要添加新联系人时:
→ 执行 scripts/add_contact.py --name "xxx" --phone "xxx" --email "xxx"
### 生成月度报告
当用户要求生成客户报告时:
→ 执行 scripts/generate_report.py --month 2026-04
→ 报告会使用 resources/report_template.html 生成
3. Resources 目录
Resources 存放 Skill 需要的静态资源——模板、配置、参考数据。Agent 可以读取这些文件来辅助任务。
4. 跨 Agent 共享 Skill
将 Skill 放在共享目录,多个 Agent 通过符号链接引用:
# 共享目录
mkdir -p ~/.openclaw/shared-skills/crm-manager/
# Agent A 和 Agent B 都引用
ln -s ~/.openclaw/shared-skills/crm-manager ~/.openclaw/agents/personal/skills/crm-manager
ln -s ~/.openclaw/shared-skills/crm-manager ~/.openclaw/agents/sales-agent/skills/crm-manager
5. 版本管理策略
- 使用语义化版本号(SemVer)
- 在 SKILL.md 的 frontmatter 中标注版本
- 大版本升级需要重新测试兼容性
- 建议用 Git 管理 Skill 源码
下节预告: Ep 21,把你开发的 Skill 发布到 ClawHub 市场,让全球社区使用。