pipeline

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pipeline Skill

Pipeline Skill

Overview

概述

The pipeline skill enables chaining multiple agents together in defined workflows where the output of one agent becomes the input to the next. This creates powerful agent pipelines similar to Unix pipes but designed for AI agent orchestration.
Pipeline skill支持将多个Agent串联到定义好的工作流中,其中一个Agent的输出会成为下一个Agent的输入。这创建了强大的Agent流水线,类似Unix管道,但专为AI Agent编排设计。

Core Concepts

核心概念

1. Sequential Pipelines

1. 顺序流水线

The simplest form: Agent A's output flows to Agent B, which flows to Agent C.
explore -> architect -> executor
Flow:
  1. Explore agent searches codebase and produces findings
  2. Architect receives findings and produces analysis/recommendations
  3. Executor receives recommendations and implements changes
最简单的形式:Agent A的输出流向Agent B,再流向Agent C。
explore -> architect -> executor
流程:
  1. Explore Agent搜索代码库并生成发现结果
  2. Architect Agent接收发现结果并生成分析/建议
  3. Executor Agent接收建议并实施变更

2. Branching Pipelines

2. 分支流水线

Route to different agents based on output conditions.
explore -> {
  if "complex refactoring" -> architect -> executor-high
  if "simple change" -> executor-low
  if "UI work" -> designer -> executor
}
根据输出条件路由到不同的Agent。
explore -> {
  if "complex refactoring" -> architect -> executor-high
  if "simple change" -> executor-low
  if "UI work" -> designer -> executor
}

3. Parallel-Then-Merge Pipelines

3. 并行合并流水线

Run multiple agents in parallel, merge their outputs.
parallel(explore, researcher) -> architect -> executor
同时运行多个Agent,合并它们的输出。
parallel(explore, researcher) -> architect -> executor

Built-in Pipeline Presets

内置Pipeline预设

Review Pipeline

评审流水线

Purpose: Comprehensive code review and implementation
/pipeline review <task>
Stages:
  1. explore
    - Find relevant code and patterns
  2. architect
    - Analyze architecture and design implications
  3. critic
    - Review and critique the analysis
  4. executor
    - Implement with full context
Use for: Major features, refactorings, complex changes

用途: 全面的代码评审与实现
/pipeline review <task>
阶段:
  1. explore
    - 查找相关代码和模式
  2. architect
    - 分析架构和设计影响
  3. critic
    - 评审并分析结果
  4. executor
    - 结合完整上下文实施变更
适用场景: 大型功能、重构、复杂变更

Implement Pipeline

实现流水线

Purpose: Planned implementation with testing
/pipeline implement <task>
Stages:
  1. planner
    - Create detailed implementation plan
  2. executor
    - Implement the plan
  3. tdd-guide
    - Add/verify tests
Use for: New features with clear requirements

用途: 带测试的规划式实现
/pipeline implement <task>
阶段:
  1. planner
    - 创建详细的实现计划
  2. executor
    - 实施计划
  3. tdd-guide
    - 添加/验证测试
适用场景: 需求明确的新功能

Debug Pipeline

调试流水线

Purpose: Systematic debugging workflow
/pipeline debug <issue>
Stages:
  1. explore
    - Locate error locations and related code
  2. architect
    - Analyze root cause
  3. build-fixer
    - Apply fixes and verify
Use for: Bugs, build errors, test failures

用途: 系统化的调试工作流
/pipeline debug <issue>
阶段:
  1. explore
    - 定位错误位置和相关代码
  2. architect
    - 分析根本原因
  3. build-fixer
    - 应用修复并验证
适用场景: 漏洞、构建错误、测试失败

Research Pipeline

研究流水线

Purpose: External research + internal analysis
/pipeline research <topic>
Stages:
  1. parallel(researcher, explore)
    - External docs + internal code
  2. architect
    - Synthesize findings
  3. writer
    - Document recommendations
Use for: Technology decisions, API integrations

用途: 外部研究+内部分析
/pipeline research <topic>
阶段:
  1. parallel(researcher, explore)
    - 外部文档+内部代码
  2. architect
    - 整合发现结果
  3. writer
    - 记录建议内容
适用场景: 技术决策、API集成

Refactor Pipeline

重构流水线

Purpose: Safe, verified refactoring
/pipeline refactor <target>
Stages:
  1. explore
    - Find all usages and dependencies
  2. architect-medium
    - Design refactoring strategy
  3. executor-high
    - Execute refactoring
  4. qa-tester
    - Verify no regressions
Use for: Architectural changes, API redesigns

用途: 安全、可验证的重构
/pipeline refactor <target>
阶段:
  1. explore
    - 查找所有用法和依赖
  2. architect-medium
    - 设计重构策略
  3. executor-high
    - 执行重构
  4. qa-tester
    - 验证无回归问题
适用场景: 架构变更、API重新设计

Security Pipeline

安全流水线

Purpose: Security audit and fixes
/pipeline security <scope>
Stages:
  1. explore
    - Find potential vulnerabilities
  2. security-reviewer
    - Audit and identify issues
  3. executor
    - Implement fixes
  4. security-reviewer-low
    - Re-verify
Use for: Security reviews, vulnerability fixes

用途: 安全审计与修复
/pipeline security <scope>
阶段:
  1. explore
    - 查找潜在漏洞
  2. security-reviewer
    - 审计并识别问题
  3. executor
    - 实施修复
  4. security-reviewer-low
    - 重新验证
适用场景: 安全评审、漏洞修复

Custom Pipeline Syntax

自定义Pipeline语法

Basic Sequential

基础顺序结构

/pipeline agent1 -> agent2 -> agent3 "task description"
Example:
/pipeline explore -> architect -> executor "add authentication"
/pipeline agent1 -> agent2 -> agent3 "task description"
示例:
/pipeline explore -> architect -> executor "add authentication"

With Model Specification

带模型指定

/pipeline explore:haiku -> architect:opus -> executor:sonnet "optimize performance"
/pipeline explore:haiku -> architect:opus -> executor:sonnet "optimize performance"

With Branching

带分支结构

/pipeline explore -> (
  complexity:high -> architect:opus -> executor-high:opus
  complexity:medium -> executor:sonnet
  complexity:low -> executor-low:haiku
) "fix reported issues"
/pipeline explore -> (
  complexity:high -> architect:opus -> executor-high:opus
  complexity:medium -> executor:sonnet
  complexity:low -> executor-low:haiku
) "fix reported issues"

With Parallel Stages

带并行阶段

/pipeline [explore, researcher] -> architect -> executor "implement OAuth"
/pipeline [explore, researcher] -> architect -> executor "implement OAuth"

Data Passing Protocol

数据传递协议

Each agent in the pipeline receives structured context from the previous stage:
json
{
  "pipeline_context": {
    "original_task": "user's original request",
    "previous_stages": [
      {
        "agent": "explore",
        "model": "haiku",
        "findings": "...",
        "files_identified": ["src/auth.ts", "src/user.ts"]
      }
    ],
    "current_stage": "architect",
    "next_stage": "executor"
  },
  "task": "specific task for this agent"
}
流水线中的每个Agent都会接收来自上一阶段的结构化上下文:
json
{
  "pipeline_context": {
    "original_task": "user's original request",
    "previous_stages": [
      {
        "agent": "explore",
        "model": "haiku",
        "findings": "...",
        "files_identified": ["src/auth.ts", "src/user.ts"]
      }
    ],
    "current_stage": "architect",
    "next_stage": "executor"
  },
  "task": "specific task for this agent"
}

Error Handling

错误处理

Retry Logic

重试逻辑

When an agent fails, the pipeline can:
  1. Retry - Re-run the same agent (up to 3 times)
  2. Skip - Continue to next stage with partial output
  3. Abort - Stop entire pipeline
  4. Fallback - Route to alternative agent
Configuration:
/pipeline explore -> architect -> executor --retry=3 --on-error=abort
当Agent失败时,流水线可以:
  1. 重试 - 重新运行同一个Agent(最多3次)
  2. 跳过 - 携带部分输出继续到下一阶段
  3. 终止 - 停止整个流水线
  4. 降级 - 路由到备选Agent
配置:
/pipeline explore -> architect -> executor --retry=3 --on-error=abort

Error Recovery Patterns

错误恢复模式

Pattern 1: Fallback to Higher Tier
executor-low -> on-error -> executor:sonnet
Pattern 2: Consult Architect
executor -> on-error -> architect -> executor
Pattern 3: Human-in-the-Loop
any-stage -> on-error -> pause-for-user-input
模式1:降级到更高层级
executor-low -> on-error -> executor:sonnet
模式2:咨询Architect
executor -> on-error -> architect -> executor
模式3:人工介入
any-stage -> on-error -> pause-for-user-input

Pipeline State Management

流水线状态管理

Pipelines maintain state in
.omc/pipeline-state.json
:
json
{
  "pipeline_id": "uuid",
  "name": "review",
  "active": true,
  "current_stage": 2,
  "stages": [
    {
      "name": "explore",
      "agent": "explore",
      "model": "haiku",
      "status": "completed",
      "output": "..."
    },
    {
      "name": "architect",
      "agent": "architect",
      "model": "opus",
      "status": "in_progress",
      "started_at": "2026-01-23T10:30:00Z"
    },
    {
      "name": "executor",
      "agent": "executor",
      "model": "sonnet",
      "status": "pending"
    }
  ],
  "task": "original user task",
  "created_at": "2026-01-23T10:25:00Z"
}
流水线的状态会保存在
.omc/pipeline-state.json
中:
json
{
  "pipeline_id": "uuid",
  "name": "review",
  "active": true,
  "current_stage": 2,
  "stages": [
    {
      "name": "explore",
      "agent": "explore",
      "model": "haiku",
      "status": "completed",
      "output": "..."
    },
    {
      "name": "architect",
      "agent": "architect",
      "model": "opus",
      "status": "in_progress",
      "started_at": "2026-01-23T10:30:00Z"
    },
    {
      "name": "executor",
      "agent": "executor",
      "model": "sonnet",
      "status": "pending"
    }
  ],
  "task": "original user task",
  "created_at": "2026-01-23T10:25:00Z"
}

Verification Rules

验证规则

Before pipeline completion, verify:
  • All stages completed successfully
  • Output from final stage addresses original task
  • No unhandled errors in any stage
  • All files modified pass lsp_diagnostics
  • Tests pass (if applicable)
流水线完成前,需验证:
  • 所有阶段成功完成
  • 最终阶段的输出符合原始任务要求
  • 所有阶段无未处理错误
  • 所有修改的文件通过lsp_diagnostics检查
  • 测试通过(如适用)

Advanced Features

高级功能

Conditional Branching

条件分支

Based on agent output, route to different paths:
explore -> {
  if files_found > 5 -> architect:opus -> executor-high:opus
  if files_found <= 5 -> executor:sonnet
}
基于Agent的输出,路由到不同路径:
explore -> {
  if files_found > 5 -> architect:opus -> executor-high:opus
  if files_found <= 5 -> executor:sonnet
}

Loop Constructs

循环结构

Repeat stages until condition met:
repeat_until(tests_pass) {
  executor -> qa-tester
}
重复阶段直到满足条件:
repeat_until(tests_pass) {
  executor -> qa-tester
}

Merge Strategies

合并策略

When parallel agents complete:
  • concat: Concatenate all outputs
  • summarize: Use architect to summarize findings
  • vote: Use critic to choose best output
当并行Agent完成时:
  • concat: 拼接所有输出
  • summarize: 使用Architect整合发现结果
  • vote: 使用Critic选择最佳输出

Usage Examples

使用示例

Example 1: Feature Implementation

示例1:功能实现

/pipeline review "add rate limiting to API"
→ Triggers: explore → architect → critic → executor
/pipeline review "add rate limiting to API"
→ 触发:explore → architect → critic → executor

Example 2: Bug Fix

示例2:漏洞修复

/pipeline debug "login fails with OAuth"
→ Triggers: explore → architect → build-fixer
/pipeline debug "login fails with OAuth"
→ 触发:explore → architect → build-fixer

Example 3: Custom Chain

示例3:自定义链

/pipeline explore:haiku -> architect:opus -> executor:sonnet -> tdd-guide:sonnet "refactor auth module"
/pipeline explore:haiku -> architect:opus -> executor:sonnet -> tdd-guide:sonnet "refactor auth module"

Example 4: Research-Driven Implementation

示例4:研究驱动的实现

/pipeline research "implement GraphQL subscriptions"
→ Triggers: parallel(researcher, explore) → architect → writer
/pipeline research "implement GraphQL subscriptions"
→ 触发:parallel(researcher, explore) → architect → writer

Cancellation

取消

Stop active pipeline:
/pipeline cancel
Or use the general cancel command which detects active pipeline.
停止活跃的流水线:
/pipeline cancel
或使用通用取消命令,它会检测到活跃的流水线。

Integration with Other Skills

与其他Skill的集成

Pipelines can be used within other skills:
  • Ralph: Loop pipelines until verified complete
  • Ultrawork: Run multiple pipelines in parallel
  • Autopilot: Use pipelines as building blocks
流水线可在其他Skill中使用:
  • Ralph: 循环执行流水线直到验证完成
  • Ultrawork: 同时运行多个流水线
  • Autopilot: 将流水线作为构建块

Best Practices

最佳实践

  1. Start with presets - Use built-in pipelines before creating custom ones
  2. Match model to complexity - Don't waste opus on simple tasks
  3. Keep stages focused - Each agent should have one clear responsibility
  4. Use parallel stages - Run independent work simultaneously
  5. Verify at checkpoints - Use architect or critic to verify progress
  6. Document custom pipelines - Save successful patterns for reuse
  1. 从预设开始 - 在创建自定义流水线前,先使用内置流水线
  2. 匹配模型复杂度 - 不要在简单任务上浪费opus模型
  3. 保持阶段聚焦 - 每个Agent应只有一个明确的职责
  4. 使用并行阶段 - 同时运行独立的任务
  5. 在检查点验证 - 使用Architect或Critic验证进度
  6. 记录自定义流水线 - 保存成功的模式以便复用

Troubleshooting

故障排除

Pipeline Hangs

流水线挂起

Check:
.omc/pipeline-state.json
for current stage Fix: Resume with
/pipeline resume
or cancel and restart
检查:
.omc/pipeline-state.json
查看当前阶段 修复: 使用
/pipeline resume
恢复,或取消后重启

Agent Fails Repeatedly

Agent反复失败

Check: Retry count and error messages Fix: Route to higher-tier agent or add architect consultation
检查: 重试次数和错误信息 修复: 路由到更高层级的Agent,或添加Architect咨询

Output Not Flowing

输出无法传递

Check: Data passing structure in agent prompts Fix: Ensure each agent is prompted with
pipeline_context
检查: Agent提示中的数据传递结构 修复: 确保每个Agent都能获取
pipeline_context
提示

Technical Implementation

技术实现

The pipeline orchestrator:
  1. Parses pipeline definition - Validates syntax and agent names
  2. Initializes state - Creates pipeline-state.json
  3. Executes stages sequentially - Spawns agents with Task tool
  4. Passes context between stages - Structures output for next agent
  5. Handles branching logic - Evaluates conditions and routes
  6. Manages parallel execution - Spawns concurrent agents and merges
  7. Persists state - Updates state file after each stage
  8. Enforces verification - Runs checks before completion
流水线编排器:
  1. 解析流水线定义 - 验证语法和Agent名称
  2. 初始化状态 - 创建pipeline-state.json
  3. 顺序执行阶段 - 通过Task工具启动Agent
  4. 在阶段间传递上下文 - 为下一个Agent结构化输出
  5. 处理分支逻辑 - 评估条件并路由
  6. 管理并行执行 - 启动并发Agent并合并输出
  7. 持久化状态 - 每个阶段完成后更新状态文件
  8. 执行验证 - 完成前运行检查

STATE CLEANUP ON COMPLETION

完成后的状态清理

IMPORTANT: Delete state files on completion - do NOT just set
active: false
When pipeline completes (all stages done or cancelled):
bash
undefined
重要提示:完成后删除状态文件 - 不要仅设置
active: false
当流水线完成(所有阶段完成或取消):
bash
undefined

Delete pipeline state file

删除流水线状态文件

rm -f .omc/state/pipeline-state.json

This ensures clean state for future sessions. Stale state files with `active: false` should not be left behind.
rm -f .omc/state/pipeline-state.json

这确保未来会话的状态干净。不要留下设置为`active: false`的过期状态文件。

Skill Invocation

Skill调用

This skill activates when:
  • User types
    /pipeline
    command
  • User mentions "agent chain", "workflow", "pipe agents"
  • Pattern detected: "X then Y then Z" with agent names
Explicit invocation:
/oh-my-claudecode:pipeline review "task"
Auto-detection:
"First explore the codebase, then architect should analyze it, then executor implements"
→ Automatically creates pipeline: explore → architect → executor
当以下情况发生时,该Skill会激活:
  • 用户输入
    /pipeline
    命令
  • 用户提及"agent chain"、"workflow"、"pipe agents"
  • 检测到模式:包含Agent名称的"X then Y then Z"
显式调用:
/oh-my-claudecode:pipeline review "task"
自动检测:
"First explore the codebase, then architect should analyze it, then executor implements"
→ 自动创建流水线:explore → architect → executor