swarm-advanced について
swarm-advancedは、分散型の調査、開発、テスト、分析をエージェントで調整するClaude Flowスキルです。トポロジーやタスク戦略、メモリー、監視、復旧のパターンを、MCPツールとCLIの例で解説します。
主な機能
- 01メッシュ、階層、スター、リング型トポロジー
- 02専門エージェントの調整戦略
- 03並列・順次タスクのワークフロー
- 04セッションをまたぐメモリーと名前空間
- 05swarm監視とメトリクス収集
- 06フォールトトレランスと復旧パターン
活用シーン
- 01調査情報を並行して収集・統合
- 02フルスタック実装とレビューの調整
- 03分散テストと品質チェックの実行
- 04コード、セキュリティ、性能の分析
MCP 対応
このスキルではClaude Flow MCPツールを使ったswarmの初期化、エージェントの起動、タスクのオーケストレーション、メモリー管理、実行監視を扱い、CLIでの代替方法も示します。
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill swarm-advancedインストール後、Claude Code で/swarm-advancedを入力して読み込まれたか確認します。
詳細
高度なスウォームオーケストレーション
分散型の調査、開発、テストのワークフローに向けた高度なスウォームパターンを習得します。このスキルでは、MCP ツールと CLI コマンドの両方を使用した、包括的なオーケストレーション戦略を取り上げます。
クイックスタート
前提条件
# Ensure Claude Flow is installed
npm install -g claude-flow@alpha
# Add MCP server (if using MCP tools)
claude mcp add claude-flow npx claude-flow@alpha mcp start
基本パターン
// 1. Initialize swarm topology
mcp__claude-flow__swarm_init({ topology: "mesh", maxAgents: 6 })
// 2. Spawn specialized agents
mcp__claude-flow__agent_spawn({ type: "researcher", name: "Agent 1" })
// 3. Orchestrate tasks
mcp__claude-flow__task_orchestrate({ task: "...", strategy: "parallel" })
コアコンセプト
スウォームトポロジー
メッシュトポロジー - ピアツーピア通信を行います。調査や分析に最適です
- すべてのエージェントが直接通信します
- 柔軟性と回復力に優れています
- 用途:調査、分析、ブレインストーミング
階層型トポロジー - 開発に最適な、部下を持つコーディネーター型です
- 明確な指揮系統を備えています
- 順次実行のワークフローをサポートします
- 用途:開発、構造化されたワークフロー
スター型トポロジー - テストに最適な、中央コーディネーター型です
- 制御と監視を一元化します
- 調整しながら並列実行します
- 用途:テスト、検証、品質保証
リング型トポロジー - 順次処理のチェーンです
- 段階的に処理します
- パイプライン型のワークフローです
- 用途:多段階処理、データパイプライン
エージェント戦略
適応型 - タスクの複雑さに応じて動的に調整します バランス型 - エージェント間で作業を均等に分配します 特化型 - タスクに応じてエージェントを割り当てます 並列型 - 同時実行を最大化します
パターン 1:調査スウォーム
目的
情報の並列収集、分析、統合を通じて、詳細な調査を行います。
アーキテクチャ
// Initialize research swarm
mcp__claude-flow__swarm_init({
"topology": "mesh",
"maxAgents": 6,
"strategy": "adaptive"
})
// Spawn research team
const researchAgents = [
{
type: "researcher",
name: "Web Researcher",
capabilities: ["web-search", "content-extraction", "source-validation"]
},
{
type: "researcher",
name: "Academic Researcher",
capabilities: ["paper-analysis", "citation-tracking", "literature-review"]
},
{
type: "analyst",
name: "Data Analyst",
capabilities: ["data-processing", "statistical-analysis", "visualization"]
},
{
type: "analyst",
name: "Pattern Analyzer",
capabilities: ["trend-detection", "correlation-analysis", "outlier-detection"]
},
{
type: "documenter",
name: "Report Writer",
capabilities: ["synthesis", "technical-writing", "formatting"]
}
]
// Spawn all agents
researchAgents.forEach(agent => {
mcp__claude-flow__agent_spawn({
type: agent.type,
name: agent.name,
capabilities: agent.capabilities
})
})
調査ワークフロー
フェーズ 1:情報収集
// Parallel information collection
mcp__claude-flow__parallel_execute({
"tasks": [
{
"id": "web-search",
"command": "search recent publications and articles"
},
{
"id": "academic-search",
"command": "search academic databases and papers"
},
{
"id": "data-collection",
"command": "gather relevant datasets and statistics"
},
{
"id": "expert-search",
"command": "identify domain experts and thought leaders"
}
]
})
// Store research findings in memory
mcp__claude-flow__memory_usage({
"action": "store",
"key": "research-findings-" + Date.now(),
"value": JSON.stringify(findings),
"namespace": "research",
"ttl": 604800 // 7 days
})
フェーズ 2:分析と検証
// Pattern recognition in findings
mcp__claude-flow__pattern_recognize({
"data": researchData,
"patterns": ["trend", "correlation", "outlier", "emerging-pattern"]
})
// Cognitive analysis
mcp__claude-flow__cognitive_analyze({
"behavior": "research-synthesis"
})
// Quality assessment
mcp__claude-flow__quality_assess({
"target": "research-sources",
"criteria": ["credibility", "relevance", "recency", "authority"]
})
// Cross-reference validation
mcp__claude-flow__neural_patterns({
"action": "analyze",
"operation": "fact-checking",
"metadata": { "sources": sourcesArray }
})
フェーズ 3:ナレッジ管理
// Search existing knowledge base
mcp__claude-flow__memory_search({
"pattern": "topic X",
"namespace": "research",
"limit": 20
})
// Create knowledge graph connections
mcp__claude-flow__neural_patterns({
"action": "learn",
"operation": "knowledge-graph",
"metadata": {
"topic": "X",
"connections": relatedTopics,
"depth": 3
}
})
// Store connections for future use
mcp__claude-flow__memory_usage({
"action": "store",
"key": "knowledge-graph-X",
"value": JSON.stringify(knowledgeGraph),
"namespace": "research$graphs",
"ttl": 2592000 // 30 days
})
フェーズ 4:レポート生成
// Orchestrate report generation
mcp__claude-flow__task_orchestrate({
"task": "generate comprehensive research report",
"strategy": "sequential",
"priority": "high",
"dependencies": ["gather", "analyze", "validate", "synthesize"]
})
// Monitor research progress
mcp__claude-flow__swarm_status({
"swarmId": "research-swarm"
})
// Generate final report
mcp__claude-flow__workflow_execute({
"workflowId": "research-report-generation",
"params": {
"findings": findings,
"format": "comprehensive",
"sections": ["executive-summary", "methodology", "findings", "analysis", "conclusions", "references"]
}
})
CLI による代替手段
# Quick research swarm
npx claude-flow swarm "research AI trends in 2025" \
--strategy research \
--mode distributed \
--max-agents 6 \
--parallel \
--output research-report.md
パターン 2:開発スウォーム
目的
連携する専門エージェントを通じて、フルスタック開発を行います。
アーキテクチャ
// Initialize development swarm with hierarchy
mcp__claude-flow__swarm_init({
"topology": "hierarchical",
"maxAgents": 8,
"strategy": "balanced"
})
// Spawn development team
const devTeam = [
{ type: "architect", name: "System Architect", role: "coordinator" },
{ type: "coder", name: "Backend Developer", capabilities: ["node", "api", "database"] },
{ type: "coder", name: "Frontend Developer", capabilities: ["react", "ui", "ux"] },
{ type: "coder", name: "Database Engineer", capabilities: ["sql", "nosql", "optimization"] },
{ type: "tester", name: "QA Engineer", capabilities: ["unit", "integration", "e2e"] },
{ type: "reviewer", name: "Code Reviewer", capabilities: ["security", "performance", "best-practices"] },
{ type: "documenter", name: "Technical Writer", capabilities: ["api-docs", "guides", "tutorials"] },
{ type: "monitor", name: "DevOps Engineer", capabilities: ["ci-cd", "deployment", "monitoring"] }
]
// Spawn all team members
devTeam.forEach(member => {
mcp__claude-flow__agent_spawn({
type: member.type,
name: member.name,
capabilities: member.capabilities,
swarmId: "dev-swarm"
})
})
開発ワークフロー
フェーズ 1:アーキテクチャと設計
// System architecture design
mcp__claude-flow__task_orchestrate({
"task": "design system architecture for REST API",
"strategy": "sequential",
"priority": "critical",
"assignTo": "System Architect"
})
// Store architecture decisions
mcp__claude-flow__memory_usage({
"action": "store",
"key": "architecture-decisions",
"value": JSON.stringify(architectureDoc),
"namespace": "development$design"
})
フェーズ 2:並列実装
// Parallel development tasks
mcp__claude-flow__parallel_execute({
"tasks": [
{
"id": "backend-api",
"command": "implement REST API endpoints",
"assignTo": "Backend Developer"
},
{
"id": "frontend-ui",
"command": "build user interface components",
"assignTo": "Frontend Developer"
},
{
"id": "database-schema",
"command": "design and implement database schema",
"assignTo": "Database Engineer"
},
{
"id": "api-documentation",
"command": "create API documentation",
"assignTo": "Technical Writer"
}
]
})
// Monitor development progress
mcp__claude-flow__swarm_monitor({
"swarmId": "dev-swarm",
"interval": 5000
})
フェーズ 3:テストと検証
// Comprehensive testing
mcp__claude-flow__batch_process({
"items": [
{ type: "unit", target: "all-modules" },
{ type: "integration", target: "api-endpoints" },
{ type: "e2e", target: "user-flows" },
{ type: "performance", target: "critical-paths" }
],
"operation": "execute-tests"
})
// Quality assessment
mcp__claude-flow__quality_assess({
"target": "codebase",
"criteria": ["coverage", "complexity", "maintainability", "security"]
})
フェーズ 4:レビューとデプロイ
// Code review workflow
mcp__claude-flow__workflow_execute({
"workflowId": "code-review-process",
"params": {
"reviewers": ["Code Reviewer"],
"criteria": ["security", "performance", "best-practices"]
}
})
// CI/CD pipeline
mcp__claude-flow__pipeline_create({
"config": {
"stages": ["build", "test", "security-scan", "deploy"],
"environment": "production"
}
})
CLI による代替手段
# Quick development swarm
npx claude-flow swarm "build REST API with authentication" \
--strategy development \
--mode hierarchical \
--monitor \
--output sqlite
パターン 3:テストスウォーム
目的
分散テストを通じて、包括的な品質保証を行います。
アーキテクチャ
// Initialize testing swarm with star topology
mcp__claude-flow__swarm_init({
"topology": "star",
"maxAgents": 7,
"strategy": "parallel"
})
// Spawn testing team
const testingTeam = [
{
type: "tester",
name: "Unit Test Coordinator",
capabilities: ["unit-testing", "mocking", "coverage", "tdd"]
},
{
type: "tester",
name: "Integration Tester",
capabilities: ["integration", "api-testing", "contract-testing"]
},
{
type: "tester",
name: "E2E Tester",
capabilities: ["e2e", "ui-testing", "user-flows", "selenium"]
},
{
type: "tester",
name: "Performance Tester",
capabilities: ["load-testing", "stress-testing", "benchmarking"]
},
{
type: "monitor",
name: "Security Tester",
capabilities: ["security-testing", "penetration-testing", "vulnerability-scanning"]
},
{
type: "analyst",
name: "Test Analyst",
capabilities: ["coverage-analysis", "test-optimization", "reporting"]
},
{
type: "documenter",
name: "Test Documenter",
capabilities: ["test-documentation", "test-plans", "reports"]
}
]
// Spawn all testers
testingTeam.forEach(tester => {
mcp__claude-flow__agent_spawn({
type: tester.type,
name: tester.name,
capabilities: tester.capabilities,
swarmId: "testing-swarm"
})
})
テストワークフロー
フェーズ 1:テスト計画
// Analyze test coverage requirements
mcp__claude-flow__quality_assess({
"target": "test-coverage",
"criteria": [
"line-coverage",
"branch-coverage",
"function-coverage",
"edge-cases"
]
})
// Identify test scenarios
mcp__claude-flow__pattern_recognize({
"data": testScenarios,
"patterns": [
"edge-case",
"boundary-condition",
"error-path",
"happy-path"
]
})
// Store test plan
mcp__claude-flow__memory_usage({
"action": "store",
"key": "test-plan-" + Date.now(),
"value": JSON.stringify(testPlan),
"namespace": "testing$plans"
})
フェーズ 2:並列テスト実行
// Execute all test suites in parallel
mcp__claude-flow__parallel_execute({
"tasks": [
{
"id": "unit-tests",
"command": "npm run test:unit",
"assignTo": "Unit Test Coordinator"
},
{
"id": "integration-tests",
"command": "npm run test:integration",
"assignTo": "Integration Tester"
},
{
"id": "e2e-tests",
"command": "npm run test:e2e",
"assignTo": "E2E Tester"
},
{
"id": "performance-tests",
"command": "npm run test:performance",
"assignTo": "Performance Tester"
},
{
"id": "security-tests",
"command": "npm run test:security",
"assignTo": "Security Tester"
}
]
})
// Batch process test suites
mcp__claude-flow__batch_process({
"items": testSuites,
"operation": "execute-test-suite"
})
フェーズ 3:パフォーマンスとセキュリティ
// Run performance benchmarks
mcp__claude-flow__benchmark_run({
"suite": "comprehensive-performance"
})
// Bottleneck analysis
mcp__claude-flow__bottleneck_analyze({
"component": "application",
"metrics": ["response-time", "throughput", "memory", "cpu"]
})
// Security scanning
mcp__claude-flow__security_scan({
"target": "application",
"depth": "comprehensive"
})
// Vulnerability analysis
mcp__claude-flow__error_analysis({
"logs": securityScanLogs
})
フェーズ 4:監視とレポート
// Real-time test monitoring
mcp__claude-flow__swarm_monitor({
"swarmId": "testing-swarm",
"interval": 2000
})
// Generate comprehensive test report
mcp__claude-flow__performance_report({
"format": "detailed",
"timeframe": "current-run"
})
// Get test results
mcp__claude-flow__task_results({
"taskId": "test-execution-001"
})
// Trend analysis
mcp__claude-flow__trend_analysis({
"metric": "test-coverage",
"period": "30d"
})
CLI による代替手段
# Quick testing swarm
npx claude-flow swarm "test application comprehensively" \
--strategy testing \
--mode star \
--parallel \
--timeout 600
パターン 4:分析スウォーム
目的
専門のアナライザーを通じて、コードとシステムを詳細に分析します。
アーキテクチャ
// Initialize analysis swarm
mcp__claude-flow__swarm_init({
"topology": "mesh",
"maxAgents": 5,
"strategy": "adaptive"
})
// Spawn analysis specialists
const analysisTeam = [
{
type: "analyst",
name: "Code Analyzer",
capabilities: ["static-analysis", "complexity-analysis", "dead-code-detection"]
},
{
type: "analyst",
name: "Security Analyzer",
capabilities: ["security-scan", "vulnerability-detection", "dependency-audit"]
},
{
type: "analyst",
name: "Performance Analyzer",
capabilities: ["profiling", "bottleneck-detection", "optimization"]
},
{
type: "analyst",
name: "Architecture Analyzer",
capabilities: ["dependency-analysis", "coupling-detection", "modularity-assessment"]
},
{
type: "documenter",
name: "Analysis Reporter",
capabilities: ["reporting", "visualization", "recommendations"]
}
]
// Spawn all analysts
analysisTeam.forEach(analyst => {
mcp__claude-flow__agent_spawn({
type: analyst.type,
name: analyst.name,
capabilities: analyst.capabilities
})
})
分析ワークフロー
// Parallel analysis execution
mcp__claude-flow__parallel_execute({
"tasks": [
{ "id": "analyze-code", "command": "analyze codebase structure and quality" },
{ "id": "analyze-security", "command": "scan for security vulnerabilities" },
{ "id": "analyze-performance", "command": "identify performance bottlenecks" },
{ "id": "analyze-architecture", "command": "assess architectural patterns" }
]
})
// Generate comprehensive analysis report
mcp__claude-flow__performance_report({
"format": "detailed",
"timeframe": "current"
})
// Cost analysis
mcp__claude-flow__cost_analysis({
"timeframe": "30d"
})
高度なテクニック
エラー処理とフォールトトレランス
// Setup fault tolerance for all agents
mcp__claude-flow__daa_fault_tolerance({
"agentId": "all",
"strategy": "auto-recovery"
})
// Error handling pattern
try {
await mcp__claude-flow__task_orchestrate({
"task": "complex operation",
"strategy": "parallel",
"priority": "high"
})
} catch (error) {
// Check swarm health
const status = await mcp__claude-flow__swarm_status({})
// Analyze error patterns
await mcp__claude-flow__error_analysis({
"logs": [error.message]
})
// Auto-recovery attempt
if (status.healthy) {
await mcp__claude-flow__task_orchestrate({
"task": "retry failed operation",
"strategy": "sequential"
})
}
}
メモリと状態の管理
// Cross-session persistence
mcp__claude-flow__memory_persist({
"sessionId": "swarm-session-001"
})
// Namespace management for different swarms
mcp__claude-flow__memory_namespace({
"namespace": "research-swarm",
"action": "create"
})
// Create state snapshot
mcp__claude-flow__state_snapshot({
"name": "development-checkpoint-1"
})
// Restore from snapshot if needed
mcp__claude-flow__context_restore({
"snapshotId": "development-checkpoint-1"
})
// Backup memory stores
mcp__claude-flow__memory_backup({
"path": "$workspaces$claude-code-flow$backups$swarm-memory.json"
})
ニューラルパターン学習
// Train neural patterns from successful workflows
mcp__claude-flow__neural_train({
"pattern_type": "coordination",
"training_data": JSON.stringify(successfulWorkflows),
"epochs": 50
})
// Adaptive learning from experience
mcp__claude-flow__learning_adapt({
"experience": {
"workflow": "research-to-report",
"success": true,
"duration": 3600,
"quality": 0.95
}
})
// Pattern recognition for optimization
mcp__claude-flow__pattern_recognize({
"data": workflowMetrics,
"patterns": ["bottleneck", "optimization-opportunity", "efficiency-gain"]
})
ワークフローの自動化
// Create reusable workflow
mcp__claude-flow__workflow_create({
"name": "full-stack-development",
"steps": [
{ "phase": "design", "agents": ["architect"] },
{ "phase": "implement", "agents": ["backend-dev", "frontend-dev"], "parallel": true },
{ "phase": "test", "agents": ["tester", "security-tester"], "parallel": true },
{ "phase": "review", "agents": ["reviewer"] },
{ "phase": "deploy", "agents": ["devops"] }
],
"triggers": ["on-commit", "scheduled-daily"]
})
// Setup automation rules
mcp__claude-flow__automation_setup({
"rules": [
{
"trigger": "file-changed",
"pattern": "*.js",
"action": "run-tests"
},
{
"trigger": "PR-created",
"action": "code-review-swarm"
}
]
})
// Event-driven triggers
mcp__claude-flow__trigger_setup({
"events": ["code-commit", "PR-merge", "deployment"],
"actions": ["test", "analyze", "document"]
})
パフォーマンスの最適化
// Topology optimization
mcp__claude-flow__topology_optimize({
"swarmId": "current-swarm"
})
// Load balancing
mcp__claude-flow__load_balance({
"swarmId": "development-swarm",
"tasks": taskQueue
})
// Agent coordination sync
mcp__claude-flow__coordination_sync({
"swarmId": "development-swarm"
})
// Auto-scaling
mcp__claude-flow__swarm_scale({
"swarmId": "development-swarm",
"targetSize": 12
})
監視とメトリクス
// Real-time swarm monitoring
mcp__claude-flow__swarm_monitor({
"swarmId": "active-swarm",
"interval": 3000
})
// Collect comprehensive metrics
mcp__claude-flow__metrics_collect({
"components": ["agents", "tasks", "memory", "performance"]
})
// Health monitoring
mcp__claude-flow__health_check({
"components": ["swarm", "agents", "neural", "memory"]
})
// Usage statistics
mcp__claude-flow__usage_stats({
"component": "swarm-orchestration"
})
// Trend analysis
mcp__claude-flow__trend_analysis({
"metric": "agent-performance",
"period": "7d"
})
ベストプラクティス
1. 適切なトポロジーの選択
- メッシュ:調査、ブレインストーミング、共同分析
- 階層型:構造化された開発、順次実行のワークフロー
- スター型:テスト、検証、一元的な調整
- リング型:パイプライン処理、段階的なワークフロー
2. エージェントの特化
- 各エージェントに特定の機能を割り当てます
- 責任範囲の重複を避けます
- 複雑なワークフローには調整エージェントを使用します
- エージェント間の通信にはメモリを活用します
3. 並列実行
- 並列化できる独立したタスクを特定します
- 依存関係のあるタスクには逐次実行を使用します
- 並列実行中のリソース使用状況を監視します
- 適切なエラー処理を実装します
4. メモリ管理
- メモリを整理するために名前空間を使用します
- 適切な TTL 値を設定します
- 定期的にバックアップを作成します
- チェックポイント用に状態のスナップショットを実装します
5. 監視と最適化
- スウォームの健全性を定期的に監視します
- メトリクスを収集して分析します
- パフォーマンスに基づいてトポロジーを最適化します
- 成功事例から学習するためにニューラルパターンを使用します
6. エラー復旧
- フォールトトレランス戦略を実装します
- 自動復旧メカニズムを使用します
- エラーパターンを分析します
- フォールバックワークフローを作成します
実際の使用例
例 1:AI 研究プロジェクト
// Research AI trends, analyze findings, generate report
mcp__claude-flow__swarm_init({ topology: "mesh", maxAgents: 6 })
// Spawn: 2 researchers, 2 analysts, 1 synthesizer, 1 documenter
// Parallel gather → Analyze patterns → Synthesize → Report
例 2:フルスタックアプリケーション
// Build complete web application with testing
mcp__claude-flow__swarm_init({ topology: "hierarchical", maxAgents: 8 })
// Spawn: 1 architect, 2 devs, 1 db engineer, 2 testers, 1 reviewer, 1 devops
// Design → Parallel implement → Test → Review → Deploy
例 3:セキュリティ監査
// Comprehensive security analysis
mcp__claude-flow__swarm_init({ topology: "star", maxAgents: 5 })
// Spawn: 1 coordinator, 1 code analyzer, 1 security scanner, 1 penetration tester, 1 reporter
// Parallel scan → Vulnerability analysis → Penetration test → Report
例 4:パフォーマンス最適化
// Identify and fix performance bottlenecks
mcp__claude-flow__swarm_init({ topology: "mesh", maxAgents: 4 })
// Spawn: 1 profiler, 1 bottleneck analyzer, 1 optimizer, 1 tester
// Profile → Identify bottlenecks → Optimize → Validate
トラブルシューティング
よくある問題
問題:スウォームエージェントが適切に連携しない 解決策:トポロジーの選択を確認し、メモリ使用量を検証して、モニタリングを有効にします
問題:並列実行が失敗する 解決策:タスクの依存関係を検証し、リソース制限を確認して、エラー処理を実装します
問題:メモリの永続化が機能しない 解決策:名前空間を検証し、TTL 設定を確認して、バックアップ構成を確実にします
問題:パフォーマンスが低下する 解決策:トポロジーを最適化し、エージェント数を減らして、ボトルネックを分析します
関連スキル
sparc-methodology- 体系的な開発ワークフローgithub-integration- リポジトリ管理と自動化neural-patterns- AI を活用した連携の最適化memory-management- セッションをまたいだ状態の永続化
参考資料
バージョン:2.0.0 最終更新日:2025-10-19 スキルレベル:上級 推定学習時間:2~3 時間