mcpField
H
hive-mind-advanced

hive-mind-advanced

github.com/proffesor-for-testingエージェントワークフロー51937 回インストール1 日前に更新
リポジトリ

hive-mind-advanced について

hive-mind-advanced は、Claude Flow で複数のエージェントを調整するスキルです。クイーン主導のチームに合意形成と共有メモリを組み合わせ、タスク割り当て、セッション管理、実績の監視を扱います。

主な機能

  1. 01クイーン主導のエージェント調整
  2. 02多数決・加重・ビザンチン合意
  3. 03永続的な集合メモリ
  4. 04タスクの自動割り当てとワーカー拡縮
  5. 05チェックポイントとセッション監視

活用シーン

  1. 01ソフトウェア開発でのエージェント調整
  2. 02アーキテクチャ案の合意形成
  3. 03タスク間での知見共有
  4. 04協調セッションの一時停止と再開

インストール

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

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --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%

設定

ハイブマインドの設定
{
  "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. 適切なクイーンタイプを選択する

戦略型クイーン - 調査、計画、分析向け

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

戦術型クイーン - 実装と実行向け

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

適応型クイーン - 最適化と動的なタスク向け

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
複数のハイブの連携

複数のハイブマインドを同時に実行します。

# 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. ハイブマインドを初期化する
  2. 基本的なスウォームを起動する
  3. ステータスを監視する
  4. 多数決によるコンセンサスを使用する
中級
  1. クイーンタイプを設定する
  2. セッション管理を実装する
  3. 重み付きコンセンサスを使用する
  4. 集合メモリにアクセスする
  5. 自動スケーリングを有効にする
上級
  1. ビザンチン障害耐性
  2. メモリの最適化
  3. カスタムワーカータイプ
  4. 複数のハイブの連携
  5. ニューラルパターンの学習
  6. セッションのエクスポート/インポート
  7. パフォーマンスのチューニング

関連スキル

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

参考資料


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

コメント