Skill Seekers 自定义工作流(Custom Workflows)完全指南:用 YAML 编排多阶段 AI 增强流水线
2026/9/23 2:49:19 网站建设 项目流程

Skill Seekers 自定义工作流(Custom Workflows)完全指南:用 YAML 编排多阶段 AI 增强流水线

【免费下载链接】Skill_SeekersConvert documentation websites, GitHub repositories, and PDFs into Claude AI skills with automatic conflict detection项目地址: https://gitcode.com/gh_mirrors/sk/Skill_Seekers

本文面向 Skill Seekers v3.9.0。工作流(Workflow)是 Skill Seekers 中用于驱动 SKILL 生成与增强的 YAML 多阶段流水线:通过内置或自定义提示词,把抓取/分析得到的原始资料逐级加工成高质量的 Claude AI Skill 文档。读完本文,你将掌握工作流的 YAML 结构、全部字段语义、内置 70+ 预置工作流、运行时变量覆盖、阶段间历史传递、workflows子命令全量用法,以及从性能分析到安全审查的完整落地范式。

什么是自定义工作流?

工作流是YAML 定义的多阶段 AI 增强流水线。一个工作流文件把若干"阶段"(stage)串联起来:每个阶段负责对 Skill 文档的某个部分执行一次 AI 增强,后一个阶段可以消费前一个阶段的输出,从而把简单的"一次性增强"升级为"分层加工"。

从源码看,工作流引擎的核心位于 enhancement_workflow.py:EnhancementWorkflow数据类描述整个工作流,WorkflowStage描述单个阶段,WorkflowEngine负责加载、校验与顺序执行。所有 scrapers(doc_scrapergithub_scraperpdf_scrapercodebase_scraper等)都通过 workflow_runner.py 中的统一run_workflows()函数消费 CLI 传入的工作流参数,意味着任何来源的抓取结果都可以挂接自定义工作流

一个工作流文件的顶层结构如下:

my-workflow.yaml ├── name ├── description ├── variables (optional) └── stages (1-10) ├── name ├── type (builtin/custom) ├── target (skill_md/references/) ├── prompt └── uses_history (optional)

说明:stages数量限制为 1~10 个;target在文档中给出skill_md/references两个面向产物文件的取值,而在引擎内部还支持更细粒度的分析数据目标(patternsexamplesall等,见下文"目标(target)"一节)。

基本工作流结构

最小可用工作流如下,包含一个内置阶段和一个自定义阶段:

name: my-custom description: Custom enhancement workflow stages: - name: stage-one type: builtin target: skill_md prompt: | Improve the SKILL.md by adding... - name: stage-two type: custom target: references prompt: | Enhance the references by...
  • stage-one使用内置增强逻辑修改主 SKILL.md;
  • stage-two使用自定义提示词增强 references 参考文件。

引擎会按 YAML 中的顺序依次执行各阶段(enhancement_workflow.py),任一阶段失败不会中断整个工作流,而是记录错误后继续执行后续阶段。

工作流字段

顶层字段

字段必需描述
name工作流标识符,也是--enhance-workflow引用的名称
description人类可读的描述,会显示在workflows list输出中
variables可配置变量,可在运行时用--var覆盖
stages阶段定义数组,1~10 个

除文档列出的四个顶层字段外,从源码(enhancement_workflow.py)还可以看到引擎支持以下扩展字段:

字段必需描述
version工作流版本号,默认"1.0"
applies_to适用场景(如codebase_analysisgithub_analysis),默认["codebase_analysis"]
post_process后处理配置:remove_sectionsreorder_sectionsadd_metadatacustom_transforms
extends继承另一个工作流(按阶段名覆盖父级)

阶段字段

字段必需描述
name阶段标识符,可通过{stages[名字]}在后续阶段引用其输出
typebuiltincustom
target本阶段写入的目标:skill_mdreferences
promptAI 提示文本,可使用{变量}与历史占位符
uses_history是否访问前一阶段结果,默认false

引擎在解析阶段时(enhancement_workflow.py)还会读取两个可选字段:enabled(是否启用该阶段,默认true,可用于临时停用阶段而不删除)与metadata(附加到阶段执行历史的任意字典)。

创建你的第一个工作流

示例:性能分析

以下performance.yaml展示了一个双阶段工作流:先用内置阶段在 SKILL.md 中补充性能总览,再用自定义阶段生成一份引用运行时变量、并消费历史结果的优化指南:

# performance.yaml name: performance-focus description: Analyze and document performance characteristics variables: target_latency: "100ms" target_throughput: "1000 req/s" stages: - name: performance-overview type: builtin target: skill_md prompt: | Add a "Performance" section to SKILL.md covering: - Benchmark results - Performance characteristics - Resource requirements - name: optimization-guide type: custom target: references uses_history: true prompt: | Create an optimization guide with: - Target latency: {target_latency} - Target throughput: {target_throughput} - Common bottlenecks - Optimization techniques

安装与使用

# 添加工作流(安装到 ~/.config/skill-seekers/workflows/) skill-seekers workflows add performance.yaml # 使用它 skill-seekers create <source> --enhance-workflow performance-focus # 使用自定义变量覆盖默认值 skill-seekers create <source> \ --enhance-workflow performance-focus \ --var target_latency=50ms \ --var target_throughput=5000req/s

--enhance-workflow既可以按名称引用已安装/内置工作流,也可以直接传 YAML 文件路径。参数定义见 arguments/workflow.py。引擎加载时按三级查找顺序解析工作流(enhancement_workflow.py):

  1. 原始文件路径(绝对路径或相对当前目录);
  2. 用户目录~/.config/skill-seekers/workflows/{name}.yaml
  3. 包内内置工作流skill_seekers/workflows/{name}.yaml(通过importlib.resources读取)。

workflows add在安装前会做基础校验(YAML 根必须是映射且必须包含stages键),并把文件复制到用户目录(workflows_command.py);同名覆盖会输出Warning

阶段类型(Stage Types)

builtin:复用内置增强逻辑

builtin阶段不直接调用 AI 生成,而是复用项目内置的增强器。当targetpatterns时调用PatternEnhancer.enhance_patterns(),为examples时调用TestExampleEnhancer.enhance_examples()(enhancement_workflow.py):

stages: - name: structure-improvement type: builtin target: skill_md prompt: "Improve document structure"

注意:builtin阶段主要面向分析数据(patterns/examples),当目标数据在当前结果中不存在时会跳过该阶段并输出提示日志。

custom:完全自定义提示控制

custom阶段将prompt模板用当前上下文格式化后交给 AI 增强器执行(enhancement_workflow.py)。提示中可直接使用{variables}{history}相关占位符:

stages: - name: custom-analysis type: custom target: skill_md prompt: | Your detailed custom prompt here... Can use {variables} and {history}
  • 格式化使用 Python 的str.format(),缺失变量不会崩溃,而是记录警告并退回原始提示文本;
  • AI 响应优先按 JSON 解析(json.loads),解析失败则把整段文本作为{"content": ..., "stage": ...}返回;
  • 调用走 agent 无关的AIEnhancer.call()max_tokens=3000),旧版增强器回退到_call_claude()

快速内联阶段(--enhance-stage)

不想新建 YAML 文件时,可用--enhance-stage 'name:prompt'直接注入自定义阶段,多个 flag 会被合并成一个名为inline_workflow的内联工作流(workflow_runner.py):

skill-seekers create <source> \ --enhance-stage "security:Analyze for security issues" \ --enhance-stage "cleanup:Remove boilerplate sections"

目标(Targets)

target决定本阶段的增强结果写入哪里。

skill_md

增强主 SKILL.md 文件(面向最终产物):

stages: - name: improve-skill target: skill_md prompt: "Add comprehensive overview section"

references

增强参考文件(如 references 目录下的补充文档、跨文件交叉引用等):

stages: - name: improve-refs target: references prompt: "Add cross-references between files"

引擎内部的分析数据目标

从源码看,target在引擎层面还有更细的取值(enhancement_workflow.py):

target行为
all阶段结果整体合并进当前结果({**current, **stage_results}
patterns只更新 patterns 数据,通常配合builtin使用
examples只更新 examples 数据,通常配合builtin使用
其他任意键将阶段结果写入当前结果的该键名下

内置工作流security-focus.yaml就用到了target: securitytarget: auth这类自定义键(见 workflows/security-focus.yaml),把不同阶段的产出分别归入独立分区,方便后续引用。

变量(Variables)

定义变量

variables: audience: "beginners" focus_area: "security" include_examples: true

变量支持字符串、布尔值等 YAML 标量;运行时可通过--var key=value覆盖。

使用变量

在任意阶段的prompt中用{变量名}引用:

stages: - name: customize prompt: | Tailor content for {audience}. Focus on {focus_area}. Include examples: {include_examples}

运行时覆盖

skill-seekers create <source> \ --enhance-workflow my-workflow \ --var audience=experts \ --var focus_area=performance

变量合并的优先级从低到高为:引擎注入的 scraper 上下文(如 GitHub 元数据)→ 配置文件workflow_vars→ 工作流文件内的variables→ 命令行--var(最高优先级),实现见 workflow_runner.py。即:--var永远能覆盖文件默认值

历史传递(History Passing)

阶段可以通过uses_history: true读取此前所有阶段的产出。引擎构建阶段上下文时(enhancement_workflow.py)会注入三类历史占位符:

占位符含义
{previous_results}最近一个已完成阶段的结果
{all_history}全部历史记录(含 stage 名、结果、时间戳、metadata)
{stages[阶段名]}按阶段名精确索引某一次结果
stages: - name: analyze type: custom target: skill_md prompt: "Analyze security features" - name: document type: custom target: skill_md uses_history: true prompt: | Based on previous analysis: {previous_results} Create documentation...

高级示例:安全审查

组合variablesuses_history与多目标,可以搭建"资产盘点 → 威胁分析 → 缓解指南"的三阶段安全流水线:

name: comprehensive-security description: Multi-stage security analysis variables: compliance_framework: "OWASP Top 10" risk_level: "high" stages: - name: asset-inventory type: builtin target: skill_md prompt: | Document all security-sensitive components: - Authentication mechanisms - Authorization checks - Data validation - Encryption usage - name: threat-analysis type: custom target: skill_md uses_history: true prompt: | Based on assets: {all_history} Analyze threats for {compliance_framework}: - Threat vectors - Attack scenarios - Risk ratings ({risk_level} focus) - name: mitigation-guide type: custom target: references uses_history: true prompt: | Create mitigation guide: - Countermeasures - Best practices - Code examples - Testing strategies

仓库内置的 security-focus.yaml 是同类思路的真实模板:它包含提示注入扫描(injection_scan)、基础模式增强(base_patterns,builtin)、OWASP 漏洞分析(vulnerabilities)与认证授权审查(auth_review)四个阶段,并通过post_process.add_metadata向最终产物写入enhanced: trueworkflow: security-focussecurity_reviewed: true元数据。

验证(Validation)

安装前验证

skill-seekers workflows validate ./my-workflow.yaml

validate通过WorkflowEngine实际解析文件(支持传路径或已安装工作流名称),成功时输出工作流名称、描述、版本与每个阶段的类型/启用状态(workflows_command.py)。

常见错误

错误原因修复
Missing 'stages'无 stages 数组添加stages:
Invalid type不是 builtin/custom检查type字段
Undefined variable已使用但未定义添加到variables:

workflows add安装时也会执行同样的stages键校验,未通过的文件不会被安装(workflows_command.py)。

内置工作流与 workflows 子命令

预置工作流

仓库自带 70+ 内置工作流(workflows 目录),覆盖广泛主题:security-focus(安全审查)、performance-optimization(性能)、architecture-comprehensive(架构)、api-documentation(API 文档)、kubernetes-deploymentmessage-queuesvector-databasesgraphql-schemamicroservices-patternscompliance-gdprtesting-focusobservability-stack等,另有default.yamlminimal.yaml作为基础模板。

内置工作流是只读的,无法直接remove;如需定制,先复制到用户目录再编辑(见下文copy)。

workflows 子命令全量用法

skill-seekers workflows子命令定义在 workflows_command.py:

# 列出所有工作流(内置 + 用户,附带描述) skill-seekers workflows list # 打印某个工作流的 YAML 内容(按名称或路径) skill-seekers workflows show my-workflow # 复制内置工作流到用户目录以便编辑 skill-seekers workflows copy security-focus # 安装自定义 YAML 工作流(--name 可重命名,单文件时可用) skill-seekers workflows add ./my-workflow.yaml skill-seekers workflows add ./my-workflow.yaml --name custom-name # 删除用户工作流(内置工作流会被拒绝) skill-seekers workflows remove my-workflow # 校验工作流 skill-seekers workflows validate security-focus

要点(均有测试覆盖,见 test_workflows_command.py):

  • copy支持一次复制多个,且同名已存在时覆盖并告警;目标写入~/.config/skill-seekers/workflows/
  • add支持一次安装多个文件(此时不能用--name),单个文件校验失败不影响其余文件安装,但进程以非零码退出;
  • remove对内置工作流报错并提示先copy
  • show/validate均可直接接受文件路径,解析顺序与引擎的三级查找一致。

最佳实践

1. 从简单开始

先写 1~2 个阶段的工作流验证效果,再逐步叠加:

# Start with 1-2 stages name: simple description: Simple workflow stages: - name: improve type: builtin target: skill_md prompt: "Improve SKILL.md"

2. 使用清晰的阶段名称

阶段名同时是{stages[...]}历史索引的键,可读性直接影响后续阶段的引用体验:

# Good stages: - name: security-overview - name: vulnerability-analysis # Bad stages: - name: stage1 - name: step2

3. 记录变量

variables中为每个键写注释,说明取值范围,方便团队复用:

variables: # Target audience level: beginner, intermediate, expert audience: "intermediate" # Security focus area: owasp, pci, hipaa compliance: "owasp"

4. 增量测试:先用干运行

--workflow-dry-run会预览所有阶段与将注入的变量而不执行任何 AI 调用、不修改文件(workflow_runner.py):

# Test with dry run skill-seekers create <source> \ --enhance-workflow my-workflow \ --workflow-dry-run # Then actually run skill-seekers create <source> \ --enhance-workflow my-workflow

干运行预览结束后进程直接退出并提示 "Dry run complete! No changes made."。

5. 链式调用以进行复杂分析

--enhance-workflow可重复使用,多个工作流按给定顺序依次执行(前一个完成后立即执行下一个),并在日志中输出"Chaining N workflow(s) in sequence":

# Use multiple workflows skill-seekers create <source> \ --enhance-workflow security-focus \ --enhance-workflow performance-focus

也可以混合使用--enhance-workflow--enhance-stage:先依次运行命名工作流,再运行合并后的内联工作流(workflow_runner.py)。单个工作流加载失败不会中断后续工作流(跳过并继续),但--workflow-dry-run会贯穿所有工作流的预览。

6. 使用继承复用现有工作流

若多个工作流共享相同的前置阶段,可用extends继承父工作流:子级按阶段名覆盖父级阶段,variablesadd_metadata深合并,custom_transforms拼接(enhancement_workflow.py)。

共享工作流

导出工作流

# Get workflow content skill-seekers workflows show my-workflow > my-workflow.yaml

show同样支持按名称或路径解析,非常适合把已安装的工作流导出为文件。

与团队共享

# Add to version control git add my-workflow.yaml git commit -m "Add custom security workflow" # Team members install skill-seekers workflows add my-workflow.yaml

配合workflows list/workflows validate,可以让团队成员先查看可用工作流、再安装与校验,降低出错概率。

发布

可以把成熟的工作流提交到 Skill Seekers 社区:GitHub Discussions、Skill Seekers 网站以及文档贡献渠道。

通过配置文件与 MCP 使用工作流

除了 CLI 参数,工作流也可以在配置文件中声明:配置文件中的workflow_vars会进入变量合并链(优先级低于--var),配置文件声明的enhancement.workflowsenhancement.stages会通过ExecutionContext在无 CLI flag 时自动生效(execution_context.py、workflow_runner.py)。统一抓取器在 Phase 5 执行配置文件工作流时,会以use_context_fallback=False避免重复执行(unified_scraper.py)。工作流同样可通过 MCP 工具调用,详见 MCP 参考。

另请参阅

  • 工作流指南 —— 工作流的基础使用流程
  • 增强指南 —— 增强(Enhancement)基础概念
  • MCP 参考 —— 通过 MCP 使用工作流
  • 增强功能说明 —— 增强模式与工作流的关系
  • 测试用例 与 workflow runner 测试 —— workflows 子命令与执行链的行为验证

【免费下载链接】Skill_SeekersConvert documentation websites, GitHub repositories, and PDFs into Claude AI skills with automatic conflict detection项目地址: https://gitcode.com/gh_mirrors/sk/Skill_Seekers

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询