mcpField
H
hive-mind-advanced

hive-mind-advanced

github.com/ruvnetエージェントワークフロー80.0k1.1k 回インストール今日更新
リポジトリ

hive-mind-advanced について

hive-mind-advancedは、Claude Flowのマルチエージェント調整システム向けスキルです。Queen主導の階層構造に集合メモリと合意形成を組み合わせ、タスク分配と意思決定を支援します。

主な機能

  1. 01Queenと専門Workerの階層的な連携
  2. 02多数決、加重、ビザンチン合意への対応
  3. 03集合メモリの共有と検索
  4. 04タスクの自動割り当てとWorkerの拡縮
  5. 05セッションのチェックポイント、停止、再開

活用シーン

  1. 01ソフトウェア開発で複数エージェントを調整する
  2. 02合意形成でアーキテクチャや実装方法を選ぶ
  3. 03複数のHive間で集合メモリを共有する
  4. 04長期の共同作業セッションを停止・再開する

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/ruvnet/ruflo --skill hive-mind-advanced

インストール後、Claude Code で/hive-mind-advancedを入力して読み込まれたか確認します。

詳細

Hive Mind Advanced Skill

女王主導のアーキテクチャ、ビザンチン合意、集合記憶を活用した高度なマルチエージェント連携のために、先進的な Hive Mind 集合知システムを習得しましょう。

概要

Hive Mind システムは、Claude Flow におけるマルチエージェント連携の最先端を体現しています。女王主導の階層型アーキテクチャを実装し、戦略的な女王コーディネーターが、集合的な意思決定と共有メモリを通じて、専門化されたワーカーエージェントを指揮します。

コアコンセプト

アーキテクチャパターン

女王主導の連携

  • 戦略的な女王エージェントが高レベルの目標を統括します
  • 戦術的な女王が中レベルの実行を管理します
  • 適応型の女王がパフォーマンスに基づいて戦略を動的に調整します

ワーカーの専門化

  • リサーチャーエージェント:分析と調査
  • コーダーエージェント:実装と開発
  • アナリストエージェント:データ処理と指標
  • テスターエージェント:品質保証と検証
  • アーキテクトエージェント:システム設計と計画
  • レビュー担当エージェント:コードレビューと改善
  • オプティマイザーエージェント:パフォーマンスの向上
  • ドキュメント作成エージェント:ドキュメントの生成

集合記憶システム

  • すべてのエージェント間で共有されるナレッジベース
  • メモリ圧迫への対応機能を備えた LRU キャッシュ
  • WAL モードによる SQLite 永続化
  • メモリの統合と関連付け
  • アクセスパターンの追跡と最適化
合意形成メカニズム

多数決 最も多くの票を得た選択肢が勝つ、単純な投票方式です。

重み付き合意 女王の票を 3 倍の重みとして扱い、戦略的な指針を提供します。

ビザンチン障害耐性 意思決定の承認に 3 分の 2 の多数を必要とし、エージェントに障害があっても堅牢な合意を実現します。

はじめに

1. Hive Mind を初期化する
# Basic initialization
npx claude-flow hive-mind init

# Force reinitialize
npx claude-flow hive-mind init --force

# Custom configuration
npx claude-flow hive-mind init --config hive-config.json
2. スウォームを起動する
# Basic spawn with objective
npx claude-flow hive-mind spawn "Build microservices architecture"

# Strategic queen type
npx claude-flow hive-mind spawn "Research AI patterns" --queen-type strategic

# Tactical queen with max workers
npx claude-flow hive-mind spawn "Implement API" --queen-type tactical --max-workers 12

# Adaptive queen with consensus
npx claude-flow hive-mind spawn "Optimize system" --queen-type adaptive --consensus byzantine

# Generate Claude Code commands
npx claude-flow hive-mind spawn "Build full-stack app" --claude
3. ステータスを監視する
# Check hive mind status
npx claude-flow hive-mind status

# Get detailed metrics
npx claude-flow hive-mind metrics

# Monitor collective memory
npx claude-flow hive-mind memory

高度なワークフロー

セッション管理

セッションの作成と管理

# List active sessions
npx claude-flow hive-mind sessions

# Pause a session
npx claude-flow hive-mind pause <session-id>

# Resume a paused session
npx claude-flow hive-mind resume <session-id>

# Stop a running session
npx claude-flow hive-mind stop <session-id>

セッション機能

  • チェックポイントの自動作成
  • 完了率による進捗の追跡
  • 親子プロセスの管理
  • イベント追跡機能付きのセッションログ
  • エクスポート$インポート機能
合意形成

Hive Mind は、構造化された投票を通じて合意を形成します。

// Programmatic consensus building
const decision = await hiveMind.buildConsensus(
  'Architecture pattern selection',
  ['microservices', 'monolith', 'serverless']
);

// Result includes:
// - decision: Winning option
// - confidence: Vote percentage
// - votes: Individual agent votes

合意形成アルゴリズム

  1. 多数決 - 単純な民主的投票
  2. 重み付き - 女王の投票権は 3 倍
  3. ビザンチン - 3 分の 2 の特別多数が必要
集合記憶

知識の保存

// Store in collective memory
await memory.store('api-patterns', {
  rest: { pros: [...], cons: [...] },
  graphql: { pros: [...], cons: [...] }
}, 'knowledge', { confidence: 0.95 });

メモリの種類

  • knowledge:永続的な知見(TTL なし)
  • context:セッションコンテキスト(TTL 1 時間)
  • task:タスク固有のデータ(TTL 30 分)
  • result:実行結果(永続、圧縮)
  • error:エラーログ(TTL 24 時間)
  • metric:パフォーマンス指標(TTL 1 時間)
  • consensus:意思決定の記録(永続)
  • system:システム設定(永続)

検索と取得

// Search memory by pattern
const results = await memory.search('api*', {
  type: 'knowledge',
  minConfidence: 0.8,
  limit: 50
});

// Get related memories
const related = await memory.getRelated('api-patterns', 10);

// Build associations
await memory.associate('rest-api', 'authentication', 0.9);
タスクの分配

ワーカーの自動割り当て

システムは以下の情報に基づいて、タスクをインテリジェントに割り当てます。

  • エージェントの専門性とのキーワード照合
  • 過去のパフォーマンス指標
  • ワーカーの稼働状況と負荷
  • タスクの複雑さの分析
// Create task (auto-assigned)
const task = await hiveMind.createTask(
  'Implement user authentication',
  priority: 8,
  { estimatedDuration: 30000 }
);

自動スケーリング

// Configure auto-scaling
const config = {
  autoScale: true,
  maxWorkers: 12,
  scaleUpThreshold: 2, // Pending tasks per idle worker
  scaleDownThreshold: 2 // Idle workers above pending tasks
};

統合パターン

Claude Code との連携

Claude Code のスポーンコマンドを直接生成します。

npx claude-flow hive-mind spawn "Build REST API" --claude

出力:

Task("Queen Coordinator", "Orchestrate REST API development...", "coordinator")
Task("Backend Developer", "Implement Express routes...", "backend-dev")
Task("Database Architect", "Design PostgreSQL schema...", "code-analyzer")
Task("Test Engineer", "Create Jest test suite...", "tester")
SPARC 方法論との連携
# Use hive mind for SPARC workflow
npx claude-flow sparc tdd "User authentication" --hive-mind

# Spawns:
# - Specification agent
# - Architecture agent
# - Coder agents
# - Tester agents
# - Reviewer agents
GitHub 連携との統合
# Repository analysis with hive mind
npx claude-flow hive-mind spawn "Analyze repo quality" --objective "owner$repo"

# PR review coordination
npx claude-flow hive-mind spawn "Review PR #123" --queen-type tactical

パフォーマンスの最適化

メモリの最適化

集合記憶システムには、高度な最適化機能が含まれています。

LRU キャッシュ

  • 設定可能なキャッシュサイズ(デフォルト:1000 件)
  • メモリ圧迫への対応(デフォルト:50MB)
  • 使用頻度が最も低いエントリを自動的に削除

データベースの最適化

  • WAL(先行書き込みログ)モード
  • 64MB のキャッシュサイズ
  • 256MB のメモリマッピング
  • 一般的なクエリ向けのプリペアドステートメント
  • ANALYZE と OPTIMIZE の自動実行

オブジェクトプーリング

  • クエリ結果のプーリング
  • メモリエントリのプーリング
  • ガベージコレクションの負荷を軽減
パフォーマンス指標
// Get performance insights
const insights = hiveMind.getPerformanceInsights();

// Includes:
// - asyncQueue utilization
// - Batch processing stats
// - Success rates
// - Average processing times
// - Memory efficiency
タスク実行

並列処理

  • エージェントのバッチ起動(1バッチあたり5エージェント)
  • タスクの同時オーケストレーション
  • 非同期操作の最適化
  • ブロッキングを伴わないタスク割り当て

ベンチマーク

  • バッチ起動が10~20倍高速化
  • 全体的な速度が2.8~4.4倍向上
  • トークンを32.3%削減
  • SWE-Bench の解決率84.8%

設定

Hive Mind の設定
{
  "objective": "Build microservices",
  "name": "my-hive",
  "queenType": "strategic", // strategic | tactical | adaptive
  "maxWorkers": 8,
  "consensusAlgorithm": "byzantine", // majority | weighted | byzantine
  "autoScale": true,
  "memorySize": 100, // MB
  "taskTimeout": 60, // minutes
  "encryption": false
}
メモリの設定
{
  "maxSize": 100, // MB
  "compressionThreshold": 1024, // bytes
  "gcInterval": 300000, // 5 minutes
  "cacheSize": 1000,
  "cacheMemoryMB": 50,
  "enablePooling": true,
  "enableAsyncOperations": true
}

フックの統合

Hive Mind は、Claude Flow のフックと統合し、自動化を実現します。

タスク開始前のフック

  • ファイルの種類に応じてエージェントを自動割り当て
  • 目的の複雑さを検証
  • トポロジーの選択を最適化
  • 検索パターンをキャッシュ

タスク完了後のフック

  • 成果物を自動フォーマット
  • ニューラルパターンを学習
  • 集合メモリを更新
  • パフォーマンスのボトルネックを分析

セッションフック

  • セッションの要約を生成
  • チェックポイントデータを永続化
  • 包括的なメトリクスを追跡
  • 実行コンテキストを復元

ベストプラクティス

1. 適切な Queen タイプを選択する

戦略型 Queen - 調査、計画、分析向け

npx claude-flow hive-mind spawn "Research ML frameworks" --queen-type strategic

戦術型 Queen - 実装、実行向け

npx claude-flow hive-mind spawn "Build authentication" --queen-type tactical

適応型 Queen - 最適化、動的なタスク向け

npx claude-flow hive-mind spawn "Optimize performance" --queen-type adaptive
2. 合意形成を活用する

重要な決定には合意形成を利用します。

  • アーキテクチャパターンの選択
  • 技術スタックの選定
  • 実装方法
  • コードレビューの承認
  • リリースの準備状況
3. 集合メモリを活用する

学習内容を保存する

// After successful pattern implementation
await memory.store('auth-pattern', {
  approach: 'JWT with refresh tokens',
  pros: ['Stateless', 'Scalable'],
  cons: ['Token size', 'Revocation complexity'],
  implementation: {...}
}, 'knowledge', { confidence: 0.95 });

関連付けを構築する

// Link related concepts
await memory.associate('jwt-auth', 'refresh-tokens', 0.9);
await memory.associate('jwt-auth', 'oauth2', 0.7);
4. パフォーマンスを監視する
# Regular status checks
npx claude-flow hive-mind status

# Track metrics
npx claude-flow hive-mind metrics

# Analyze memory usage
npx claude-flow hive-mind memory
5. セッション管理

頻繁にチェックポイントを作成する

// Create checkpoints at key milestones
await sessionManager.saveCheckpoint(
  sessionId,
  'api-routes-complete',
  { completedRoutes: [...], remaining: [...] }
);

セッションを再開する

# Resume from any previous state
npx claude-flow hive-mind resume <session-id>

トラブルシューティング

メモリの問題

メモリ使用量が多い

# Run garbage collection
npx claude-flow hive-mind memory --gc

# Optimize database
npx claude-flow hive-mind memory --optimize

# Export and clear
npx claude-flow hive-mind memory --export --clear

キャッシュヒット率が低い

// Increase cache size in config
{
  "cacheSize": 2000,
  "cacheMemoryMB": 100
}
パフォーマンスの問題

タスクの割り当てが遅い

// Enable worker type caching
// The system caches best worker matches for 5 minutes
// Automatic - no configuration needed

キュー使用率が高い

// Increase async queue concurrency
{
  "asyncQueueConcurrency": 20 // Default: min(maxWorkers * 2, 20)
}
合意形成の失敗

合意に至らない(ビザンチン障害)

# Switch to weighted consensus for more decisive results
npx claude-flow hive-mind spawn "..." --consensus weighted

# Or use simple majority
npx claude-flow hive-mind spawn "..." --consensus majority

高度なトピック

カスタムワーカータイプ

.claude.agents/ に特化型ワーカーを定義します。

name: security-auditor
type: specialist
capabilities:
  - vulnerability-scanning
  - security-review
  - penetration-testing
  - compliance-checking
priority: high
ニューラルパターンの学習

システムは成功したパターンを学習します。

// Automatic pattern learning
// Happens after successful task completion
// Stores in collective memory
// Improves future task matching
複数 Hive の連携

複数の Hive Mind を同時に実行します。

# Frontend hive
npx claude-flow hive-mind spawn "Build UI" --name frontend-hive

# Backend hive
npx claude-flow hive-mind spawn "Build API" --name backend-hive

# They share collective memory for coordination
セッションのエクスポート/インポート
# Export session for backup
npx claude-flow hive-mind export <session-id> --output backup.json

# Import session
npx claude-flow hive-mind import backup.json

API リファレンス

HiveMindCore
const hiveMind = new HiveMindCore({
  objective: 'Build system',
  queenType: 'strategic',
  maxWorkers: 8,
  consensusAlgorithm: 'byzantine'
});

await hiveMind.initialize();
await hiveMind.spawnQueen(queenData);
await hiveMind.spawnWorkers(['coder', 'tester']);
await hiveMind.createTask('Implement feature', 7);
const decision = await hiveMind.buildConsensus('topic', options);
const status = hiveMind.getStatus();
await hiveMind.shutdown();
CollectiveMemory
const memory = new CollectiveMemory({
  swarmId: 'hive-123',
  maxSize: 100,
  cacheSize: 1000
});

await memory.store(key, value, type, metadata);
const data = await memory.retrieve(key);
const results = await memory.search(pattern, options);
const related = await memory.getRelated(key, limit);
await memory.associate(key1, key2, strength);
const stats = memory.getStatistics();
const analytics = memory.getAnalytics();
const health = await memory.healthCheck();
HiveMindSessionManager
const sessionManager = new HiveMindSessionManager();

const sessionId = await sessionManager.createSession(
  swarmId, swarmName, objective, metadata
);

await sessionManager.saveCheckpoint(sessionId, name, data);
const sessions = await sessionManager.getActiveSessions();
const session = await sessionManager.getSession(sessionId);
await sessionManager.pauseSession(sessionId);
await sessionManager.resumeSession(sessionId);
await sessionManager.stopSession(sessionId);
await sessionManager.completeSession(sessionId);

例

フルスタック開発
# Initialize hive mind
npx claude-flow hive-mind init

# Spawn full-stack hive
npx claude-flow hive-mind spawn "Build e-commerce platform" \
  --queen-type strategic \
  --max-workers 10 \
  --consensus weighted \
  --claude

# Output generates Claude Code commands:
# - Queen coordinator
# - Frontend developers (React)
# - Backend developers (Node.js)
# - Database architects
# - DevOps engineers
# - Security auditors
# - Test engineers
# - Documentation specialists
調査と分析
# Spawn research hive
npx claude-flow hive-mind spawn "Research GraphQL vs REST" \
  --queen-type adaptive \
  --consensus byzantine

# Researchers gather data
# Analysts process findings
# Queen builds consensus on recommendation
# Results stored in collective memory
コードレビュー
# Review coordination
npx claude-flow hive-mind spawn "Review PR #456" \
  --queen-type tactical \
  --max-workers 6

# Spawns:
# - Code analyzers
# - Security reviewers
# - Performance reviewers
# - Test coverage analyzers
# - Documentation reviewers
# - Consensus on approval$changes

スキルの習得段階

初級
  1. Hive Mind を初期化する
  2. 基本的なスウォームを起動する
  3. 状態を監視する
  4. 多数決による合意形成を利用する
中級
  1. Queen タイプを設定する
  2. セッション管理を実装する
  3. 重み付き合意形成を利用する
  4. 集合メモリにアクセスする
  5. 自動スケーリングを有効にする
上級
  1. ビザンチン障害耐性
  2. メモリ最適化
  3. カスタムワーカータイプ
  4. 複数 Hive の連携
  5. ニューラルパターンの学習
  6. セッションのエクスポート$インポート
  7. パフォーマンスの調整

関連スキル

  • swarm-orchestration:基本的なスウォームの連携
  • consensus-mechanisms:分散型の意思決定
  • memory-systems:高度なメモリ管理
  • sparc-methodology:構造化された開発ワークフロー
  • github-integration:リポジトリの連携

参考資料


スキルのバージョン:1.0.0 最終更新日:2025-10-19 メンテナンス担当:Claude Flow Team ライセンス:MIT

コメント