Skip to content

Multi-agent tournament plugin that runs parallel agents on one task and merges the best result.

CCM score
62 of 100
version
2.14.11
GitHub stars
30.6K
View on GitHub

Own this plugin? Claim it

What it does

  • Adds the /hub-init, /hub-status, /hub-run, /agenthub:spawn, /agenthub:eval, /agenthub:merge, and /agenthub:board commands, plus the hub-coordinator agent
  • Covers the full lifecycle: baseline capture, spawn in git worktrees, metric or LLM judge ranking, and merge of the winning branch
  • Archives losing branches as tags and cleans up worktrees, so only the chosen result lands in your branch
  • Designed for optimization, refactoring, and content tasks where several competing approaches are worth comparing

Multi-agent collaboration — spawn N parallel subagents that compete on code optimization, content drafts, research approaches, or any task that benefits from diverse solutions. 7 slash commands (/hub-init, /agenthub:spawn, /hub-status, /agenthub:eval, /agenthub:merge, /agenthub:board, /hub-run), agent templates, DAG-based orchestration, LLM judge mode, message board coordination.

Add marketplace

/plugin marketplace add alirezarezvani/claude-skills

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install agenthub@claude-code-skills

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

AgentHub — Multi-Agent Collaboration

Spawn N parallel AI agents that compete on the same task. Each agent works in an isolated git worktree. The coordinator evaluates results and merges the winner.

Slash Commands

CommandDescription
/hub-initCreate a new collaboration session — task, agent count, eval criteria
/agenthub:spawnLaunch N parallel subagents in isolated worktrees
/hub-statusShow DAG state, agent progress, branch status
/agenthub:evalRank agent results by metric or LLM judge
/agenthub:mergeMerge winning branch, archive losers
/agenthub:boardRead/write the agent message board
/hub-runOne-shot lifecycle: init → baseline → spawn → eval → merge

Agent Templates

When spawning with --template, agents follow a predefined iteration pattern:

TemplatePatternUse Case
optimizerEdit → eval → keep/discard → repeat x10Performance, latency, size
refactorerRestructure → test → iterate until greenCode quality, tech debt
test-writerWrite tests → measure coverage → repeatTest coverage gaps
bug-fixerReproduce → diagnose → fix → verifyBug fix approaches

Templates are defined in references/agent-templates.md.

When This Skill Activates

Trigger phrases:

  • "try multiple approaches"
  • "have agents compete"
  • "parallel optimization"
  • "spawn N agents"
  • "compare different solutions"
  • "fan-out" or "tournament"
  • "generate content variations"
  • "compare different drafts"
  • "A/B test copy"
  • "explore multiple strategies"

Coordinator Protocol

The main Claude Code session is the coordinator. It follows this lifecycle:

INIT → DISPATCH → MONITOR → EVALUATE → MERGE

1. Init

Run /hub-init to create a session. This generates:

  • .agenthub/sessions/{session-id}/config.yaml — task config
  • .agenthub/sessions/{session-id}/state.json — state machine
  • .agenthub/board/ — message board channels

2. Dispatch

Run /agenthub:spawn to launch agents. For each agent 1..N:

  • Post task assignment to .agenthub/board/dispatch/
  • Spawn via Agent tool with isolation: "worktree"
  • All agents launched in a single message (parallel)

3. Monitor

Run /hub-status to check progress:

  • dag_analyzer.py --status --session {id} shows branch state
  • Board progress/ channel has agent updates

4. Evaluate

Run /agenthub:eval to rank results:

  • Metric mode: run eval command in each worktree, parse numeric result
  • Judge mode: read diffs, coordinator ranks by quality
  • Hybrid: metric first, LLM-judge for ties

5. Merge

Run /agenthub:merge to finalize:

  • git merge --no-ff winner into base branch
  • Tag losers: git tag hub/archive/{session}/agent-{i}
  • Clean up worktrees
  • Post merge summary to board

Agent Protocol

Each subagent receives this prompt pattern:

You are agent-{i} in hub session {session-id}.
Your task: {task description}

Instructions:
1. Read your assignment at .agenthub/board/dispatch/{seq}-agent-{i}.md
2. Work in your worktree — make changes, run tests, iterate
3. Commit all changes with descriptive messages
4. Write your result summary to .agenthub/board/results/agent-{i}-result.md
5. Exit when done

Agents do NOT see each other's work. They do NOT communicate with each other. They only write to the board for the coordinator to read.

DAG Model

Branch Naming

hub/{session-id}/agent-{N}/attempt-{M}
  • Session ID: timestamp-based (YYYYMMDD-HHMMSS)
  • Agent N: sequential (1 to agent-count)
  • Attempt M: increments on retry (usually 1)

Frontier Detection

Frontier = branch tips with no child branches. Equivalent to AgentHub's "leaves" query.

python scripts/dag_analyzer.py --frontier --session {id}

Immutability

The DAG is append-only:

  • Never rebase or force-push agent branches
  • Never delete commits (only branch refs after archival)
  • Every approach preserved via git tags

Message Board

Location: .agenthub/board/

Channels

ChannelWriterReaderPurpose
dispatch/CoordinatorAgentsTask assignments
progress/AgentsCoordinatorStatus updates
results/Agents + CoordinatorAllFinal results + merge summary

Post Format

---
author: agent-1
timestamp: 2026-03-17T14:30:22Z
channel: results
parent: null
---

## Result Summary

- **Approach**: Replaced O(n²) sort with hash map
- **Files changed**: 3
- **Metric**: 142ms (baseline: 180ms, delta: -38ms)
- **Confidence**: High — all tests pass

Board Rules

  • Append-only: never edit or delete posts
  • Unique filenames: {seq:03d}-{author}-{timestamp}.md
  • YAML frontmatter required on all posts

Evaluation Modes

Metric-Based

Best for: benchmarks, test pass rates, file sizes, response times.

python scripts/result_ranker.py --session {id} \
  --eval-cmd "pytest bench.py --json" \
  --metric p50_ms --direction lower

The ranker runs the eval command in each agent's worktree directory and parses the metric from stdout.

LLM Judge

Best for: code quality, readability, architecture decisions.

The coordinator reads each agent's diff (git diff base...agent-branch) and ranks by:

  1. Correctness (does it solve the task?)
  2. Simplicity (fewer lines changed preferred)
  3. Quality (clean execution, good structure)

Hybrid

Run metric first. If top agents are within 10% of each other, use LLM judge to break ties.

Session Lifecycle

init → running → evaluating → merged
                            → archived (if no winner)

State transitions managed by session_manager.py:

FromToTrigger
initrunning/agenthub:spawn completes
runningevaluatingAll agents return
evaluatingmerged/agenthub:merge completes
evaluatingarchivedNo winner / all failed

Proactive Triggers

The coordinator should act when:

SignalAction
All agents crashedPost failure summary, suggest retry with different constraints
No improvement over baselineArchive session, suggest different approaches
Orphan worktrees detectedRun session_manager.py --cleanup {id}
Session stuck in runningCheck board for progress, consider timeout

Installation

# Copy to your Claude Code skills directory
cp -r engineering/agenthub ~/.claude/skills/agenthub

# Or install via ClawHub
clawhub install agenthub

Scripts

ScriptPurpose
hub_init.pyInitialize .agenthub/ structure and session
dag_analyzer.pyFrontier detection, DAG graph, branch status
board_manager.pyMessage board CRUD (channels, posts, threads)
result_ranker.pyRank agents by metric or diff quality
session_manager.pySession state machine and cleanup

Related Skills

  • autoresearch-agent — Single-agent optimization loop (use AgentHub when you want N agents competing)
  • self-improving-agent — Self-modifying agent (use AgentHub when you want external competition)
  • git-worktree-manager — Git worktree utilities (AgentHub uses worktrees internally)

More in this skill

Load these only when the task needs them.

Readme

AgentHub — Multi-Agent Collaboration for Claude Code

AgentHub spawns N parallel agents in isolated git worktrees to compete on the same task, then evaluates results by metric or LLM judge and merges the winner. It turns any optimization, refactoring, content generation, or design problem into a tournament where the best solution wins.

Quick Start

/plugin marketplace add alirezarezvani/claude-skills
/plugin install agenthub@claude-code-skills
# One command — full lifecycle
/hub-run --task "Reduce p50 latency" --agents 3 \
  --eval "pytest bench.py --json" --metric p50_ms --direction lower \
  --template optimizer

Or step by step:

# 1. Initialize a session — define the task, agent count, and evaluation criteria
/hub-init --task "Reduce API p50 latency" --agents 3 \
  --eval "pytest bench.py --json" --metric p50_ms --direction lower

# 2. Spawn agents — launches 3 parallel agents in isolated worktrees
/agenthub:spawn --template optimizer

# 3. Check progress
/hub-status

# 4. Evaluate — rank agents by metric
/agenthub:eval

# 5. Merge the winner into your branch
/agenthub:merge

Skill hints (UserPromptSubmit hook)

Some skills in this plugin rarely load on their own: in our trigger evals the model answered prompts squarely in their scope without opening them. The plugin ships a small hook, hooks/skill_router.py, that reads each prompt and, when it clearly matches one of these skills, adds one line telling Claude which skill fits: agenthub:agenthub.

It is quiet by design. It prints nothing on prompts that don't match, suggests at most one skill per prompt and each skill at most once per session, skips prompts that start with /, never blocks a prompt and makes no network or model calls. The patterns live in hooks/skill_routes.json. Turn it off with SKILL_ROUTER=0 (all plugins) or SKILL_ROUTER_AGENTHUB=0 (this plugin only).

Commands Reference

CommandPurposeExample
/hub-initCreate session with task, agents, eval criteria/hub-init --task "Optimize DB queries" --agents 4 --eval "python bench.py" --metric query_ms --direction lower
/agenthub:spawnLaunch all agents in parallel worktrees/agenthub:spawn (uses latest session)
/hub-statusShow DAG state, branches, progress posts/hub-status
/agenthub:evalRank results by metric or LLM judge/agenthub:eval --judge (LLM judge mode)
/agenthub:mergeMerge winner, archive losers, cleanup/agenthub:merge --agent agent-2 (force pick)
/agenthub:boardRead/write the message board/agenthub:board --read progress
/hub-runOne-shot full lifecycle/hub-run --task "Reduce latency" --agents 3 --eval "pytest bench.py" --metric p50_ms --direction lower --template optimizer

The Optimizer Pattern

AgentHub's most powerful pattern: N agents compete using different strategies, each running an iterative improvement loop in its own worktree.

How It Works

/hub-run --task "Reduce p50 latency" --agents 3 \
  --eval "pytest bench.py --json" --metric p50_ms --direction lower \
  --template optimizer

Each agent follows the same loop independently:

┌─── Agent 1 (worktree) ──────────────────────────┐
│  Strategy: Caching                              │
│  Loop: edit → eval → keep/discard → repeat ×10  │
└─────────────────────────────────────────────────┘
┌─── Agent 2 (worktree) ──────────────────────────┐
│  Strategy: Algorithm optimization               │
│  Loop: edit → eval → keep/discard → repeat ×10  │
└─────────────────────────────────────────────────┘
┌─── Agent 3 (worktree) ──────────────────────────┐
│  Strategy: I/O batching                         │
│  Loop: edit → eval → keep/discard → repeat ×10  │
└─────────────────────────────────────────────────┘

The optimizer template embeds the iteration loop directly in each agent's dispatch prompt — no external dependencies required.

Agent Templates

Templates define the dispatch prompt pattern. Use --template with /agenthub:spawn or /hub-run:

TemplatePatternUse Case
optimizerEdit → eval → keep/discard → repeat x10Performance, latency, size reduction, content quality, research depth
refactorerRestructure → test → iterate until greenCode quality, tech debt, document restructuring
test-writerWrite tests → measure coverage → repeatTest coverage gaps
bug-fixerReproduce → diagnose → fix → verifyBug fix with competing approaches

Templates live in references/agent-templates.md.

Example: 3 Strategies Competing on API Latency

/hub-run --task "Reduce API p50 latency below 150ms" --agents 3 \
  --eval "pytest bench.py --json" --metric p50_ms --direction lower \
  --template optimizer

AgentHub automatically:

  1. Captures baseline (e.g., p50_ms = 180ms)
  2. Assigns diverse strategies (caching, algorithm, I/O batching)
  3. Spawns 3 agents — each iterates up to 10 times in its worktree
  4. Agents commit improvements, revert failures, post progress to the board
  5. Evaluates final metrics across all agents
  6. Presents ranked results for merge confirmation
# Example output:
# RANK  AGENT    METRIC   DELTA    FILES
# 1     agent-2  128ms    -52ms    4
# 2     agent-1  145ms    -35ms    2
# 3     agent-3  171ms    -9ms     1

Example: 3 Agents Drafting Competing Blog Posts

/hub-run --task "Write a 1500-word blog post on zero-downtime deployments" \
  --agents 3 --judge

No eval command needed — --judge activates LLM judge mode. Each agent takes a different angle (tutorial, case study, opinion piece). The coordinator reads all three drafts and picks the winner by clarity, depth, and engagement.

Power-Up: Autoresearch for Richer Tracking

If you also have the autoresearch-agent skill installed, agents can optionally use its tracking tools for:

  • results.tsv — structured iteration history with timestamps and metrics
  • Strategy escalation — start with low-hanging fruit, escalate to radical changes
  • program.md — self-improving agent instructions that refine across iterations

This is entirely optional. The optimizer template works standalone — autoresearch just adds richer per-agent tracking if available. Both plugins remain independent; install either or both.

Step-by-Step Walkthrough

  1. Init + Baseline — Sets up session config with task description, agent count, eval command, and target metric. Captures baseline metric value. Creates .agenthub/sessions/{id}/config.yaml.

  2. Spawn — The coordinator writes dispatch posts to .agenthub/board/dispatch/ with strategy-specific instructions for each agent. Each agent is launched with isolation: "worktree" so it works on an isolated copy of the repo. When a template is used, the dispatch prompt contains the full iteration loop.

  3. Agents iterate — Each agent independently: reads its dispatch instructions, makes changes to the target files, runs the eval command, commits improvements, reverts failures, and posts progress updates.

  4. Evaluate — Runs result_ranker.py which checks out each agent's final branch, runs the eval command, extracts the metric, and produces a ranked table with deltas from baseline.

  5. Merge — Merges the winning branch with --no-ff, archives loser branches as tags (hub/archive/{session}/{agent}), cleans up worktrees, and posts a merge summary to the board.

Coordination Patterns

Fan-Out / Fan-In (Default)

One coordinator spawns N agents with the same task but different strategies or constraints. All run in parallel. Results are evaluated and one winner is merged.

Best for: Performance optimization, competing implementations, A/B testing approaches, competing marketing copy variations.

Tournament (Multi-Round Elimination)

Multiple rounds of fan-out/fan-in. Winners advance, losers are eliminated. Each round can narrow the strategy space.

Best for: Large solution spaces where you want to prune early, iterative refinement of the best approaches, multi-round content refinement.

Ensemble (Combine All Agents' Work)

Each agent works on a different subtask rather than competing on the same one. Results are combined rather than compared.

Best for: Large refactoring tasks, multi-file changes where work can be parallelized by module, multi-section reports or whitepapers.

Pipeline (Sequential Phases)

Agent 1's output becomes Agent 2's input. Each phase builds on the previous result.

Best for: Multi-stage workflows (e.g., Agent 1 writes tests, Agent 2 writes implementation, Agent 3 optimizes) or research → draft → edit pipelines.

Scripts

ScriptPurposeExample
hub_init.pyCreate session directory and configpython scripts/hub_init.py --task "Optimize queries" --agents 3 --eval "python bench.py" --metric query_ms --direction lower
board_manager.pyMessage board CRUD (dispatch, progress, results)python scripts/board_manager.py --post --channel progress --author agent-1 --message "Iteration 3: p50=145ms"
session_manager.pySession state machine (init→running→evaluating→merged)python scripts/session_manager.py --list
dag_analyzer.pyGit DAG analysis — frontier detection, branch statuspython scripts/dag_analyzer.py --status --session 20260317-143022
result_ranker.pyEvaluate and rank agent results by metric or diffpython scripts/result_ranker.py --session 20260317-143022 --eval-cmd "pytest bench.py --json" --metric p50_ms --direction lower

All scripts support --help for full usage and --demo for example output.

Installation

Claude Code

# Install from ClawHub
claude install agenthub

# Or add manually — copy the engineering/agenthub/ folder to your project,
# then add to your .claude/settings.json:
{
  "skills": ["./engineering/agenthub"]
}

OpenAI Codex

# Copy to your agents directory
cp -r engineering/agenthub/ .codex/agents/agenthub/

OpenClaw

openclaw install agenthub

Architecture

Session Model

Each /hub-init creates a session with a timestamp-based ID (YYYYMMDD-HHMMSS). Sessions progress through states:

init → running → evaluating → merged
                            → archived

State is tracked in .agenthub/sessions/{session-id}/state.json.

Branch Naming

hub/{session-id}/agent-{N}/attempt-{M}

# Example:
hub/20260317-143022/agent-1/attempt-1
hub/20260317-143022/agent-2/attempt-1
hub/20260317-143022/agent-3/attempt-1

Board Channels

The message board uses three channels stored as YAML-frontmatter markdown files:

ChannelDirectionPurpose
dispatchcoordinator → agentsTask assignments and strategy prompts
progressagents → coordinatorStatus updates, iteration results
resultsbidirectionalFinal metrics, merge summaries

Immutability Rules

  • Append-only board — posts are never edited or deleted
  • Append-only DAG — no rebase, no force-push
  • Archive losers — loser branches become tags, not deleted
  • Worktree cleanup — removed only after merge is complete

Directory Structure

.agenthub/
├── sessions/{session-id}/
│   ├── config.yaml          # Task, agents, eval criteria
│   └── state.json           # State machine, agent status
└── board/
    ├── _index.json          # Channel metadata
    ├── dispatch/            # Coordinator → agents
    ├── progress/            # Agents → coordinator
    └── results/             # Final results + merge summary

License

MIT

Details

Marketplace
alirezarezvani/claude-skills
Source
engineering/agenthub
Author
Alireza Rezvani
Category
Development
Keywords
multi-agent, collaboration, parallel, git-dag, orchestration, competition, worktree, content-generation, research, optimization
Listed since
Apr 7, 2026

More from alirezarezvani/claude-skills

All 121