pipeline
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePipeline 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 -> executorFlow:
- Explore agent searches codebase and produces findings
- Architect receives findings and produces analysis/recommendations
- Executor receives recommendations and implements changes
最简单的形式:Agent A的输出流向Agent B,再流向Agent C。
explore -> architect -> executor流程:
- Explore Agent搜索代码库并生成发现结果
- Architect Agent接收发现结果并生成分析/建议
- 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 -> executorBuilt-in Pipeline Presets
内置Pipeline预设
Review Pipeline
评审流水线
Purpose: Comprehensive code review and implementation
/pipeline review <task>Stages:
- - Find relevant code and patterns
explore - - Analyze architecture and design implications
architect - - Review and critique the analysis
critic - - Implement with full context
executor
Use for: Major features, refactorings, complex changes
用途: 全面的代码评审与实现
/pipeline review <task>阶段:
- - 查找相关代码和模式
explore - - 分析架构和设计影响
architect - - 评审并分析结果
critic - - 结合完整上下文实施变更
executor
适用场景: 大型功能、重构、复杂变更
Implement Pipeline
实现流水线
Purpose: Planned implementation with testing
/pipeline implement <task>Stages:
- - Create detailed implementation plan
planner - - Implement the plan
executor - - Add/verify tests
tdd-guide
Use for: New features with clear requirements
用途: 带测试的规划式实现
/pipeline implement <task>阶段:
- - 创建详细的实现计划
planner - - 实施计划
executor - - 添加/验证测试
tdd-guide
适用场景: 需求明确的新功能
Debug Pipeline
调试流水线
Purpose: Systematic debugging workflow
/pipeline debug <issue>Stages:
- - Locate error locations and related code
explore - - Analyze root cause
architect - - Apply fixes and verify
build-fixer
Use for: Bugs, build errors, test failures
用途: 系统化的调试工作流
/pipeline debug <issue>阶段:
- - 定位错误位置和相关代码
explore - - 分析根本原因
architect - - 应用修复并验证
build-fixer
适用场景: 漏洞、构建错误、测试失败
Research Pipeline
研究流水线
Purpose: External research + internal analysis
/pipeline research <topic>Stages:
- - External docs + internal code
parallel(researcher, explore) - - Synthesize findings
architect - - Document recommendations
writer
Use for: Technology decisions, API integrations
用途: 外部研究+内部分析
/pipeline research <topic>阶段:
- - 外部文档+内部代码
parallel(researcher, explore) - - 整合发现结果
architect - - 记录建议内容
writer
适用场景: 技术决策、API集成
Refactor Pipeline
重构流水线
Purpose: Safe, verified refactoring
/pipeline refactor <target>Stages:
- - Find all usages and dependencies
explore - - Design refactoring strategy
architect-medium - - Execute refactoring
executor-high - - Verify no regressions
qa-tester
Use for: Architectural changes, API redesigns
用途: 安全、可验证的重构
/pipeline refactor <target>阶段:
- - 查找所有用法和依赖
explore - - 设计重构策略
architect-medium - - 执行重构
executor-high - - 验证无回归问题
qa-tester
适用场景: 架构变更、API重新设计
Security Pipeline
安全流水线
Purpose: Security audit and fixes
/pipeline security <scope>Stages:
- - Find potential vulnerabilities
explore - - Audit and identify issues
security-reviewer - - Implement fixes
executor - - Re-verify
security-reviewer-low
Use for: Security reviews, vulnerability fixes
用途: 安全审计与修复
/pipeline security <scope>阶段:
- - 查找潜在漏洞
explore - - 审计并识别问题
security-reviewer - - 实施修复
executor - - 重新验证
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:
- Retry - Re-run the same agent (up to 3 times)
- Skip - Continue to next stage with partial output
- Abort - Stop entire pipeline
- Fallback - Route to alternative agent
Configuration:
/pipeline explore -> architect -> executor --retry=3 --on-error=abort当Agent失败时,流水线可以:
- 重试 - 重新运行同一个Agent(最多3次)
- 跳过 - 携带部分输出继续到下一阶段
- 终止 - 停止整个流水线
- 降级 - 路由到备选Agent
配置:
/pipeline explore -> architect -> executor --retry=3 --on-error=abortError Recovery Patterns
错误恢复模式
Pattern 1: Fallback to Higher Tier
executor-low -> on-error -> executor:sonnetPattern 2: Consult Architect
executor -> on-error -> architect -> executorPattern 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-inputPipeline State Management
流水线状态管理
Pipelines maintain state in :
.omc/pipeline-state.jsonjson
{
"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.jsonjson
{
"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 cancelOr 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
最佳实践
- Start with presets - Use built-in pipelines before creating custom ones
- Match model to complexity - Don't waste opus on simple tasks
- Keep stages focused - Each agent should have one clear responsibility
- Use parallel stages - Run independent work simultaneously
- Verify at checkpoints - Use architect or critic to verify progress
- Document custom pipelines - Save successful patterns for reuse
- 从预设开始 - 在创建自定义流水线前,先使用内置流水线
- 匹配模型复杂度 - 不要在简单任务上浪费opus模型
- 保持阶段聚焦 - 每个Agent应只有一个明确的职责
- 使用并行阶段 - 同时运行独立的任务
- 在检查点验证 - 使用Architect或Critic验证进度
- 记录自定义流水线 - 保存成功的模式以便复用
Troubleshooting
故障排除
Pipeline Hangs
流水线挂起
Check: for current stage
Fix: Resume with or cancel and restart
.omc/pipeline-state.json/pipeline resume检查: 查看当前阶段
修复: 使用恢复,或取消后重启
.omc/pipeline-state.json/pipeline resumeAgent 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_contextTechnical Implementation
技术实现
The pipeline orchestrator:
- Parses pipeline definition - Validates syntax and agent names
- Initializes state - Creates pipeline-state.json
- Executes stages sequentially - Spawns agents with Task tool
- Passes context between stages - Structures output for next agent
- Handles branching logic - Evaluates conditions and routes
- Manages parallel execution - Spawns concurrent agents and merges
- Persists state - Updates state file after each stage
- Enforces verification - Runs checks before completion
流水线编排器:
- 解析流水线定义 - 验证语法和Agent名称
- 初始化状态 - 创建pipeline-state.json
- 顺序执行阶段 - 通过Task工具启动Agent
- 在阶段间传递上下文 - 为下一个Agent结构化输出
- 处理分支逻辑 - 评估条件并路由
- 管理并行执行 - 启动并发Agent并合并输出
- 持久化状态 - 每个阶段完成后更新状态文件
- 执行验证 - 完成前运行检查
STATE CLEANUP ON COMPLETION
完成后的状态清理
IMPORTANT: Delete state files on completion - do NOT just set
active: falseWhen pipeline completes (all stages done or cancelled):
bash
undefined重要提示:完成后删除状态文件 - 不要仅设置
active: false当流水线完成(所有阶段完成或取消):
bash
undefinedDelete 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 command
/pipeline - 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