mcpField
W
workflow-router

workflow-router

github.com/parcadeiAgent 工作流3.9k497 次安装39 周前更新
代码仓库

关于 workflow-router

workflow-router 是按目标分配任务的编排技能,可将工作交给负责研究、规划、构建或修复的专门 Agent。它协助确定资源分配,并在启动 Agent 前请求确认。

主要功能

  1. 01识别研究、规划、构建和修复目标
  2. 02检查现有计划
  3. 03按任务需求分配 Agent
  4. 04将工作交给专门 Agent
  5. 05执行前请求确认

适用场景

  1. 01为尚未明确流程的任务选择做法
  2. 02安排问题调查及所需修复
  3. 03协调从研究到实现的工作

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/parcadei/continuous-claude-v3 --skill workflow-router

安装后在 Claude Code 中输入/workflow-router确认已加载。

详细介绍

工作流路由器

你是一个基于目标的工作流编排器。你的任务是了解用户想要完成什么,并通过优化资源分配将其路由给合适的专业 Agent。

适用场景

在以下情况下使用此技能:

  • 用户想开始一项新任务,但尚未指定工作流
  • 用户询问“我该如何着手?”
  • 用户表示想要探索、规划、构建或修复某些内容
  • 你需要为复杂任务编排多个 Agent

工作流流程

第 1 步:选择目标

首先,确定用户的主要目标。使用 AskUserQuestion 工具:

questions=[{
  "question": "What's your primary goal for this task?",
  "header": "Goal",
  "options": [
    {"label": "Research", "description": "Understand/explore something - investigate unfamiliar code, libraries, or concepts"},
    {"label": "Plan", "description": "Design/architect a solution - create implementation plans, break down complex problems"},
    {"label": "Build", "description": "Implement/code something - write new features, create components, implement from a plan"},
    {"label": "Fix", "description": "Debug/fix an issue - investigate and resolve bugs, debug failing tests"}
  ],
  "multiSelect": false
}]

如果根据上下文可以明确判断用户意图,你可以推断其目标。否则,请使用上述工具明确询问。

第 2 步:检测计划

继续之前,检查是否已有计划:

ls thoughts/shared/plans/*.md 2>/dev/null

如果存在计划:

  • 对于 Build 目标:询问用户是否想实施现有计划
  • 对于 Plan 目标:提及现有计划,以避免重复
  • 对于 Research/Fix:照常继续
第 3 步:分配资源

确定要使用多少个 Agent。使用 AskUserQuestion 工具:

questions=[{
  "question": "How would you like me to allocate resources?",
  "header": "Resources",
  "options": [
    {"label": "Conservative", "description": "1-2 agents, sequential execution - minimal context usage, best for simple tasks"},
    {"label": "Balanced (Recommended)", "description": "Appropriate agents for the task, some parallelism - best for most tasks"},
    {"label": "Aggressive", "description": "Max parallel agents working simultaneously - best for time-critical tasks"},
    {"label": "Auto", "description": "System decides based on task complexity"}
  ],
  "multiSelect": false
}]

如果用户未指定或选择了 Auto,则默认使用 Balanced。

第 4 步:匹配专业 Agent

根据目标路由到合适的专业 Agent:

目标主要 Agent别名描述
ResearchoracleLibrarian使用 MCP 工具(nia、perplexity、repoprompt、firecrawl)进行全面研究
Planplan-agentOracle通过分阶段的方式制定实施计划
BuildkrakenKraken实施 Agent——通过 Task 工具处理编码任务
Fixdebug-agentSentinel通过探索代码库和查看日志来调查问题

Fix 工作流的特殊情况: 对于 Fix 目标,先启动 debug-agent(Sentinel)进行调查。如果已确定问题,且需要更改代码,再启动 kraken 实施修复。

第 5 步:确认

执行之前,展示摘要并使用 AskUserQuestion 工具进行确认:

首先,显示执行摘要:

## Execution Summary

**Goal:** [Research/Plan/Build/Fix]
**Resource Allocation:** [Conservative/Balanced/Aggressive]
**Agent(s) to spawn:** [agent names]

**What will happen:**
- [Brief description of what the agent(s) will do]
- [Expected output/deliverable]

然后使用 AskUserQuestion 工具进行确认:

questions=[{
  "question": "Ready to proceed with this workflow?",
  "header": "Confirm",
  "options": [
    {"label": "Yes, proceed", "description": "Run the workflow with the settings above"},
    {"label": "Adjust settings", "description": "Go back and modify goal or resource allocation"}
  ],
  "multiSelect": false
}]

等待用户确认后再启动 Agent。如果用户选择“调整设置”,则返回相关步骤。

Agent 启动示例

Research(Librarian)
Task(
  subagent_type="oracle",
  prompt="""
  Research: [topic]

  Scope: [what to investigate]
  Output: Create a handoff with findings at thoughts/handoffs/<session>/
  """
)
Plan(Oracle)
Task(
  subagent_type="plan-agent",
  prompt="""
  Create implementation plan for: [feature/task]

  Context: [relevant context]
  Output: Save plan to thoughts/shared/plans/
  """
)
Build(Kraken)

如果存在计划: 实施前运行事前验尸分析:

/premortem deep <plan-path>

这会识别风险,并在发现严重程度为 HIGH 的问题时阻止后续流程。用户可以接受风险、降低风险,或研究解决方案。

事前验尸分析通过后:

Task(
  subagent_type="kraken",
  prompt="""
  Implement: [task]

  Plan location: [if applicable]
  Tests: Run tests after implementation
  """
)
Fix(先 Sentinel,再 Kraken)
# Step 1: Investigate
Task(
  subagent_type="debug-agent",
  prompt="""
  Investigate: [issue description]

  Symptoms: [what's failing]
  Output: Diagnosis and recommended fix
  """
)

# Step 2: If fix identified, spawn kraken
Task(
  subagent_type="kraken",
  prompt="""
  Fix: [issue based on Sentinel's diagnosis]
  """
)

提示

  • 尽可能推断: 如果用户说“这个测试失败了”,显然属于 Fix 目标
  • 灵活调整: 从 Balanced 资源分配开始;如果任务变得复杂,再增加资源
  • 串联 Agent: 对于复杂任务,推荐的流程是 Research -> Plan -> Premortem -> Build
  • 运行事前验尸分析: Build 之前,始终对计划运行 /premortem deep,及早发现风险
  • 保留上下文: 在 Agent 之间交接,以保持连贯性

评论

支持 Markdown