$workflow.input.user_intent/skills/workflow-define-skill/SKILL.md
# workflow-define-skill **用途**: 定义 Workflow(基于需求生成 Workflow YAML) **输入**: 需求、系统结构、Skills 列表 **输出**: Workflow YAML 定义 --- ## 核心原则 1. **基于需求驱动** - Workflow 服务于具体需求 2. **复用 Skills** - 优先使用已有的 Skills 3. **遵循规范** - 严格遵循 workflow-spec.md 4. **清晰命名** - Workflow 和节点名称自解释 5. **适度复杂** - 避免过度设计,保持简单 --- ## 输入格式 ```yaml input: requirement: # 需求描述 name: string # Workflow 名称 purpose: string # 用途 trigger: object # 触发
npx skillsauth add maxoreric/sop-engine $workflow.input.user_intent/skills/workflow-define-skillInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
用途: 定义 Workflow(基于需求生成 Workflow YAML)
输入: 需求、系统结构、Skills 列表
输出: Workflow YAML 定义
input:
requirement: # 需求描述
name: string # Workflow 名称
purpose: string # 用途
trigger: object # 触发方式
expected_flow: array # 期望的步骤流程
inputs: object # 输入参数
outputs: object # 输出结果
available_skills: # 可用的 Skills
- name: string
input: object
output: object
structure: # 系统结构(数据路径)
data_paths: object
output_paths: object
domain: string # 领域(health / finance / learning)
output:
workflow: # 完整的 Workflow 定义
name: string
description: string
version: string
input: object # Workflow 输入
output: object # Workflow 输出
nodes: object # 节点定义
edges: array # 边定义
entry: string # 入口节点
exit: string # 出口节点
metadata: # 元数据
complexity: string # simple / medium / complex
estimated_duration: string # 预计执行时间
dependencies: array # 依赖的 Skills
从需求中提取关键信息:
def analyze_requirement(requirement):
"""
提取 Workflow 的关键特征
"""
return {
"type": identify_workflow_type(requirement.purpose),
"steps": requirement.expected_flow,
"trigger_type": requirement.trigger.type, # manual / tick / event
"has_loop": check_if_needs_loop(requirement),
"has_condition": check_if_needs_condition(requirement),
"complexity": estimate_complexity(requirement)
}
Workflow 类型:
将期望的步骤映射到具体的 Skills:
def map_steps_to_skills(expected_flow, available_skills):
"""
将抽象步骤映射到具体 Skills
"""
mapping = {}
for step in expected_flow:
# 关键词匹配
if "collect" in step.lower():
mapping[step] = find_skill("data-collect", available_skills)
elif "analyze" in step.lower():
mapping[step] = find_skill("analyze", available_skills)
elif "generate" in step.lower():
mapping[step] = find_skill("generate", available_skills)
elif "notify" in step.lower():
mapping[step] = find_skill("notify", available_skills)
# ... 更多模式
return mapping
根据分析结果构建 Workflow 结构:
def build_workflow(requirement, skill_mapping):
"""
构建 Workflow 的 nodes 和 edges
"""
workflow = {
"name": requirement.name,
"nodes": {},
"edges": []
}
# 构建节点
for i, (step, skill) in enumerate(skill_mapping.items()):
node_id = f"step{i+1}"
workflow["nodes"][node_id] = {
"type": "skill",
"skill": skill.name,
"input": map_inputs(step, skill, requirement)
}
# 构建边(顺序执行)
node_ids = list(workflow["nodes"].keys())
for i in range(len(node_ids) - 1):
workflow["edges"].append({
"from": node_ids[i],
"to": node_ids[i+1]
})
# 添加结束边
workflow["edges"].append({
"from": node_ids[-1],
"to": "END"
})
return workflow
循环:
if analysis["has_loop"]:
add_loop_controller(workflow, max_iterations=5)
条件分支:
if analysis["has_condition"]:
add_condition_node(workflow, condition_expression)
def validate_workflow(workflow, available_skills):
"""
验证 Workflow 定义是否合法
"""
checks = {
"all_skills_exist": check_skills_exist(workflow, available_skills),
"no_cycles": check_no_unintended_cycles(workflow),
"variables_valid": check_variable_references(workflow),
"entry_exit_valid": check_entry_exit(workflow)
}
if not all(checks.values()):
return {"valid": False, "errors": checks}
return {"valid": True}
workflow:
name: data-processing-workflow
description: 收集 → 分析 → 生成报告
nodes:
collect:
type: skill
skill: data-collect-skill
input:
date: $workflow.input.date
analyze:
type: skill
skill: analyze-skill
input:
data: $collect.output
report:
type: skill
skill: report-skill
input:
analysis: $analyze.output
edges:
- from: collect
to: analyze
- from: analyze
to: report
- from: report
to: END
entry: collect
exit: END
workflow:
name: iterative-improvement-workflow
description: 创建 → 评价 → 迭代(直到通过)
nodes:
loop_controller:
type: loop
max_iterations: 5
condition: "$evaluate.output.pass == false"
create:
type: skill
skill: create-skill
evaluate:
type: skill
skill: evaluate-skill
input:
artifact: $create.output
check:
type: condition
expression: "$evaluate.output.pass == true"
iterate:
type: skill
skill: iterate-skill
input:
artifact: $create.output
feedback: $evaluate.output
edges:
- from: loop_controller
to: create
condition: "$loop.should_continue"
- from: create
to: evaluate
- from: evaluate
to: check
- from: check
to: END
condition: true
- from: check
to: iterate
condition: false
- from: iterate
to: loop_controller
entry: loop_controller
exit: END
workflow:
name: conditional-workflow
description: 检查 → 条件判断 → 不同路径
nodes:
check:
type: skill
skill: check-skill
decision:
type: condition
expression: "$check.output.status == 'success'"
success_path:
type: skill
skill: success-handler-skill
failure_path:
type: skill
skill: failure-handler-skill
edges:
- from: check
to: decision
- from: decision
to: success_path
condition: true
- from: decision
to: failure_path
condition: false
- from: success_path
to: END
- from: failure_path
to: END
entry: check
exit: END
requirement:
name: daily-check
purpose: 每日健康检查,收集数据并生成报告
trigger:
type: tick
schedule: "21:00"
expected_flow:
- "收集今日健康数据"
- "分析健康指标"
- "生成每日总结"
- "通知用户"
inputs:
date: string # 日期(默认今天)
outputs:
report_path: string # 报告路径
available_skills:
- name: data-collect-skill
input: {date, sources}
output: {collected_data}
- name: health-indicators-skill
input: {indicators, profile}
output: {analysis, alerts}
- name: daily-review-skill
input: {analysis, date}
output: {report}
- name: notify-user-skill
input: {message, path}
output: {notified}
structure:
data_paths:
profile: "data/profile/profile.json"
indicators: "data/indicators/{date}.json"
output_paths:
reports: "outputs/reports/daily/"
workflow:
name: daily-check
description: 每日健康检查流程
version: 1.0.0
input:
date: string # 默认为今天
output:
report_path: string
alerts: array
nodes:
# 步骤 1: 收集数据
collect_data:
type: skill
skill: data-collect-skill
input:
date: $workflow.input.date
sources:
- "data/indicators/$workflow.input.date.json"
- "data/profile/profile.json"
output_to: $collected_data
# 步骤 2: 分析健康指标
analyze_indicators:
type: skill
skill: health-indicators-skill
input:
indicators: $collected_data.indicators
profile: $collected_data.profile
output_to: $analysis
# 步骤 3: 生成每日总结
generate_review:
type: skill
skill: daily-review-skill
input:
analysis: $analysis
date: $workflow.input.date
output_to: $review
# 步骤 4: 通知用户
notify_user:
type: skill
skill: notify-user-skill
input:
message: "今日健康检查完成"
path: $review.report_path
output_to: $notification
edges:
- from: collect_data
to: analyze_indicators
- from: analyze_indicators
to: generate_review
- from: generate_review
to: notify_user
- from: notify_user
to: END
entry: collect_data
exit: END
metadata:
complexity: simple
estimated_duration: "2-3 minutes"
dependencies:
- data-collect-skill
- health-indicators-skill
- daily-review-skill
- notify-user-skill
trigger:
type: tick
schedule: "21:00"
notes: |
这是一个简单的顺序 Workflow,无循环无分支。
每天晚上 9 点自动执行。
使用循环的场景:
不使用循环的场景:
使用条件的场景:
不使用条件的场景:
使用并行的场景:
不使用并行的场景:
# Workflow 的输入参数
$workflow.input.date
$workflow.input.user_id
# 示例
input:
date: $workflow.input.date
# 直接引用节点输出
$collect_data.output
$analyze.output.alerts
# 使用 output_to 定义的变量
$collected_data # 如果 collect_data 有 output_to: $collected_data
$analysis # 如果 analyze 有 output_to: $analysis
# 循环相关
$loop.iteration # 当前循环次数
$loop.should_continue # 是否继续循环
$loop.should_exit # 是否退出循环
# 上一步输出(顺序执行时)
$prev.output
示例:
daily-checkweekly-reportcheckup-analysisDailyCheckworkflow_1示例:
collect_dataanalyze_indicatorsgenerate_reviewstep1node_a见 criteria.md
严格按照规范定义节点和边,确保:
引用的所有 Skills 必须在 available_skills 中:
for node in workflow.nodes:
if node.type == "skill":
assert node.skill in available_skills, f"Skill {node.skill} not found"
确保所有变量引用都有效:
# 被引用的节点必须在当前节点之前执行
if "$collect_data.output" in node.input:
assert "collect_data" in executed_nodes
原则: 从简单开始,需要时再增加复杂度
❌ 过度设计:
# 只需要顺序执行 3 步,却用了循环 + 条件
✅ 合适设计:
# 顺序执行即可
collect → analyze → report
extract → transform → load
collect_data → analyze → generate_report → notify
loop: create → evaluate → (pass? exit : iterate)
submit → review → (approved? publish : reject)
data-ai
# workflow-define-skill **用途**: 定义 Workflow(基于需求生成 Workflow YAML) **输入**: 需求、系统结构、Skills 列表 **输出**: Workflow YAML 定义 --- ## 核心原则 1. **基于需求驱动** - Workflow 服务于具体需求 2. **复用 Skills** - 优先使用已有的 Skills 3. **遵循规范** - 严格遵循 workflow-spec.md 4. **清晰命名** - Workflow 和节点名称自解释 5. **适度复杂** - 避免过度设计,保持简单 --- ## 输入格式 ```yaml input: requirement: # 需求描述 name: string # Workflow 名称 purpose: string # 用途 trigger: object # 触发
testing
Skill 版本管理的 Skill。当需要 A/B test、切换版本、回滚时触发。触发词:版本、version、A/B test、切换、回滚、promote。
development
# user-confirm-skill **用途**: 判别式确认 - 展示内容并获取用户反馈 **核心理念**: - 做选择题,不做填空题 - 人类擅长判别(喜不喜欢),不擅长生成(描述细节) - 展示具体方案,让用户说"对/不对" --- ## 输入参数 ```yaml input: content: object | string # 要确认的内容(方案、结果等) format: string # 展示格式(见下方) question: string # 确认问题 options: array # 可选:预定义的选项 ``` ### format 选项 | 格式 | 说明 | 适用场景 | |------|------|----------| | `visual_summary` | 可视化摘要(emoji + 结构化) | 展示设计方案 | | `file_list_with_summary` | 文件列表 + 功能说明 | 展示执行结果 | | `comp
data-ai
# system-create-skill **用途**: 创建一个完整的 System/Project **触发**: 当用户表达想要创建一个系统时(如:"创建一个健康管理系统") **核心理念**: - 人只说意图,AI 自己设计 - 做选择题,不做填空题 - 问最关键的一题(最大信息增益) --- ## Workflow 定义 这是一个完整的 Workflow,演示了: - 条件分支 - 循环迭代 - Workflow 嵌套 - 判别式交互 ```yaml workflow: name: system-create-skill description: 创建一个完整的 System/Project version: 1.0.0 input: user_intent: string # 用户的模糊意图 output: system_path: string # 创建的系统路径 summary: object # 系统摘要 # ===============================