关于 workflow-orchestrator
Workflow Orchestrator 是用于协调多个 Skill 后续操作的技能,可在工作流到达里程碑、完成或出错时评估声明式钩子及宿主支持,并按风险和权限要求记录或执行操作。
主要功能
- 01检测工作流里程碑和错误
- 02读取声明式钩子元数据
- 03运行或记录受支持的后续操作
- 04区分自动、后台和需审批操作
- 05遵守宿主支持与权限边界
适用场景
- 01在技能完成后记录日志或反思任务
- 02在创建 PR 等重大操作前请求批准
- 03协调实现或 PRD 里程碑后的后续步骤
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ zhaono1/ agent-playbook --skill workflow-orchestrator安装后在 Claude Code 中输入/workflow-orchestrator确认已加载。
附带文件README.md
详细介绍
工作流编排器
一项用于协调多个技能之间工作流的技能:通过评估钩子元数据、记录待处理的后续操作,并且只运行当前宿主运行时中安全且受支持的操作。
此技能的激活时机
在以下情况应使用此技能:
- 某项技能完成其主要工作流
- 达到里程碑(PRD 完成、实现完成等)
- 用户说“完成工作流”或“结束流程”
工作方式
┌─────────────────────────────────────────────────────────────┐
│ Workflow Orchestration │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. Detect Milestone → 2. Read Hooks → 3. Record/Run Safe Follow-ups │
│ │
│ prd-planner complete │
│ ↓ │
│ workflow-orchestrator │
│ ↓ │
│ ┌─────────────────────────────────────┐ │
│ │ declared self-improving follow-up │ (record/run) │
│ │ declared session logging follow-up │ (record/run) │
│ └─────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
触发器配置
从 skills/auto-trigger/SKILL.md 读取触发器定义:
hooks:
after_complete:
- trigger: self-improving-agent
mode: background
- trigger: session-logger
mode: auto
on_error:
- trigger: self-improving-agent
mode: background
执行模式
| 模式 | 行为 | 使用场景 |
|---|---|---|
auto | 宿主支持时,运行或记录低风险的后续操作 | 日志记录、状态更新 |
background | 记录非阻塞的后续操作 | 反思、分析 |
ask_first | 执行前询问用户 | PR、部署、重大更改 |
里程碑检测
PRD 完成
Detected when:
- docs/{scope}-prd.md exists
- All phases in {scope}-prd-task-plan.md are checked
- Status shows "COMPLETE"
Actions:
1. Record self-improving-agent as a background follow-up
2. Run or record session-logger if the host supports it
实现完成
Detected when:
- All PRD requirements implemented
- Tests pass
- Code committed
Actions:
1. Ask before running code-reviewer
2. Run create-pr only when the user requested submission
3. Run or record session-logger if the host supports it
已应用自我改进
Detected when:
- Candidate validated with auditable evidence
- One named durable owner changed
- Representative behavior rerun
- Candidate recorded as applied
Actions:
1. Ask before running create-pr
2. Run or record session-logger if the host supports it
学习候选项(技能完成)
Detected when:
- A skill completes its workflow and produces reusable evidence
- User provides feedback
- Error or issue encountered
Actions:
1. Record self-improving-agent as a background follow-up
2. Run or record session-logger if the host supports it
The self-improving-agent:
- Captures a candidate only when reusable evidence exists
- Excludes raw transcripts and private tool payloads
- Keeps uncertain findings under observation
- Validates candidates only with explicit, auditable evidence
- Applies validated changes only to a named durable owner with a change reference
- Proves the representative behavior after application
错误处理(on_error)
以下情况会被检测到:
- 命令返回非零退出代码
- 遵循技能指引后测试失败
- 用户报告指引产生了错误结果
操作:
- 在后台记录 self-improving-agent,以进行自我纠正
- 运行或记录 session-logger,以捕获错误上下文
技能中的钩子实现
如需声明后续操作元数据,请在任意技能的 SKILL.md 中添加此部分:
## Auto-Trigger (After Completion)
When this skill completes, record or run supported follow-ups:
```yaml
hooks:
after_complete:
- trigger: skill-name
mode: auto|background|ask_first
context: "relevant context"
on_error:
- trigger: self-improving-agent
mode: background
当前钩子约定
钩子元数据表示声明性的意图,并不证明 CLI 自动化可用。采取行动前,请阅读当前技能的 front matter。缺少钩子意味着未声明后续操作;即使存在钩子,仍须确认宿主支持相关操作,并遵守目标操作的权限边界。
通用学习模式
┌─────────────────────────────────────────────────────────────┐
│ Skill Completes With Evidence │
└──────────────┬──────────────────────────────────────────────┘
│
↓
┌──────────────────────┐
│ workflow-orchestrator │
└──────────┬───────────┘
│
┌──────────┴─────────┐
↓ ↓
self-improving-agent session-logger
↓ ↓
Capture candidate Save bounded context
↓ ↓
Validate evidence Log session
↓
Apply to named owner
↓
create-pr (only if submission was requested)
## Workflow Examples
### Example 1: PRD Creation Workflow
用户:“为用户身份验证创建一份 PRD” ↓ prd-planner 执行 ↓ 阶段 6 完成:交付 PRD ↓ workflow-orchestrator 检测到里程碑 ↓ ┌─────────────────────────────────┐ │ 后台:self-improving-agent │ → 记录学习提案 │ 自动:session-logger │ → 宿主支持时保存会话 └─────────────────────────────────┘
### Example 2: Full Feature Workflow
用户:“创建一份 PRD 并实现它” ↓ prd-planner → workflow-orchestrator ↓ self-improving-agent(仅捕获候选项) ↓ prd-implementation-precheck ↓ 实现完成 → workflow-orchestrator ↓ code-reviewer → 可选的候选项捕获 ↓ create-pr(仅在收到请求时)→ workflow-orchestrator ↓ session-logger
Each milestone can produce a `self-improving-agent` follow-up, but durable
skill edits still require validation or explicit approval.
## Implementation Steps
### Step 1: Detect Milestone
Check for completion indicators:
```bash
# PRD complete?
grep -q "COMPLETE" docs/{scope}-prd-task-plan.md
# All phases checked?
grep -q "^\- \[x\].*Phase 6" docs/{scope}-prd-task-plan.md
# PRD file exists?
ls docs/{scope}-prd.md
步骤 2:读取触发器配置
# Read hooks from auto-trigger skill
cat skills/auto-trigger/SKILL.md
步骤 3:记录或执行钩子
按顺序处理每个钩子(before_start、after_complete、on_error):
- 检查是否满足条件
- 根据模式和宿主支持情况记录或执行
- 将上下文传递给触发的技能
- 根据模式等待或继续
步骤 4:更新状态
记录触发的内容及结果:
## Workflow Execution
- [x] self-improving-agent (background) - Started
- [x] session-logger (auto) - Session saved
- [ ] create-pr (ask_first) - Pending user approval
配置了自动触发器的技能
| 技能 | 触发时机 |
|---|---|
prd-planner | self-improving-agent、session-logger |
self-improving-agent | 不自动创建 PR;已应用的更改可以声明日志记录后续操作 |
prd-implementation-precheck | self-improving-agent、session-logger |
code-reviewer | self-improving-agent、session-logger |
create-pr | session-logger |
refactoring-specialist | self-improving-agent、session-logger |
debugger | self-improving-agent、session-logger |
为现有技能添加后续操作元数据
如需为现有技能添加后续操作元数据,请在其 SKILL.md 末尾添加:
---
## Auto-Trigger
When this skill completes, record or run supported follow-ups:
```yaml
hooks:
after_complete:
- trigger: session-logger
mode: auto
context: "Save session context"
For more complex triggers, specify mode and context:
```markdown
## Auto-Trigger
When this skill completes:
```yaml
hooks:
after_complete:
- trigger: next-skill
mode: background
context: "Description"
- trigger: session-logger
mode: auto
context: "Save session"
- trigger: create-pr
mode: ask_first
context: "Create PR if files modified"
on_error:
- trigger: self-improving-agent
mode: background
## Best Practices
1. **Log only when supported and appropriate** - Session logging is a bounded optional follow-up
2. **Ask before major actions** - PRs, deployments, destructive changes
3. **Background for analysis** - Reflection, evaluation, optimization
4. **Auto for status** - Logging, status updates, bookmarks
5. **Don't create loops** - Ensure chains terminate