stream-chain

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Stream-Chain Skill

Stream-Chain Skill

Execute sophisticated multi-step workflows where each agent's output flows into the next, enabling complex data transformations and sequential processing pipelines.
执行复杂的多步骤工作流,每个智能体的输出会流入下一个步骤,实现复杂的数据转换和顺序处理流水线。

Overview

概述

Stream-Chain provides two powerful modes for orchestrating multi-agent workflows:
  1. Custom Chains (
    run
    ): Execute custom prompt sequences with full control
  2. Predefined Pipelines (
    pipeline
    ): Use battle-tested workflows for common tasks
Each step in a chain receives the complete output from the previous step, enabling sophisticated multi-agent coordination through streaming data flow.

Stream-Chain 提供两种强大的模式来编排多智能体工作流:
  1. 自定义链式流程
    run
    ):完全可控地执行自定义提示词序列
  2. 预定义流水线
    pipeline
    ):使用经过实战检验的工作流处理常见任务
链式流程中的每个步骤都会接收上一步的完整输出,通过流式数据流实现复杂的多智能体协作。

Quick Start

快速开始

Run a Custom Chain

运行自定义链式流程

bash
claude-flow stream-chain run \
  "Analyze codebase structure" \
  "Identify improvement areas" \
  "Generate action plan"
bash
claude-flow stream-chain run \
  "Analyze codebase structure" \
  "Identify improvement areas" \
  "Generate action plan"

Execute a Pipeline

执行预定义流水线

bash
claude-flow stream-chain pipeline analysis

bash
claude-flow stream-chain pipeline analysis

Custom Chains (
run
)

自定义链式流程(
run

Execute custom stream chains with your own prompts for maximum flexibility.
使用自定义提示词执行流式链式流程,实现最大灵活性。

Syntax

语法

bash
claude-flow stream-chain run <prompt1> <prompt2> [...] [options]
Requirements:
  • Minimum 2 prompts required
  • Each prompt becomes a step in the chain
  • Output flows sequentially through all steps
bash
claude-flow stream-chain run <prompt1> <prompt2> [...] [options]
要求:
  • 至少需要2个提示词
  • 每个提示词成为链式流程中的一个步骤
  • 输出会按顺序流经所有步骤

Options

选项

OptionDescriptionDefault
--verbose
Show detailed execution information
false
--timeout <seconds>
Timeout per step
30
--debug
Enable debug mode with full logging
false
选项描述默认值
--verbose
显示详细执行信息
false
--timeout <seconds>
每个步骤的超时时间
30
--debug
启用调试模式,记录完整日志
false

How Context Flows

上下文流转方式

Each step receives the previous output as context:
Step 1: "Write a sorting function"
Output: [function implementation]

Step 2 receives:
  "Previous step output:
  [function implementation]

  Next task: Add comprehensive tests"

Step 3 receives:
  "Previous steps output:
  [function + tests]

  Next task: Optimize performance"
每个步骤都会接收上一步的输出作为上下文:
步骤1: "Write a sorting function"
输出: [函数实现代码]

步骤2收到的内容:
  "Previous step output:
  [函数实现代码]

  Next task: Add comprehensive tests"

步骤3收到的内容:
  "Previous steps output:
  [函数实现代码 + 测试代码]

  Next task: Optimize performance"

Examples

示例

Basic Development Chain

基础开发链式流程

bash
claude-flow stream-chain run \
  "Write a user authentication function" \
  "Add input validation and error handling" \
  "Create unit tests with edge cases"
bash
claude-flow stream-chain run \
  "Write a user authentication function" \
  "Add input validation and error handling" \
  "Create unit tests with edge cases"

Security Audit Workflow

安全审计工作流

bash
claude-flow stream-chain run \
  "Analyze authentication system for vulnerabilities" \
  "Identify and categorize security issues by severity" \
  "Propose fixes with implementation priority" \
  "Generate security test cases" \
  --timeout 45 \
  --verbose
bash
claude-flow stream-chain run \
  "Analyze authentication system for vulnerabilities" \
  "Identify and categorize security issues by severity" \
  "Propose fixes with implementation priority" \
  "Generate security test cases" \
  --timeout 45 \
  --verbose

Code Refactoring Chain

代码重构链式流程

bash
claude-flow stream-chain run \
  "Identify code smells in src/ directory" \
  "Create refactoring plan with specific changes" \
  "Apply refactoring to top 3 priority items" \
  "Verify refactored code maintains behavior" \
  --debug
bash
claude-flow stream-chain run \
  "Identify code smells in src/ directory" \
  "Create refactoring plan with specific changes" \
  "Apply refactoring to top 3 priority items" \
  "Verify refactored code maintains behavior" \
  --debug

Data Processing Pipeline

数据处理流水线

bash
claude-flow stream-chain run \
  "Extract data from API responses" \
  "Transform data into normalized format" \
  "Validate data against schema" \
  "Generate data quality report"

bash
claude-flow stream-chain run \
  "Extract data from API responses" \
  "Transform data into normalized format" \
  "Validate data against schema" \
  "Generate data quality report"

Predefined Pipelines (
pipeline
)

预定义流水线(
pipeline

Execute battle-tested workflows optimized for common development tasks.
执行经过实战检验的工作流,针对常见开发任务进行优化。

Syntax

语法

bash
claude-flow stream-chain pipeline <type> [options]
bash
claude-flow stream-chain pipeline <type> [options]

Available Pipelines

可用流水线

1. Analysis Pipeline

1. 分析流水线

Comprehensive codebase analysis and improvement identification.
bash
claude-flow stream-chain pipeline analysis
Workflow Steps:
  1. Structure Analysis: Map directory structure and identify components
  2. Issue Detection: Find potential improvements and problems
  3. Recommendations: Generate actionable improvement report
Use Cases:
  • New codebase onboarding
  • Technical debt assessment
  • Architecture review
  • Code quality audits
全面的代码库分析和改进点识别。
bash
claude-flow stream-chain pipeline analysis
工作流步骤:
  1. 结构分析:映射目录结构并识别组件
  2. 问题检测:发现潜在的改进点和问题
  3. 建议生成:生成可执行的改进报告
适用场景:
  • 新代码库上手
  • 技术债务评估
  • 架构评审
  • 代码质量审计

2. Refactor Pipeline

2. 重构流水线

Systematic code refactoring with prioritization.
bash
claude-flow stream-chain pipeline refactor
Workflow Steps:
  1. Candidate Identification: Find code needing refactoring
  2. Prioritization: Create ranked refactoring plan
  3. Implementation: Provide refactored code for top priorities
Use Cases:
  • Technical debt reduction
  • Code quality improvement
  • Legacy code modernization
  • Design pattern implementation
系统化的代码重构,包含优先级排序。
bash
claude-flow stream-chain pipeline refactor
工作流步骤:
  1. 候选识别:找出需要重构的代码
  2. 优先级排序:创建排序后的重构计划
  3. 实现:提供优先级最高的代码重构版本
适用场景:
  • 技术债务减少
  • 代码质量提升
  • 遗留代码现代化
  • 设计模式实现

3. Test Pipeline

3. 测试流水线

Comprehensive test generation with coverage analysis.
bash
claude-flow stream-chain pipeline test
Workflow Steps:
  1. Coverage Analysis: Identify areas lacking tests
  2. Test Design: Create test cases for critical functions
  3. Implementation: Generate unit tests with assertions
Use Cases:
  • Increasing test coverage
  • TDD workflow support
  • Regression test creation
  • Quality assurance
全面的测试用例生成,包含覆盖率分析。
bash
claude-flow stream-chain pipeline test
工作流步骤:
  1. 覆盖率分析:识别缺少测试的区域
  2. 测试设计:为关键功能创建测试用例
  3. 实现:生成带断言的单元测试
适用场景:
  • 提升测试覆盖率
  • 支持TDD工作流
  • 回归测试创建
  • 质量保证

4. Optimize Pipeline

4. 优化流水线

Performance optimization with profiling and implementation.
bash
claude-flow stream-chain pipeline optimize
Workflow Steps:
  1. Profiling: Identify performance bottlenecks
  2. Strategy: Analyze and suggest optimization approaches
  3. Implementation: Provide optimized code
Use Cases:
  • Performance improvement
  • Resource optimization
  • Scalability enhancement
  • Latency reduction
包含性能分析和实现的性能优化。
bash
claude-flow stream-chain pipeline optimize
工作流步骤:
  1. 性能分析:识别性能瓶颈
  2. 策略制定:分析并提出优化方案
  3. 实现:提供优化后的代码
适用场景:
  • 性能提升
  • 资源优化
  • 可扩展性增强
  • 延迟降低

Pipeline Options

流水线选项

OptionDescriptionDefault
--verbose
Show detailed execution
false
--timeout <seconds>
Timeout per step
30
--debug
Enable debug mode
false
选项描述默认值
--verbose
显示详细执行信息
false
--timeout <seconds>
每个步骤的超时时间
30
--debug
启用调试模式
false

Pipeline Examples

流水线示例

Quick Analysis

快速分析

bash
claude-flow stream-chain pipeline analysis
bash
claude-flow stream-chain pipeline analysis

Extended Refactoring

扩展重构

bash
claude-flow stream-chain pipeline refactor --timeout 60 --verbose
bash
claude-flow stream-chain pipeline refactor --timeout 60 --verbose

Debug Test Generation

调试测试生成

bash
claude-flow stream-chain pipeline test --debug
bash
claude-flow stream-chain pipeline test --debug

Comprehensive Optimization

全面优化

bash
claude-flow stream-chain pipeline optimize --timeout 90 --verbose
bash
claude-flow stream-chain pipeline optimize --timeout 90 --verbose

Pipeline Output

流水线输出

Each pipeline execution provides:
  • Progress: Step-by-step execution status
  • Results: Success$failure per step
  • Timing: Total and per-step execution time
  • Summary: Consolidated results and recommendations

每次流水线执行都会提供:
  • 进度:分步执行状态
  • 结果:每个步骤的成功$失败状态
  • 计时:总耗时和各步骤耗时
  • 总结:整合后的结果和建议

Custom Pipeline Definitions

自定义流水线定义

Define reusable pipelines in
.claude-flow$config.json
:
.claude-flow$config.json
中定义可复用的流水线:

Configuration Format

配置格式

json
{
  "streamChain": {
    "pipelines": {
      "security": {
        "name": "Security Audit Pipeline",
        "description": "Comprehensive security analysis",
        "prompts": [
          "Scan codebase for security vulnerabilities",
          "Categorize issues by severity (critical$high$medium$low)",
          "Generate fixes with priority and implementation steps",
          "Create security test suite"
        ],
        "timeout": 45
      },
      "documentation": {
        "name": "Documentation Generation Pipeline",
        "prompts": [
          "Analyze code structure and identify undocumented areas",
          "Generate API documentation with examples",
          "Create usage guides and tutorials",
          "Build architecture diagrams and flow charts"
        ]
      }
    }
  }
}
json
{
  "streamChain": {
    "pipelines": {
      "security": {
        "name": "Security Audit Pipeline",
        "description": "Comprehensive security analysis",
        "prompts": [
          "Scan codebase for security vulnerabilities",
          "Categorize issues by severity (critical$high$medium$low)",
          "Generate fixes with priority and implementation steps",
          "Create security test suite"
        ],
        "timeout": 45
      },
      "documentation": {
        "name": "Documentation Generation Pipeline",
        "prompts": [
          "Analyze code structure and identify undocumented areas",
          "Generate API documentation with examples",
          "Create usage guides and tutorials",
          "Build architecture diagrams and flow charts"
        ]
      }
    }
  }
}

Execute Custom Pipeline

执行自定义流水线

bash
claude-flow stream-chain pipeline security
claude-flow stream-chain pipeline documentation

bash
claude-flow stream-chain pipeline security
claude-flow stream-chain pipeline documentation

Advanced Use Cases

高级使用场景

Multi-Agent Coordination

多智能体协作

Chain different agent types for complex workflows:
bash
claude-flow stream-chain run \
  "Research best practices for API design" \
  "Design REST API with discovered patterns" \
  "Implement API endpoints with validation" \
  "Generate OpenAPI specification" \
  "Create integration tests" \
  "Write deployment documentation"
将不同类型的智能体链接起来处理复杂工作流:
bash
claude-flow stream-chain run \
  "Research best practices for API design" \
  "Design REST API with discovered patterns" \
  "Implement API endpoints with validation" \
  "Generate OpenAPI specification" \
  "Create integration tests" \
  "Write deployment documentation"

Data Transformation Pipeline

数据转换流水线

Process and transform data through multiple stages:
bash
claude-flow stream-chain run \
  "Extract user data from CSV files" \
  "Normalize and validate data format" \
  "Enrich data with external API calls" \
  "Generate analytics report" \
  "Create visualization code"
通过多个阶段处理和转换数据:
bash
claude-flow stream-chain run \
  "Extract user data from CSV files" \
  "Normalize and validate data format" \
  "Enrich data with external API calls" \
  "Generate analytics report" \
  "Create visualization code"

Code Migration Workflow

代码迁移工作流

Systematic code migration with validation:
bash
claude-flow stream-chain run \
  "Analyze legacy codebase dependencies" \
  "Create migration plan with risk assessment" \
  "Generate modernized code for high-priority modules" \
  "Create migration tests" \
  "Document migration steps and rollback procedures"
系统化的代码迁移,包含验证:
bash
claude-flow stream-chain run \
  "Analyze legacy codebase dependencies" \
  "Create migration plan with risk assessment" \
  "Generate modernized code for high-priority modules" \
  "Create migration tests" \
  "Document migration steps and rollback procedures"

Quality Assurance Chain

质量保证链式流程

Comprehensive code quality workflow:
bash
claude-flow stream-chain pipeline analysis
claude-flow stream-chain pipeline refactor
claude-flow stream-chain pipeline test
claude-flow stream-chain pipeline optimize

全面的代码质量工作流:
bash
claude-flow stream-chain pipeline analysis
claude-flow stream-chain pipeline refactor
claude-flow stream-chain pipeline test
claude-flow stream-chain pipeline optimize

Best Practices

最佳实践

1. Clear and Specific Prompts

1. 清晰具体的提示词

Good:
bash
"Analyze authentication.js for SQL injection vulnerabilities"
Avoid:
bash
"Check security"
推荐:
bash
"Analyze authentication.js for SQL injection vulnerabilities"
避免:
bash
"Check security"

2. Logical Progression

2. 逻辑递进

Order prompts to build on previous outputs:
bash
1. "Identify the problem"
2. "Analyze root causes"
3. "Design solution"
4. "Implement solution"
5. "Verify implementation"
按顺序排列提示词,基于之前的输出构建后续步骤:
bash
1. "Identify the problem"
2. "Analyze root causes"
3. "Design solution"
4. "Implement solution"
5. "Verify implementation"

3. Appropriate Timeouts

3. 合适的超时时间

  • Simple tasks: 30 seconds (default)
  • Analysis tasks: 45-60 seconds
  • Implementation tasks: 60-90 seconds
  • Complex workflows: 90-120 seconds
  • 简单任务:30秒(默认)
  • 分析任务:45-60秒
  • 实现任务:60-90秒
  • 复杂工作流:90-120秒

4. Verification Steps

4. 验证步骤

Include validation in your chains:
bash
claude-flow stream-chain run \
  "Implement feature X" \
  "Write tests for feature X" \
  "Verify tests pass and cover edge cases"
在链式流程中包含验证环节:
bash
claude-flow stream-chain run \
  "Implement feature X" \
  "Write tests for feature X" \
  "Verify tests pass and cover edge cases"

5. Iterative Refinement

5. 迭代优化

Use chains for iterative improvement:
bash
claude-flow stream-chain run \
  "Generate initial implementation" \
  "Review and identify issues" \
  "Refine based on issues found" \
  "Final quality check"

使用链式流程进行迭代改进:
bash
claude-flow stream-chain run \
  "Generate initial implementation" \
  "Review and identify issues" \
  "Refine based on issues found" \
  "Final quality check"

Integration with Claude Flow

与Claude Flow集成

Combine with Swarm Coordination

与Swarm协调结合

bash
undefined
bash
undefined

Initialize swarm for coordination

初始化swarm用于协调

claude-flow swarm init --topology mesh
claude-flow swarm init --topology mesh

Execute stream chain with swarm agents

使用swarm智能体执行流式链式流程

claude-flow stream-chain run
"Agent 1: Research task"
"Agent 2: Implement solution"
"Agent 3: Test implementation"
"Agent 4: Review and refine"
undefined
claude-flow stream-chain run
"Agent 1: Research task"
"Agent 2: Implement solution"
"Agent 3: Test implementation"
"Agent 4: Review and refine"
undefined

Memory Integration

内存集成

Stream chains automatically store context in memory for cross-session persistence:
bash
undefined
流式链式流程会自动将上下文存储到内存中,实现跨会话持久化:
bash
undefined

Execute chain with memory

带内存功能执行链式流程

claude-flow stream-chain run
"Analyze requirements"
"Design architecture"
--verbose
claude-flow stream-chain run
"Analyze requirements"
"Design architecture"
--verbose

Results stored in .claude-flow$memory$stream-chain/

结果存储在 .claude-flow$memory$stream-chain/

undefined
undefined

Neural Pattern Training

神经模式训练

Successful chains train neural patterns for improved performance:
bash
undefined
成功的链式流程会训练神经模式以提升性能:
bash
undefined

Enable neural training

启用神经训练

claude-flow stream-chain pipeline optimize --debug
claude-flow stream-chain pipeline optimize --debug

Patterns learned and stored for future optimizations

学习到的模式会被存储,用于未来的优化


---

---

Troubleshooting

故障排除

Chain Timeout

链式流程超时

If steps timeout, increase timeout value:
bash
claude-flow stream-chain run "complex task" --timeout 120
如果步骤超时,增加超时时间:
bash
claude-flow stream-chain run "complex task" --timeout 120

Context Loss

上下文丢失

If context not flowing properly, use
--debug
:
bash
claude-flow stream-chain run "step 1" "step 2" --debug
如果上下文流转异常,使用
--debug
模式:
bash
claude-flow stream-chain run "step 1" "step 2" --debug

Pipeline Not Found

流水线未找到

Verify pipeline name and custom definitions:
bash
undefined
验证流水线名称和自定义定义:
bash
undefined

Check available pipelines

查看可用流水线

cat .claude-flow$config.json | grep -A 10 "streamChain"

---
cat .claude-flow$config.json | grep -A 10 "streamChain"

---

Performance Characteristics

性能特征

  • Throughput: 2-5 steps per minute (varies by complexity)
  • Context Size: Up to 100K tokens per step
  • Memory Usage: ~50MB per active chain
  • Concurrency: Supports parallel chain execution

  • 吞吐量:每分钟2-5个步骤(根据复杂度不同而变化)
  • 上下文大小:每个步骤最多支持100K tokens
  • 内存使用:每个活跃链式流程约50MB
  • 并发支持:支持并行链式流程执行

Related Skills

相关技能

  • SPARC Methodology: Systematic development workflow
  • Swarm Coordination: Multi-agent orchestration
  • Memory Management: Persistent context storage
  • Neural Patterns: Adaptive learning

  • SPARC方法论:系统化开发工作流
  • Swarm协调:多智能体编排
  • 内存管理:持久化上下文存储
  • 神经模式:自适应学习

Examples Repository

示例仓库

Complete Development Workflow

完整开发工作流

bash
undefined
bash
undefined

Full feature development chain

完整功能开发链式流程

claude-flow stream-chain run
"Analyze requirements for user profile feature"
"Design database schema and API endpoints"
"Implement backend with validation"
"Create frontend components"
"Write comprehensive tests"
"Generate API documentation"
--timeout 60
--verbose
undefined
claude-flow stream-chain run
"Analyze requirements for user profile feature"
"Design database schema and API endpoints"
"Implement backend with validation"
"Create frontend components"
"Write comprehensive tests"
"Generate API documentation"
--timeout 60
--verbose
undefined

Code Review Pipeline

代码审查流水线

bash
undefined
bash
undefined

Automated code review workflow

自动化代码审查工作流

claude-flow stream-chain run
"Analyze recent git changes"
"Identify code quality issues"
"Check for security vulnerabilities"
"Verify test coverage"
"Generate code review report with recommendations"
undefined
claude-flow stream-chain run
"Analyze recent git changes"
"Identify code quality issues"
"Check for security vulnerabilities"
"Verify test coverage"
"Generate code review report with recommendations"
undefined

Migration Assistant

迁移助手

bash
undefined
bash
undefined

Framework migration helper

框架迁移助手

claude-flow stream-chain run
"Analyze current Vue 2 codebase"
"Identify Vue 3 breaking changes"
"Create migration checklist"
"Generate migration scripts"
"Provide updated code examples"

---
claude-flow stream-chain run
"Analyze current Vue 2 codebase"
"Identify Vue 3 breaking changes"
"Create migration checklist"
"Generate migration scripts"
"Provide updated code examples"

---

Conclusion

总结

Stream-Chain enables sophisticated multi-step workflows by:
  • Sequential Processing: Each step builds on previous results
  • Context Preservation: Full output history flows through chain
  • Flexible Orchestration: Custom chains or predefined pipelines
  • Agent Coordination: Natural multi-agent collaboration pattern
  • Data Transformation: Complex processing through simple steps
Use
run
for custom workflows and
pipeline
for battle-tested solutions.
Stream-Chain 通过以下方式实现复杂的多步骤工作流:
  • 顺序处理:每个步骤基于之前的结果构建
  • 上下文保留:完整的输出历史在链式流程中流转
  • 灵活编排:自定义链式流程或预定义流水线
  • 智能体协调:自然的多智能体协作模式
  • 数据转换:通过简单步骤实现复杂处理
使用
run
执行自定义工作流,使用
pipeline
执行经过实战检验的解决方案。