创建、管理和执行自定义工作流,支持多步骤任务编排、并行执行和条件触发
Automate multi-step tasks with sequential, parallel, and conditional workflows. Use this to create recurring SEO audits, batch content analysis, or complex task chains that run automatically or on-demand.
/plugin marketplace add huifer/claude-code-seo/plugin install huifer-claude-seo-assistant@huifer/claude-code-seo<action> [--workflow <workflow-name>] [--file <workflow-file>] [--trigger <trigger-type>]工作流是多个任务的有序编排,支持:
name: "comprehensive-geo-workflow"
description: "完整的 GEO 优化工作流"
version: "1.0.0"
author: "SEO Team"
created: "2024-02-15"
# 触发器配置
triggers:
- type: "schedule"
cron: "0 9 * * 1" # 每周一上午 9:00
enabled: true
- type: "event"
event: "competitor-surpassed"
enabled: true
- type: "manual"
enabled: true
# 全局变量
variables:
domain: "yoursite.com"
competitors: "comp1.com,comp2.com,comp3.com"
team_email: "seo-team@company.com"
slack_channel: "#seo-alerts"
# 全局配置
config:
timeout: 3600 # 总超时时间(秒)
retry_on_failure: true
max_retries: 3
parallel_tasks: 5
notify_on_complete: true
# 工作流步骤
steps:
# 第一步:内容审计
- id: audit
name: "GEO 内容审计"
description: "对网站进行全面的内容审计"
command: "/geo-content-audit"
params:
domain: "{{variables.domain}}"
detailed: true
timeout: 300
retry: 3
on_success: citation-monitor
on_failure: notify-error
continue_on_failure: false
# 第二步:引用监控
- id: citation-monitor
name: "AI 引用监控"
description: "监控 AI 搜索引擎的引用情况"
command: "/geo-citation-monitor"
params:
url: "https://{{variables.domain}}"
period: 7
timeout: 180
retry: 2
depends_on: audit
on_success: competitor-compare
on_failure: notify-error
# 第三步:竞争对手对比
- id: competitor-compare
name: "竞争对手对比"
description: "对比分析竞争对手表现"
command: "/geo-competitor-compare"
params:
you: "{{variables.domain}}"
competitors: "{{variables.competitors}}"
timeout: 240
retry: 2
depends_on: citation-monitor
on_success: generate-report
on_failure: notify-error
# 第四步:生成报告(并行)
- id: generate-report
name: "生成综合报告"
description: "生成多格式 GEO 综合报告"
parallel:
# 子步骤 4a:执行摘要
- id: exec-summary
name: "生成执行摘要"
command: "/generate-report"
params:
type: "executive-summary"
domain: "{{variables.domain}}"
period: 30
format: "pdf"
timeout: 120
on_complete: send-report
# 子步骤 4b:技术分析
- id: tech-analysis
name: "生成技术分析"
command: "/generate-report"
params:
type: "technical-analysis"
domain: "{{variables.domain}}"
format: "html"
include-charts: true
timeout: 180
on_complete: send-report
# 子步骤 4c:交互式报告
- id: interactive-report
name: "生成交互式报告"
command: "/generate-report"
params:
type: "geo-comprehensive"
domain: "{{variables.domain}}"
period: 30
format: "html"
interactive: true
timeout: 150
on_complete: send-report
# 第五步:发送报告
- id: send-report
name: "发送报告给团队"
description: "通过邮件发送生成的报告"
action: "send_email"
params:
to: "{{variables.team_email}}"
subject: "📊 GEO 综合报告 - {{date}}"
body: |
亲爱的团队,
附件是最新的 GEO 综合报告,包含以下内容:
1. 执行摘要(PDF)
2. 技术分析(HTML)
3. 交互式报告(HTML)
主要发现:
- 整体 GEO 评分:72/100
- AI 引用次数:677(+45%)
- 行业排名:Top 10%
请查看附件了解详情。
祝好,
SEO Assistant
attachments:
- "{{steps.exec-summary.output}}"
- "{{steps.tech-analysis.output}}"
- "{{steps.interactive-report.output}}"
timeout: 60
depends_on: generate-report
on_success: notify-success
on_failure: notify-error
# 错误处理
- id: notify-error
name: "发送错误通知"
description: "工作流执行失败时发送通知"
action: "send_slack"
params:
channel: "{{variables.slack_channel}}"
message: |
❌ 工作流执行失败
工作流:{{workflow.name}}
失败步骤:{{failed_step.name}}
错误信息:{{error.message}}
时间:{{timestamp}}
请立即检查!
priority: "high"
# 成功通知
- id: notify-success
name: "发送成功通知"
description: "工作流执行成功时发送通知"
action: "send_slack"
params:
channel: "{{variables.slack_channel}}"
message: |
✅ 工作流执行成功
工作流:{{workflow.name}}
执行时间:{{duration}}
生成报告:{{report_count}}
时间:{{timestamp}}
priority: "info"
# 工作流输出
output:
format: "json"
path: ".claude-flow/cache/workflows/{{workflow.name}}/{{timestamp}}.json"
include:
- execution_summary
- step_outputs
- alerts
- metrics
任务按定义的顺序依次执行:
name: "sequential-content-audit"
steps:
- id: step1
name: "第一步"
command: "/command1"
on_success: step2
- id: step2
name: "第二步"
command: "/command2"
depends_on: step1
on_success: step3
- id: step3
name: "第三步"
command: "/command3"
depends_on: step2
多个任务同时执行:
name: "parallel-content-audit"
steps:
- id: parallel-audit
parallel:
- id: blog-audit
name: "审计博客文章"
command: "/geo-content-audit"
params:
path: "/blog"
- id: product-audit
name: "审计产品页面"
command: "/geo-content-audit"
params:
path: "/products"
- id: case-audit
name: "审计案例研究"
command: "/geo-content-audit"
params:
path: "/case-studies"
# 所有并行任务完成后继续
on_complete: aggregate-results
根据条件执行不同路径:
name: "conditional-workflow"
steps:
- id: check-score
name: "检查 GEO 评分"
action: "check_condition"
params:
condition: "geo-score < 70"
# 如果评分 < 70
on_true: optimize-content
# 如果评分 >= 70
on_false: generate-report
- id: optimize-content
name: "优化内容"
command: "/optimize-content"
condition: "{{check-score.result}} == true"
- id: generate-report
name: "生成报告"
command: "/generate-report"
condition: "{{check-score.result}} == false"
重复执行任务直到满足条件:
name: "iterative-optimization"
steps:
- id: optimize-loop
name: "迭代优化循环"
loop:
max_iterations: 5
until: "geo-score >= 85"
steps:
- id: audit
name: "审计内容"
command: "/geo-content-audit"
- id: optimize
name: "优化内容"
command: "/optimize-content"
depends_on: audit
- id: check
name: "检查是否达标"
action: "check_score"
target: 85
# 从文件创建工作流
/workflow-automation create \
--workflow comprehensive-geo \
--file workflow.yaml
# 从模板创建工作流
/workflow-automation create \
--workflow weekly-audit \
--template weekly-audit
# 立即执行工作流
/workflow-automation execute --workflow comprehensive-geo
# 带参数执行
/workflow-automation execute \
--workflow comprehensive-geo \
--params domain=test.com,competitors=comp1.com
# 后台执行
/workflow-automation execute \
--workflow comprehensive-geo \
--background
# 列出所有工作流
/workflow-automation list
# 列出活跃工作流
/workflow-automation list --status active
# 查看工作流状态
/workflow-automation status --workflow comprehensive-geo
# 查看工作流执行历史
/workflow-automation history --workflow comprehensive-geo --limit 10
# 删除工作流
/workflow-automation delete --workflow old-workflow
# ✅ 工作流创建成功
**工作流名称:** comprehensive-geo
**版本:** 1.0.0
**创建时间:** 2024-02-15 15:30
## 工作流配置
### 基本信息
- **描述:** 完整的 GEO 优化工作流
- **作者:** SEO Team
- **步骤数量:** 7 个
- **预计耗时:** ~20 分钟
### 触发器
1. 🕐 定时触发:每周一上午 9:00
2. 🎯 事件触发:竞争对手超越
3. 🖱️ 手动触发:支持
### 执行步骤
1. GEO 内容审计
2. AI 引用监控
3. 竞争对手对比
4. 生成报告(并行 3 个子任务)
5. 发送报告
### 错误处理
- ✅ 失败重试:最多 3 次
- ✅ 错误通知:Slack + 邮件
- ✅ 继续执行:否(遇到错误停止)
### 通知配置
- ✅ 成功通知:Slack #seo-reports
- 🔴 失败通知:Slack #seo-critical + 邮件
## 保存位置
`.claude-flow/cache/workflows/comprehensive-geo/workflow.yaml`
## 立即执行
```bash
/workflow-automation execute --workflow comprehensive-geo
实时监控:
http://localhost:3000/workflows/comprehensive-geo
创建时间: 2024-02-15 15:30 状态: 🟢 已启用
### 工作流状态输出
```markdown
# 📊 工作流状态:comprehensive-geo
## 基本信息
- **名称:** comprehensive-geo
- **版本:** 1.0.0
- **状态:** 🟢 运行中
- **创建时间:** 2024-02-15 15:30
## 当前执行
- **执行ID:** exec-20240215-153000
- **开始时间:** 2024-02-15 15:30
- **当前步骤:** generate-report
- **进度:** 60% (3/5 完成)
- **耗时:** 12 分钟
## 步骤执行情况
| 步骤 | 状态 | 耗时 | 输出 |
|------|------|------|------|
| audit | ✅ | 4:45 | report-001.json |
| citation-monitor | ✅ | 2:48 | 677 citations |
| competitor-compare | ✅ | 3:52 | ranked #1 |
| generate-report | 🔄 | - | - |
| send-report | ⏳ | - | - |
## 下次执行
- **调度时间:** 2024-02-22 09:00
- **触发方式:** 定时触发
- **倒计时:** 6 天 17 小时
## 执行统计
- **总执行次数:** 12
- **成功次数:** 11 (92%)
- **失败次数:** 1 (8%)
- **平均耗时:** 18 分钟
## 最近执行历史
| 执行ID | 时间 | 状态 | 耗时 |
|--------|------|------|------|
| exec-20240215 | 15:30 | 🔄 | - |
| exec-20240208 | 09:00 | ✅ | 17:23 |
| exec-20240201 | 09:00 | ✅ | 18:45 |
| exec-20240125 | 09:00 | ❌ | - |
## 管理操作
- 停止:`/workflow-automation stop --workflow comprehensive-geo`
- 重启:`/workflow-automation restart --workflow comprehensive-geo`
- 查看:`/workflow-automation logs --workflow comprehensive-geo`
---
**查询时间:** 2024-02-15 15:42
**数据来源:** 工作流执行引擎
模板名称: quick-start-workflow
name: "quick-start"
description: "快速启动工作流模板"
version: "1.0.0"
triggers:
- type: "manual"
enabled: true
variables:
domain: "your-domain.com"
steps:
- id: audit
name: "快速审计"
command: "/geo-content-audit"
params:
domain: "{{variables.domain}}"
timeout: 180
- id: report
name: "生成报告"
command: "/generate-report"
params:
type: "executive-summary"
domain: "{{variables.domain}}"
timeout: 120
模板名称: weekly-audit-template
name: "weekly-audit"
description: "每周 GEO 审计工作流"
version: "1.0.0"
triggers:
- type: "schedule"
cron: "0 9 * * 1"
enabled: true
steps:
- id: audit
name: "内容审计"
command: "/geo-content-audit"
timeout: 300
- id: monitor
name: "引用监控"
command: "/geo-citation-monitor"
timeout: 180
- id: report
name: "生成报告"
command: "/generate-report"
timeout: 120
variables:
# 域名配置
domain: "yoursite.com"
base_url: "https://{{domain}}"
# 竞争对手
competitors:
- "comp1.com"
- "comp2.com"
- "comp3.com"
# 团队信息
team_email: "seo-team@company.com"
slack_channel: "#seo-alerts"
# API 密钥
openai_key: "{{OPENAI_API_KEY}}"
anthropic_key: "{{ANTHROPIC_API_KEY}}"
# 文件路径
output_dir: ".claude-flow/cache/reports"
log_dir: ".claude-flow/cache/logs"
在步骤中引用变量:
steps:
- id: audit
name: "审计 {{variables.domain}}"
command: "/geo-content-audit"
params:
domain: "{{variables.domain}}" # yoursite.com
url: "{{variables.base_url}}" # https://yoursite.com
competitors: "{{variables.competitors}}" # ["comp1.com", "comp2.com"]
.claude-flow/cache/workflows/
├── comprehensive-geo/
│ ├── workflow.yaml # 工作流定义
│ ├── config.json # 配置文件
│ └── variables.json # 变量文件
└── weekly-audit/
├── workflow.yaml
├── config.json
└── variables.json
.claude-flow/cache/history/workflows/
├── comprehensive-geo/
│ ├── exec-20240215-153000.json
│ ├── exec-20240208-090000.json
│ └── exec-20240201-090000.json
└── weekly-audit/
├── exec-20240215.json
└── exec-20240208.json
.claude-flow/cache/logs/workflows/
├── comprehensive-geo/
│ ├── 2024-02-15.log
│ └── 2024-02-08.log
└── weekly-audit/
├── 2024-02-15.log
└── 2024-02-08.log
/geo-automation - 自动化任务配置/generate-report - 生成各类报告命令版本: 1.0.0 最后更新: 2024-02-15 维护者: automation-coordinator skill