stream-chain について
stream-chainは、複数のAgentタスクを順次つなぐclaude-flowのスキルです。カスタムプロンプトチェーンと既定・独自のパイプラインに対応し、各ステップの出力を次へ渡します。
主な機能
- 01カスタムプロンプトチェーンの実行
- 02分析・リファクタリング・テスト・最適化パイプライン
- 03前の出力を次のステップへ引き継ぎ
- 04タイムアウト、詳細表示、デバッグの設定
活用シーン
- 01コードベースの段階的な分析と改善
- 02テスト生成とカバレッジ確認
- 03コードのリファクタリングや性能最適化
- 04データの段階的な処理と検証
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill stream-chainインストール後、Claude Code で/stream-chainを入力して読み込まれたか確認します。
詳細
Stream-Chain スキル
各エージェントの出力を次のエージェントに渡して、複雑なデータ変換や逐次処理パイプラインを実現する、高度な複数ステップのワークフローを実行します。
概要
Stream-Chain では、複数エージェントのワークフローを調整するための、次の2つの強力なモードを利用できます。
- カスタムチェーン(
run):完全な制御のもとでカスタムのプロンプトシーケンスを実行します - 定義済みパイプライン(
pipeline):一般的なタスク向けの実績あるワークフローを利用します
チェーンの各ステップは前のステップの出力全体を受け取るため、ストリーミングデータフローを通じて高度な複数エージェント間の連携を実現できます。
クイックスタート
カスタムチェーンを実行する
claude-flow stream-chain run \
"Analyze codebase structure" \
"Identify improvement areas" \
"Generate action plan"
パイプラインを実行する
claude-flow stream-chain pipeline analysis
カスタムチェーン(run)
独自のプロンプトを使用してカスタムのストリームチェーンを実行し、最大限の柔軟性を実現します。
構文
claude-flow stream-chain run <prompt1> <prompt2> [...] [options]
要件:
- プロンプトは最低2つ必要です
- 各プロンプトがチェーンの1つのステップになります
- 出力はすべてのステップを順番に流れます
オプション
| オプション | 説明 | デフォルト |
|---|---|---|
--verbose | 実行の詳細情報を表示します | false |
--timeout <seconds> | 各ステップのタイムアウト | 30 |
--debug | すべてのログを記録するデバッグモードを有効にします | false |
コンテキストの受け渡し方法
各ステップは、前のステップの出力をコンテキストとして受け取ります。
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"
例
基本的な開発チェーン
claude-flow stream-chain run \
"Write a user authentication function" \
"Add input validation and error handling" \
"Create unit tests with edge cases"
セキュリティ監査ワークフロー
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
コードリファクタリングチェーン
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
データ処理パイプライン
claude-flow stream-chain run \
"Extract data from API responses" \
"Transform data into normalized format" \
"Validate data against schema" \
"Generate data quality report"
定義済みパイプライン(pipeline)
一般的な開発タスク向けに最適化された、実績あるワークフローを実行します。
構文
claude-flow stream-chain pipeline <type> [options]
利用可能なパイプライン
1. 分析パイプライン
コードベースを包括的に分析し、改善点を特定します。
claude-flow stream-chain pipeline analysis
ワークフローのステップ:
- 構造分析:ディレクトリ構造をマッピングし、コンポーネントを特定します
- 問題の検出:改善の可能性がある点や問題を見つけます
- 推奨事項:実行可能な改善レポートを作成します
使用例:
- 新しいコードベースの把握
- 技術的負債の評価
- アーキテクチャレビュー
- コード品質の監査
2. リファクタリングパイプライン
優先順位を付けながら、体系的にコードをリファクタリングします。
claude-flow stream-chain pipeline refactor
ワークフローのステップ:
- 候補の特定:リファクタリングが必要なコードを見つけます
- 優先順位付け:優先度順のリファクタリング計画を作成します
- 実装:優先度の高い項目について、リファクタリング済みのコードを提示します
使用例:
- 技術的負債の削減
- コード品質の向上
- レガシーコードのモダナイズ
- デザインパターンの実装
3. テストパイプライン
カバレッジ分析を含む、包括的なテストを生成します。
claude-flow stream-chain pipeline test
ワークフローのステップ:
- カバレッジ分析:テストが不足している領域を特定します
- テスト設計:重要な関数のテストケースを作成します
- 実装:アサーションを含むユニットテストを生成します
使用例:
- テストカバレッジの向上
- TDD ワークフローのサポート
- 回帰テストの作成
- 品質保証
4. 最適化パイプライン
プロファイリングと実装によって、パフォーマンスを最適化します。
claude-flow stream-chain pipeline optimize
ワークフローのステップ:
- プロファイリング:パフォーマンスのボトルネックを特定します
- 戦略:最適化の手法を分析し、提案します
- 実装:最適化されたコードを提示します
使用例:
- パフォーマンスの向上
- リソースの最適化
- スケーラビリティの向上
- レイテンシの削減
パイプラインのオプション
| オプション | 説明 | デフォルト |
|---|---|---|
--verbose | 実行の詳細を表示します | false |
--timeout <seconds> | 各ステップのタイムアウト | 30 |
--debug | デバッグモードを有効にします | false |
パイプラインの例
クイック分析
claude-flow stream-chain pipeline analysis
拡張リファクタリング
claude-flow stream-chain pipeline refactor --timeout 60 --verbose
デバッグ付きテスト生成
claude-flow stream-chain pipeline test --debug
包括的な最適化
claude-flow stream-chain pipeline optimize --timeout 90 --verbose
パイプラインの出力
各パイプラインの実行では、次の情報が提供されます。
- 進行状況:ステップごとの実行状況
- 結果:各ステップの成功$失敗
- 所要時間:合計およびステップごとの実行時間
- 概要:結果と推奨事項のまとめ
カスタムパイプライン定義
.claude-flow$config.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"
]
}
}
}
}
カスタムパイプラインの実行
claude-flow stream-chain pipeline security
claude-flow stream-chain pipeline documentation
高度なユースケース
マルチエージェントの調整
複雑なワークフローでは、異なる種類のエージェントを連結します。
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"
データ変換パイプライン
複数の段階を通じてデータを処理・変換します。
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"
コード移行ワークフロー
検証を伴う体系的なコード移行です。
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"
品質保証チェーン
包括的なコード品質ワークフローです。
claude-flow stream-chain pipeline analysis
claude-flow stream-chain pipeline refactor
claude-flow stream-chain pipeline test
claude-flow stream-chain pipeline optimize
ベストプラクティス
1. 明確で具体的なプロンプト
推奨例:
"Analyze authentication.js for SQL injection vulnerabilities"
避ける例:
"Check security"
2. 論理的な進行
前の出力を基に構築できるよう、プロンプトを順序付けます。
1. "Identify the problem"
2. "Analyze root causes"
3. "Design solution"
4. "Implement solution"
5. "Verify implementation"
3. 適切なタイムアウト
- 単純なタスク:30秒(デフォルト)
- 分析タスク:45~60秒
- 実装タスク:60~90秒
- 複雑なワークフロー:90~120秒
4. 検証ステップ
チェーンに検証を含めます。
claude-flow stream-chain run \
"Implement feature X" \
"Write tests for feature X" \
"Verify tests pass and cover edge cases"
5. 反復的な改善
チェーンを使って反復的に改善します。
claude-flow stream-chain run \
"Generate initial implementation" \
"Review and identify issues" \
"Refine based on issues found" \
"Final quality check"
Claude Flow との統合
Swarm Coordination との組み合わせ
# Initialize swarm for coordination
claude-flow swarm init --topology mesh
# Execute stream chain with swarm agents
claude-flow stream-chain run \
"Agent 1: Research task" \
"Agent 2: Implement solution" \
"Agent 3: Test implementation" \
"Agent 4: Review and refine"
メモリ統合
Stream-Chain は、セッションをまたいでコンテキストを保持できるよう、チェーンのコンテキストを自動的にメモリに保存します。
# Execute chain with memory
claude-flow stream-chain run \
"Analyze requirements" \
"Design architecture" \
--verbose
# Results stored in .claude-flow$memory$stream-chain/
ニューラルパターンのトレーニング
成功したチェーンは、パフォーマンス向上のためにニューラルパターンをトレーニングします。
# Enable neural training
claude-flow stream-chain pipeline optimize --debug
# Patterns learned and stored for future optimizations
トラブルシューティング
チェーンのタイムアウト
ステップがタイムアウトする場合は、タイムアウト値を増やします。
claude-flow stream-chain run "complex task" --timeout 120
コンテキストの喪失
コンテキストが適切に引き継がれない場合は、--debug を使用します。
claude-flow stream-chain run "step 1" "step 2" --debug
パイプラインが見つからない
パイプライン名とカスタム定義を確認します。
# Check available pipelines
cat .claude-flow$config.json | grep -A 10 "streamChain"
パフォーマンス特性
- スループット:毎分2~5ステップ(複雑さによって異なります)
- コンテキストサイズ:1ステップあたり最大100Kトークン
- メモリ使用量:アクティブなチェーンあたり約50MB
- 並行実行:チェーンの並列実行に対応
関連スキル
- SPARC Methodology:体系的な開発ワークフロー
- Swarm Coordination:マルチエージェントのオーケストレーション
- Memory Management:永続的なコンテキストストレージ
- Neural Patterns:適応学習
サンプルリポジトリ
開発ワークフロー全体
# 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
コードレビューのパイプライン
# 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"
移行アシスタント
# 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"
まとめ
Stream-Chain は、以下の機能によって高度な複数ステップのワークフローを実現します。
- 逐次処理:各ステップが前の結果を基に構築されます
- コンテキストの保持:すべての出力履歴がチェーンを通じて引き継がれます
- 柔軟なオーケストレーション:カスタムチェーンまたは事前定義済みパイプライン
- エージェントの調整:自然なマルチエージェント連携パターン
- データ変換:シンプルなステップを通じた複雑な処理
カスタムワークフローには run を、実績のあるソリューションには pipeline を使用します。