任务分解器与技能生成器
此技能帮助将复杂的用户请求分解为可执行的子任务,识别每项任务所需的能力,从开放的技能生态系统中搜索现有技能,并在无现成解决方案时自动创建新技能。
核心工作流程
User Request → Task Decomposition → Capability Identification → Skill Search → Gap Analysis → Skill Creation → Execution Plan
阶段一:任务分析与分解
当接收到用户请求时,请遵循以下步骤:

步骤一:理解用户意图
分析请求以确定:
- 核心目标:最终目的是什么?
- 涉及领域:需要哪些专业领域的知识?
- 触发机制:一次性、计划性还是事件驱动?
示例分析:
User Input: "Help me get email summaries every morning and send them to Slack"
Analysis:
- Core objective: Automated email digest delivery to Slack
- Domains: Email access, content summarization, messaging
- Trigger: Scheduled (daily morning)
步骤二:分解为原子任务
将复杂任务拆解为最小的可执行单元:
Task Decomposition:
- task_id: 1
name: "Access and retrieve email list"
type: "data_retrieval"
input: "Email credentials/session"
output: "List of emails with metadata"
dependencies: []
- task_id: 2
name: "Extract key information from emails"
type: "data_extraction"
input: "Email list"
output: "Structured email data"
dependencies: [1]
- task_id: 3
name: "Generate email summary"
type: "content_generation"
input: "Structured email data"
output: "Formatted summary text"
dependencies: [2]
- task_id: 4
name: "Send message to Slack"
type: "message_delivery"
input: "Summary text, Slack webhook/token"
output: "Delivery confirmation"
dependencies: [3]
- task_id: 5
name: "Configure scheduled execution"
type: "scheduling"
input: "Workflow script, schedule config"
output: "Active scheduled job"
dependencies: [4]
阶段二:能力识别
将每个子任务映射到通用能力分类体系中的一种能力类型。
通用能力类型
| 能力 | 描述 | 搜索关键词 |
|---|---|---|
browser_automation | 网页导航、交互、抓取 | 浏览器, selenium, puppeteer, playwright, 抓取 |
web_search | 互联网搜索与信息检索 | 搜索, 谷歌, bing, duckduckgo |
api_integration | 第三方API通信 | api, rest, graphql, webhook, {服务名称} |
data_extraction | 解析与提取结构化数据 | 解析, 提取, 抓取, ocr, pdf |
data_transformation | 转换、清理、转换数据 | 转换, 转化, 格式化, 清理, etl |
content_generation | 创建文本、图像或其他内容 | 生成, 撰写, 创建, 总结, 翻译 |
文件操作 | 读取、写入、操作文件 | 文件、读取、写入、csv、excel、json、pdf |
消息传递 | 发送通知或消息 | 通知、发送、电子邮件、slack、discord、telegram |
调度 | 基于时间的任务执行 | 调度、cron、定时器、每日、每周 |
认证 | 身份和访问管理 | 认证、oauth、登录、令牌、凭证 |
数据库操作 | 数据库增删改查操作 | 数据库、sql、mongodb、查询、存储 |
代码执行 | 运行脚本或程序 | 执行、运行、脚本、shell、python |
版本控制 | Git与代码仓库操作 | git、github、gitlab、提交、pr、审查 |
测试 | 自动化测试与质量保证 | 测试,Jest,Pytest,端到端测试,单元测试 |
部署 | 应用程序部署与CI/CD | 部署,Docker,Kubernetes,CI-CD,发布 |
监控 | 系统与应用程序监控 | 监控,告警,日志,指标,健康状态 |
能力识别流程
对于每个子任务:
- 分析任务描述与要求
- 匹配到一个或多个能力类型
- 生成用于技能发现的搜索关键词
示例:
Task: "Send message to Slack"
Capability: message_delivery
Search Keywords: ["slack", "notification", "message", "webhook"]
第三阶段:技能搜索
使用Skills CLI在以下位置搜索现有技能:https://skills.sh/
搜索流程
针对每个能力需求,使用相关关键词进行搜索:
# Search for skills matching the capability
npx skills find <keyword>
# Examples:
npx skills find slack notification
npx skills find browser automation
npx skills find pdf extract
npx skills find github api
评估搜索结果
当返回结果时:
Install with npx skills add <owner/repo@skill>
owner/repo@skill-name
└ https://skills.sh/owner/repo/skill-name
评估每个结果的以下方面:
- 相关性:是否与所需能力匹配?
- 完整性:是否涵盖了所有需要的功能?
- 质量:是否文档完善且维护良好?
生成能力映射
Capability Mapping:
- task_id: 1
capability: browser_automation
search_query: "browser email automation"
found_skills:
- name: "anthropic/claude-skills@browser-use"
url: "https://skills.sh/anthropic/claude-skills/browser-use"
match_score: high
recommendation: "Install browser-use skill"
- task_id: 4
capability: message_delivery
search_query: "slack notification"
found_skills: []
recommendation: "Create new skill: slack-notification"
阶段 4:差距分析
识别没有匹配技能的任务:
内置能力(无需额外技能)
这些能力通常由智能体的原生能力处理:
内容生成- 大语言模型的原生文本生成数据转换- 通过代码进行基本的数据操作代码执行- 直接执行脚本调度- 系统级 cron/调度器配置
所需技能
对于没有内置支持的能力,确定:
- 技能存在:从 skills.sh 安装
- 未找到技能:创建新技能
阶段 5:技能创建
当没有现有技能匹配所需能力时,创建一个新技能。
技能创建流程
- 定义范围:确定该技能应实现的功能
- 设计接口:定义输入、输出和使用模式
- 创建 SKILL.md:编写技能定义文件
- 添加资源:根据需要包含脚本、参考资料或资产
技能模板
---
name: {skill-name}
description: {Clear description of what the skill does and when to use it. Written in third person.}
---
# {Skill Title}
{Brief introduction explaining the skill's purpose.}
## When to Use
{Describe scenarios when this skill should be triggered.}
## Prerequisites
{List any required installations, configurations, or credentials.}
## Usage
{Detailed usage instructions with examples.}
### Basic Usage
```bash
{Basic command or code example}
高级用法
{更复杂的示例和选项。}
配置
{任何配置选项或环境变量。}
示例
示例一:{用例}
{包含代码的逐步示例。}
故障排除
{常见问题及解决方案。}
### Initialize New Skill
```bash
# Create skill using the skills CLI
npx skills init <skill-name>
# Or manually create the structure:
# skill-name/
# ├── SKILL.md (required)
# ├── scripts/ (optional)
# ├── references/ (optional)
# └── assets/ (optional)
第六阶段:生成执行计划
将所有信息汇编成结构化的执行计划:
Execution Plan:
title: "{Task Description}"
prerequisites:
- "{Prerequisite 1}"
- "{Prerequisite 2}"
skills_to_install:
- skill: "owner/repo@skill-name"
command: "npx skills add owner/repo@skill-name -g -y"
url: "https://skills.sh/owner/repo/skill-name"
skills_to_create:
- name: "{new-skill-name}"
capability: "{capability_type}"
description: "{What it does}"
execution_steps:
- step: 1
task: "{Task name}"
skill: "{skill-name | built-in}"
action: "{Specific action to take}"
- step: 2
task: "{Task name}"
skill: "{skill-name | built-in}"
action: "{Specific action to take}"
verification:
- "{How to verify step 1 succeeded}"
- "{How to verify step 2 succeeded}"
任务分解原则
原则一:原子性
每个子任务应是具有明确输入输出的最小可执行单元。
原则二:独立性
最小化任务间的依赖关系,尽可能允许并行执行。
原则三:可验证性
每个任务应有明确的方法来验证其成功完成。
原则四:可复用性
识别可复用的模式,优先创建通用技能。
原则五:单一职责
每个任务应专注于做好一件事。
输出格式
以结构化格式呈现分解结果:
════════════════════════════════════════════════════════════════
📋 TASK DECOMPOSITION REPORT
════════════════════════════════════════════════════════════════
🎯 Original Request:
{User's original request}
────────────────────────────────────────────────────────────────
📊 SUBTASKS
────────────────────────────────────────────────────────────────
┌─────┬────────────────────────┬───────────────────┬───────────┐
│ ID │ Task │ Capability │ Status │
├─────┼────────────────────────┼───────────────────┼───────────┤
│ 1 │ {task name} │ {capability} │ Found │
│ 2 │ {task name} │ {capability} │ Built-in │
│ 3 │ {task name} │ {capability} │ Create │
└─────┴────────────────────────┴───────────────────┴───────────┘
────────────────────────────────────────────────────────────────
🔍 SKILL SEARCH RESULTS
────────────────────────────────────────────────────────────────
Task 1: {task name}
Search: npx skills find {keywords}
Found: owner/repo@skill-name
URL: https://skills.sh/owner/repo/skill-name
Task 3: {task name}
Search: npx skills find {keywords}
Found: No matching skills
Action: Create new skill
────────────────────────────────────────────────────────────────
🛠️ SKILLS TO CREATE
────────────────────────────────────────────────────────────────
1. {skill-name}
Capability: {capability_type}
Description: {what it does}
────────────────────────────────────────────────────────────────
📝 EXECUTION PLAN
────────────────────────────────────────────────────────────────
Prerequisites:
• {prerequisite 1}
• {prerequisite 2}
Steps:
1. {action} using {skill}
2. {action} using {skill}
3. {action} using {skill}
════════════════════════════════════════════════════════════════
示例
示例 1:工作流自动化
用户请求:
Create a workflow that monitors GitHub issues, summarizes new issues, and posts notifications to Discord
分解:
Subtasks:
1. Monitor GitHub repository for new issues
Capability: api_integration
Search: "npx skills find github issues"
2. Extract issue content and metadata
Capability: data_extraction
Status: Built-in (code)
3. Generate issue summary
Capability: content_generation
Status: Built-in (LLM)
4. Send notification to Discord
Capability: message_delivery
Search: "npx skills find discord notification"
5. Configure webhook or polling trigger
Capability: scheduling
Status: Built-in (system)
示例 2:数据管道
用户请求:
Search for AI research papers, download PDFs, extract key findings, and save to Notion
分解:
Subtasks:
1. Search for AI research papers
Capability: web_search
Search: "npx skills find academic search"
2. Download PDF files
Capability: browser_automation
Search: "npx skills find browser download"
3. Extract text from PDFs
Capability: data_extraction
Search: "npx skills find pdf extract"
4. Generate summaries of key findings
Capability: content_generation
Status: Built-in (LLM)
5. Save to Notion database
Capability: api_integration
Search: "npx skills find notion"
最佳实践
- 从技能搜索开始:在创建新技能前,务必先检查https://skills.sh/使用具体的搜索术语
- :将能力关键词与领域术语相结合利用内置能力
- :不要为智能体原生就能完成的功能创建技能创建可复用的技能
- :尽可能将新技能设计为通用型详细记录
- :新技能应附有清晰的使用说明执行前验证
- :在执行任务前确认技能已安装: Confirm skill installation before executing tasks
- 优雅地处理错误: 在执行计划中包含备用策略
与查找技能集成
此技能与find-skills技能协同工作,用于发现现有解决方案:
# Search the skills ecosystem
npx skills find <query>
# Install a discovered skill
npx skills add <owner/repo@skill> -g -y
# Browse all available skills
# Visit: https://skills.sh/
备注
- 在创建新技能前,始终先搜索现有技能
- 内置功能(LLM、基础代码)无需额外技能
- 创建技能前需获得用户确认方可继续
- 复杂工作流程可能需要多个技能协同运作


微信扫一扫,打赏作者吧~
网友评论
最新评论