任务分解器与技能生成器
此技能可将复杂的用户请求分解为可执行的子任务,识别每项任务所需的能力,从开放的技能生态系统中搜索现有技能,并在无现有解决方案可用时自动创建新技能。
核心工作流程
User Request → Task Decomposition → Capability Identification → Skill Search → Gap Analysis → Skill Creation → Execution Plan
阶段一:任务分析与分解
接收用户请求时,请遵循以下步骤:
步骤1:理解用户意图
分析请求以识别:
- 核心目标:最终目的是什么?
- 涉及领域:需要哪些专业领域的知识?
- 触发机制:一次性执行、计划调度还是事件驱动?
示例分析:
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)
步骤2:分解为原子任务
将复杂任务拆解为最小可执行单元:
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]
阶段二:能力识别
将每个子任务映射到通用能力分类体系中的能力类型。
通用能力类型
| 能力 | 描述 | 搜索关键词 |
|---|---|---|
浏览器自动化 | 网络导航、交互、抓取 | 浏览器、selenium、puppeteer、playwright、抓取 |
网络搜索 | 互联网搜索和信息检索 | 搜索、谷歌、必应、DuckDuckGo |
API集成 | 第三方API通信 | api、rest、graphql、webhook、{服务名称} |
数据提取 | 解析和提取结构化数据 | 解析、提取、抓取、光学字符识别、PDF |
数据转换 | 转换、清理、变换数据 | 转换、变换、格式化、清理、ETL |
内容生成 | 创建文本、图像或其他内容 | 生成、撰写、创建、总结、翻译 |
file_operations | 读取、写入、操作文件 | 文件、读取、写入、csv、excel、json、pdf |
message_delivery | 发送通知或消息 | 通知、发送、电子邮件、slack、discord、telegram |
scheduling | 基于时间的任务执行 | 调度、cron、计时器、每日、每周 |
authentication | 身份和访问管理 | 认证、oauth、登录、令牌、凭据 |
database_operations | 数据库CRUD操作 | 数据库、sql、mongodb、查询、存储 |
code_execution | 运行脚本或程序 | 执行、运行、脚本、shell、python |
version_control | Git和代码仓库操作 | git、github、gitlab、提交、pr、评审 |
testing | 自动化测试与质量保证 | 测试、jest、pytest、端到端测试、单元测试 |
部署 | 应用部署与持续集成/持续交付 | 部署、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
- 优雅地处理错误:在执行计划中包含备用策略
与查找技能集成
此技能与查找技能协同工作,用于发现现有解决方案:
# 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、基础代码)无需技能支持
- 技能创建需获得用户确认方可继续
- 复杂工作流可能需要多个技能协同运作


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