stream-chain
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStream-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:
- Custom Chains (): Execute custom prompt sequences with full control
run - Predefined Pipelines (): Use battle-tested workflows for common tasks
pipeline
Each step in a chain receives the complete output from the previous step, enabling sophisticated multi-agent coordination through streaming data flow.
Stream-Chain 提供两种强大的模式来编排多智能体工作流:
- 自定义链式流程():完全可控地执行自定义提示词序列
run - 预定义流水线():使用经过实战检验的工作流处理常见任务
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 analysisbash
claude-flow stream-chain pipeline analysisCustom Chains (run
)
run自定义链式流程(run
)
runExecute 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
选项
| Option | Description | Default |
|---|---|---|
| Show detailed execution information | |
| Timeout per step | |
| Enable debug mode with full logging | |
| 选项 | 描述 | 默认值 |
|---|---|---|
| 显示详细执行信息 | |
| 每个步骤的超时时间 | |
| 启用调试模式,记录完整日志 | |
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 \
--verbosebash
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 \
--verboseCode 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" \
--debugbash
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" \
--debugData 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预定义流水线(pipeline
)
pipelineExecute 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 analysisWorkflow Steps:
- Structure Analysis: Map directory structure and identify components
- Issue Detection: Find potential improvements and problems
- 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工作流步骤:
- 结构分析:映射目录结构并识别组件
- 问题检测:发现潜在的改进点和问题
- 建议生成:生成可执行的改进报告
适用场景:
- 新代码库上手
- 技术债务评估
- 架构评审
- 代码质量审计
2. Refactor Pipeline
2. 重构流水线
Systematic code refactoring with prioritization.
bash
claude-flow stream-chain pipeline refactorWorkflow Steps:
- Candidate Identification: Find code needing refactoring
- Prioritization: Create ranked refactoring plan
- 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工作流步骤:
- 候选识别:找出需要重构的代码
- 优先级排序:创建排序后的重构计划
- 实现:提供优先级最高的代码重构版本
适用场景:
- 技术债务减少
- 代码质量提升
- 遗留代码现代化
- 设计模式实现
3. Test Pipeline
3. 测试流水线
Comprehensive test generation with coverage analysis.
bash
claude-flow stream-chain pipeline testWorkflow Steps:
- Coverage Analysis: Identify areas lacking tests
- Test Design: Create test cases for critical functions
- 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工作流步骤:
- 覆盖率分析:识别缺少测试的区域
- 测试设计:为关键功能创建测试用例
- 实现:生成带断言的单元测试
适用场景:
- 提升测试覆盖率
- 支持TDD工作流
- 回归测试创建
- 质量保证
4. Optimize Pipeline
4. 优化流水线
Performance optimization with profiling and implementation.
bash
claude-flow stream-chain pipeline optimizeWorkflow Steps:
- Profiling: Identify performance bottlenecks
- Strategy: Analyze and suggest optimization approaches
- Implementation: Provide optimized code
Use Cases:
- Performance improvement
- Resource optimization
- Scalability enhancement
- Latency reduction
包含性能分析和实现的性能优化。
bash
claude-flow stream-chain pipeline optimize工作流步骤:
- 性能分析:识别性能瓶颈
- 策略制定:分析并提出优化方案
- 实现:提供优化后的代码
适用场景:
- 性能提升
- 资源优化
- 可扩展性增强
- 延迟降低
Pipeline Options
流水线选项
| Option | Description | Default |
|---|---|---|
| Show detailed execution | |
| Timeout per step | |
| Enable debug mode | |
| 选项 | 描述 | 默认值 |
|---|---|---|
| 显示详细执行信息 | |
| 每个步骤的超时时间 | |
| 启用调试模式 | |
Pipeline Examples
流水线示例
Quick Analysis
快速分析
bash
claude-flow stream-chain pipeline analysisbash
claude-flow stream-chain pipeline analysisExtended Refactoring
扩展重构
bash
claude-flow stream-chain pipeline refactor --timeout 60 --verbosebash
claude-flow stream-chain pipeline refactor --timeout 60 --verboseDebug Test Generation
调试测试生成
bash
claude-flow stream-chain pipeline test --debugbash
claude-flow stream-chain pipeline test --debugComprehensive Optimization
全面优化
bash
claude-flow stream-chain pipeline optimize --timeout 90 --verbosebash
claude-flow stream-chain pipeline optimize --timeout 90 --verbosePipeline 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.jsonConfiguration 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 documentationbash
claude-flow stream-chain pipeline security
claude-flow stream-chain pipeline documentationAdvanced 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 optimizeBest 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
undefinedbash
undefinedInitialize 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"
"Agent 1: Research task"
"Agent 2: Implement solution"
"Agent 3: Test implementation"
"Agent 4: Review and refine"
undefinedclaude-flow stream-chain run
"Agent 1: Research task"
"Agent 2: Implement solution"
"Agent 3: Test implementation"
"Agent 4: Review and refine"
"Agent 1: Research task"
"Agent 2: Implement solution"
"Agent 3: Test implementation"
"Agent 4: Review and refine"
undefinedMemory Integration
内存集成
Stream chains automatically store context in memory for cross-session persistence:
bash
undefined流式链式流程会自动将上下文存储到内存中,实现跨会话持久化:
bash
undefinedExecute chain with memory
带内存功能执行链式流程
claude-flow stream-chain run
"Analyze requirements"
"Design architecture"
--verbose
"Analyze requirements"
"Design architecture"
--verbose
claude-flow stream-chain run
"Analyze requirements"
"Design architecture"
--verbose
"Analyze requirements"
"Design architecture"
--verbose
Results stored in .claude-flow$memory$stream-chain/
结果存储在 .claude-flow$memory$stream-chain/
undefinedundefinedNeural Pattern Training
神经模式训练
Successful chains train neural patterns for improved performance:
bash
undefined成功的链式流程会训练神经模式以提升性能:
bash
undefinedEnable 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 120Context Loss
上下文丢失
If context not flowing properly, use :
--debugbash
claude-flow stream-chain run "step 1" "step 2" --debug如果上下文流转异常,使用 模式:
--debugbash
claude-flow stream-chain run "step 1" "step 2" --debugPipeline Not Found
流水线未找到
Verify pipeline name and custom definitions:
bash
undefined验证流水线名称和自定义定义:
bash
undefinedCheck 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
undefinedbash
undefinedFull 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
"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
undefinedclaude-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
"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
undefinedCode Review Pipeline
代码审查流水线
bash
undefinedbash
undefinedAutomated 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"
"Analyze recent git changes"
"Identify code quality issues"
"Check for security vulnerabilities"
"Verify test coverage"
"Generate code review report with recommendations"
undefinedclaude-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"
"Analyze recent git changes"
"Identify code quality issues"
"Check for security vulnerabilities"
"Verify test coverage"
"Generate code review report with recommendations"
undefinedMigration Assistant
迁移助手
bash
undefinedbash
undefinedFramework 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"
"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"
"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 for custom workflows and for battle-tested solutions.
runpipelineStream-Chain 通过以下方式实现复杂的多步骤工作流:
- 顺序处理:每个步骤基于之前的结果构建
- 上下文保留:完整的输出历史在链式流程中流转
- 灵活编排:自定义链式流程或预定义流水线
- 智能体协调:自然的多智能体协作模式
- 数据转换:通过简单步骤实现复杂处理
使用 执行自定义工作流,使用 执行经过实战检验的解决方案。
runpipeline