AgentHub — Multi-Agent Collaboration

Multi-agent collaboration plugin that spawns N parallel subagents competing on the same task via git worktree isolation.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/agenthub, including the files SKILL.md points to.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit alirezarezvani/claude-skills/engineering/agenthub/skills/agenthub#main ~/.claude/skills/agenthub

For one project only, change the path to .claude/skills/agenthub. This skill also uses dag_analyzer.py, -result.md, bench.py, session_manager.py, hub_init.py, board_manager.py — copying SKILL.md alone won't be enough. See the folder on GitHub.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of AgentHub — Multi-Agent Collaboration

Show the full text258 lines
namedescriptionlicensemetadata
agenthubMulti-agent collaboration plugin that spawns N parallel subagents competing on the same task via git worktree isolation. Agents work independently, results are evaluated by metric or LLM judge, and the best branch is merged. Use when: user wants multiple approaches tried in parallel — code optimization, content variation, research exploration, or any task that benefits from parallel competition. Requires: a git repo.MIT version: 2.1.2 author: Alireza Rezvani category: engineering updated: 2026-03-17

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

Command Description
/hub:hub-init Create a new collaboration session — task, agent count, eval criteria
/hub:spawn Launch N parallel subagents in isolated worktrees
/hub:hub-status Show DAG state, agent progress, branch status
/hub:eval Rank agent results by metric or LLM judge
/hub:merge Merge winning branch, archive losers
/hub:board Read/write the agent message board
/hub:run One-shot lifecycle: init → baseline → spawn → eval → merge

Agent Templates

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

Template Pattern Use Case
optimizer Edit → eval → keep/discard → repeat x10 Performance, latency, size
refactorer Restructure → test → iterate until green Code quality, tech debt
test-writer Write tests → measure coverage → repeat Test coverage gaps
bug-fixer Reproduce → diagnose → fix → verify Bug 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: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 /hub: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:hub-status to check progress:

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

Run /hub: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 /hub: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
Channel Writer Reader Purpose
dispatch/ Coordinator Agents Task assignments
progress/ Agents Coordinator Status updates
results/ Agents + Coordinator All Final 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:

From To Trigger
init running /hub:spawn completes
running evaluating All agents return
evaluating merged /hub:merge completes
evaluating archived No winner / all failed

Proactive Triggers

The coordinator should act when:

Signal Action
All agents crashed Post failure summary, suggest retry with different constraints
No improvement over baseline Archive session, suggest different approaches
Orphan worktrees detected Run session_manager.py --cleanup {id}
Session stuck in running Check 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

Script Purpose
hub_init.py Initialize .agenthub/ structure and session
dag_analyzer.py Frontier detection, DAG graph, branch status
board_manager.py Message board CRUD (channels, posts, threads)
result_ranker.py Rank agents by metric or diff quality
session_manager.py Session state machine and cleanup
  • 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)
1---
2name: "agenthub"
3description: "Multi-agent collaboration plugin that spawns N parallel subagents competing on the same task via git worktree isolation. Agents work independently, results are evaluated by metric or LLM judge, and the best branch is merged. Use when: user wants multiple approaches tried in parallel — code optimization, content variation, research exploration, or any task that benefits from parallel competition. Requires: a git repo."
4license: MIT
5metadata:
6 version: 2.1.2
7 author: Alireza Rezvani
8 category: engineering
9 updated: 2026-03-17
10---
11 
12# AgentHub — Multi-Agent Collaboration
13 
14Spawn 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.
15 
16## Slash Commands
17 
18| Command | Description |
19|---------|-------------|
20| `/hub:hub-init` | Create a new collaboration session — task, agent count, eval criteria |
21| `/hub:spawn` | Launch N parallel subagents in isolated worktrees |
22| `/hub:hub-status` | Show DAG state, agent progress, branch status |
23| `/hub:eval` | Rank agent results by metric or LLM judge |
24| `/hub:merge` | Merge winning branch, archive losers |
25| `/hub:board` | Read/write the agent message board |
26| `/hub:run` | One-shot lifecycle: init → baseline → spawn → eval → merge |
27 
28## Agent Templates
29 
30When spawning with `--template`, agents follow a predefined iteration pattern:
31 
32| Template | Pattern | Use Case |
33|----------|---------|----------|
34| `optimizer` | Edit → eval → keep/discard → repeat x10 | Performance, latency, size |
35| `refactorer` | Restructure → test → iterate until green | Code quality, tech debt |
36| `test-writer` | Write tests → measure coverage → repeat | Test coverage gaps |
37| `bug-fixer` | Reproduce → diagnose → fix → verify | Bug fix approaches |
38 
39Templates are defined in `references/agent-templates.md`.
40 
41## When This Skill Activates
42 
43Trigger phrases:
44- "try multiple approaches"
45- "have agents compete"
46- "parallel optimization"
47- "spawn N agents"
48- "compare different solutions"
49- "fan-out" or "tournament"
50- "generate content variations"
51- "compare different drafts"
52- "A/B test copy"
53- "explore multiple strategies"
54 
55## Coordinator Protocol
56 
57The main Claude Code session is the coordinator. It follows this lifecycle:
58 
59```
60INIT → DISPATCH → MONITOR → EVALUATE → MERGE
61```
62 
63### 1. Init
64 
65Run `/hub:hub-init` to create a session. This generates:
66- `.agenthub/sessions/{session-id}/config.yaml` — task config
67- `.agenthub/sessions/{session-id}/state.json` — state machine
68- `.agenthub/board/` — message board channels
69 
70### 2. Dispatch
71 
72Run `/hub:spawn` to launch agents. For each agent 1..N:
73- Post task assignment to `.agenthub/board/dispatch/`
74- Spawn via Agent tool with `isolation: "worktree"`
75- All agents launched in a single message (parallel)
76 
77### 3. Monitor
78 
79Run `/hub:hub-status` to check progress:
80- `dag_analyzer.py --status --session {id}` shows branch state
81- Board `progress/` channel has agent updates
82 
83### 4. Evaluate
84 
85Run `/hub:eval` to rank results:
86- **Metric mode**: run eval command in each worktree, parse numeric result
87- **Judge mode**: read diffs, coordinator ranks by quality
88- **Hybrid**: metric first, LLM-judge for ties
89 
90### 5. Merge
91 
92Run `/hub:merge` to finalize:
93- `git merge --no-ff` winner into base branch
94- Tag losers: `git tag hub/archive/{session}/agent-{i}`
95- Clean up worktrees
96- Post merge summary to board
97 
98## Agent Protocol
99 
100Each subagent receives this prompt pattern:
101 
102```
103You are agent-{i} in hub session {session-id}.
104Your task: {task description}
105 
106Instructions:
1071. Read your assignment at .agenthub/board/dispatch/{seq}-agent-{i}.md
1082. Work in your worktree — make changes, run tests, iterate
1093. Commit all changes with descriptive messages
1104. Write your result summary to .agenthub/board/results/agent-{i}-result.md
1115. Exit when done
112```
113 
114Agents 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.
115 
116## DAG Model
117 
118### Branch Naming
119 
120```
121hub/{session-id}/agent-{N}/attempt-{M}
122```
123 
124- Session ID: timestamp-based (`YYYYMMDD-HHMMSS`)
125- Agent N: sequential (1 to agent-count)
126- Attempt M: increments on retry (usually 1)
127 
128### Frontier Detection
129 
130Frontier = branch tips with no child branches. Equivalent to AgentHub's "leaves" query.
131 
132```bash
133python scripts/dag_analyzer.py --frontier --session {id}
134```
135 
136### Immutability
137 
138The DAG is append-only:
139- Never rebase or force-push agent branches
140- Never delete commits (only branch refs after archival)
141- Every approach preserved via git tags
142 
143## Message Board
144 
145Location: `.agenthub/board/`
146 
147### Channels
148 
149| Channel | Writer | Reader | Purpose |
150|---------|--------|--------|---------|
151| `dispatch/` | Coordinator | Agents | Task assignments |
152| `progress/` | Agents | Coordinator | Status updates |
153| `results/` | Agents + Coordinator | All | Final results + merge summary |
154 
155### Post Format
156 
157```markdown
158---
159author: agent-1
160timestamp: 2026-03-17T14:30:22Z
161channel: results
162parent: null
163---
164 
165## Result Summary
166 
167- **Approach**: Replaced O(n²) sort with hash map
168- **Files changed**: 3
169- **Metric**: 142ms (baseline: 180ms, delta: -38ms)
170- **Confidence**: High — all tests pass
171```
172 
173### Board Rules
174 
175- Append-only: never edit or delete posts
176- Unique filenames: `{seq:03d}-{author}-{timestamp}.md`
177- YAML frontmatter required on all posts
178 
179## Evaluation Modes
180 
181### Metric-Based
182 
183Best for: benchmarks, test pass rates, file sizes, response times.
184 
185```bash
186python scripts/result_ranker.py --session {id} \
187 --eval-cmd "pytest bench.py --json" \
188 --metric p50_ms --direction lower
189```
190 
191The ranker runs the eval command in each agent's worktree directory and parses the metric from stdout.
192 
193### LLM Judge
194 
195Best for: code quality, readability, architecture decisions.
196 
197The coordinator reads each agent's diff (`git diff base...agent-branch`) and ranks by:
1981. Correctness (does it solve the task?)
1992. Simplicity (fewer lines changed preferred)
2003. Quality (clean execution, good structure)
201 
202### Hybrid
203 
204Run metric first. If top agents are within 10% of each other, use LLM judge to break ties.
205 
206## Session Lifecycle
207 
208```
209init → running → evaluating → merged
210 → archived (if no winner)
211```
212 
213State transitions managed by `session_manager.py`:
214 
215| From | To | Trigger |
216|------|----|---------|
217| `init` | `running` | `/hub:spawn` completes |
218| `running` | `evaluating` | All agents return |
219| `evaluating` | `merged` | `/hub:merge` completes |
220| `evaluating` | `archived` | No winner / all failed |
221 
222## Proactive Triggers
223 
224The coordinator should act when:
225 
226| Signal | Action |
227|--------|--------|
228| All agents crashed | Post failure summary, suggest retry with different constraints |
229| No improvement over baseline | Archive session, suggest different approaches |
230| Orphan worktrees detected | Run `session_manager.py --cleanup {id}` |
231| Session stuck in `running` | Check board for progress, consider timeout |
232 
233## Installation
234 
235```bash
236# Copy to your Claude Code skills directory
237cp -r engineering/agenthub ~/.claude/skills/agenthub
238 
239# Or install via ClawHub
240clawhub install agenthub
241```
242 
243## Scripts
244 
245| Script | Purpose |
246|--------|---------|
247| `hub_init.py` | Initialize `.agenthub/` structure and session |
248| `dag_analyzer.py` | Frontier detection, DAG graph, branch status |
249| `board_manager.py` | Message board CRUD (channels, posts, threads) |
250| `result_ranker.py` | Rank agents by metric or diff quality |
251| `session_manager.py` | Session state machine and cleanup |
252 
253## Related Skills
254 
255- **autoresearch-agent** — Single-agent optimization loop (use AgentHub when you want N agents competing)
256- **self-improving-agent** — Self-modifying agent (use AgentHub when you want external competition)
257- **git-worktree-manager** — Git worktree utilities (AgentHub uses worktrees internally)
258 

Discussion

Alternatives

Also in CI/CD & releasesSee all 533 in Development →