agenthub — Claude Code plugin: what it does, how to install
Spawns parallel subagents in isolated git worktrees to compete on tasks, compares outcomes with metric checks or an LLM judge, and merges the winner.
/plugin marketplace add alirezarezvani/claude-skills
/plugin install agenthub@claude-code-skillsWhat agenthub does
AgentHub runs a tournament of parallel subagents inside Claude Code. When executing /hub:hub-run or using /hub:hub-init with /hub:spawn, the coordinator sets up an isolated git worktree for each agent. Every worker explores an assigned strategy independently. Subagents iteratively test adjustments, keep improvements, and post progress updates to a shared board.
Once iterations finish, result_ranker.py ranks candidates against target metrics, or an LLM judge evaluates drafts via --judge. The coordinator performs a --no-ff merge on the winning branch, tags losing branches for archival, and cleans up worktree folders. Built-in templates include optimizer, refactorer, test-writer, and bug-fixer.
Because agent isolation relies directly on git worktrees, your project must reside in an active git repository.
What it helps with
- Benchmark competing performance optimizations against baseline latency
- Draft competing blog posts evaluated by an LLM coordinator
- Generate regression tests aiming for maximum test coverage
- Test multiple bug-fixing strategies across isolated worktrees
Example prompts for the agent
- /hub:hub-run --task "Reduce p50 latency" --agents 3 --eval "pytest bench.py --json" --metric p50_ms --direction lower --template optimizer
- /hub:hub-run --task "Write a blog post on zero-downtime deployments" --agents 3 --judge
- /hub:merge --agent agent-2
How to install agenthub
Plugin marketplace
/plugin marketplace add alirezarezvani/claude-skills/plugin install agenthub@claude-code-skillsStep by step, with commands for each platform: Claude Code plugins: marketplaces, installing, and building your own
Questions about agenthub
How to install agenthub in Claude Code?
Run these two marketplace commands in Claude Code: /plugin marketplace add alirezarezvani/claude-skills, followed by /plugin install agenthub@claude-code-skills.
What does agenthub do?
It launches parallel subagents in separate git worktrees to tackle the same problem with different approaches. After testing, it ranks solutions using an automated metric or an LLM judge and merges the winning branch.
What agent templates are included?
The plugin supplies optimizer for iterative metric gains, refactorer for restructuring code, test-writer for coverage expansion, and bug-fixer for competing diagnostic fixes.
Source text
agenthub · MIT
# 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
```bash
# One command — full lifecycle
/hub:hub-run --task "Reduce p50 latency" --agents 3 \
--eval "pytest bench.py --json" --metric p50_ms --direction lower \
--template optimizer
```
Or step by step:
```bash
# 1. Initialize a session — define the task, agent count, and evaluation criteria
/hub: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
/hub:spawn --template optimizer
# 3. Check progress
/hub:hub-status
# 4. Evaluate — rank agents by metric
/hub:eval
# 5. Merge the winner into your branch
/hub:merge
```
## Commands Reference
| Command | Purpose | Example |
|---------|---------|---------|
| `/hub:hub-init` | Create session with task, agents, eval criteria | `/hub:hub-init --task "Optimize DB queries" --agents 4 --eval "python bench.py" --metric query_ms --direction lower` |
| `/hub:spawn` | Launch all agents in parallel worktrees | `/hub:spawn` (uses latest session) |
| `/hub:hub-status` | Show DAG state, branches, progress posts | `/hub:hub-status` |
| `/hub:eval` | Rank results by metric or LLM judge | `/hub:eval --judge` (LLM judge mode) |
| `/hub:merge` | Merge winner, archive losers, cleanup | `/hub:merge --agent agent-2` (force pick) |
| `/hub:board` | Read/write the message board | `/hub:board --read progress` |
| `/hub:hub-run` | One-shot full lifecycle | `/hub: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: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 `/hub:spawn` or `/hub:hub-run`:
| Template | Pattern | Use Case |
|----------|---------|----------|
| `optimizer` | Edit → eval → keep/discard → repeat x10 | Performance, latency, size reduction, content quality, research depth |
| `refactorer` | Restructure → test → iterate until green | Code quality, tech debt, document restructuring |
| `test-writer` | Write tests → measure coverage → repeat | Test coverage gaps |
| `bug-fixer` | Reproduce → diagnose → fix → verify | Bug fix with competing approaches |
Templates live in `references/agent-templates.md`.
### Example: 3 Strategies Competing on API Latency
```bash
/hub: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
```bash
/hub: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
| Script | Purpose | Example |
|--------|---------|---------|
| `hub_init.py` | Create session directory and config | `python scripts/hub_init.py --task "Optimize queries" --agents 3 --eval "python bench.py" --metric query_ms --direction lower` |
| `board_manager.py` | Message board CRUD (dispatch, progress, results) | `python scripts/board_manager.py --post --channel progress --author agent-1 --message "Iteration 3: p50=145ms"` |
| `session_manager.py` | Session state machine (init→running→evaluating→merged) | `python scripts/session_manager.py --list` |
| `dag_analyzer.py` | Git DAG analysis — frontier detection, branch status | `python scripts/dag_analyzer.py --status --session 20260317-143022` |
| `result_ranker.py` | Evaluate and rank agent results by metric or diff | `python 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
```bash
# 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
```bash
# Copy to your agents directory
cp -r engineering/agenthub/ .codex/agents/agenthub/
```
### OpenClaw
```bash
openclaw install agenthub
```
## Architecture
### Session Model
Each `/hub: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:
| Channel | Direction | Purpose |
|---------|-----------|---------|
| `dispatch` | coordinator → agents | Task assignments and strategy prompts |
| `progress` | agents → coordinator | Status updates, iteration results |
| `results` | bidirectional | Final 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
© Alireza Rezvani · MIT · alirezarezvani/claude-skills