merge — Claude skill: land the winning branch, tidy the session
A Claude skill that merges the top-ranked agent's branch into base, archives the rest as tags, and cleans up worktrees. Useful once an AgentHub session is done.
/plugin marketplace add alirezarezvani/claude-skills
/plugin install agenthub@claude-code-skillsWhat merge does
The skill runs on the /hub:merge slash command. With no arguments it takes the winner of the latest session; pass a session id to target a specific one, or --agent to pick the winner yourself. Otherwise the #1 ranked agent from the most recent /hub:eval wins.
From there it is plain git. It checks out the base branch and runs git merge --no-ff on the winner's branch with a message carrying the task, agent and session. Losers are not thrown away: each gets a tag hub/archive/{session-id}/{agent-id} before the branch ref is dropped with git branch -D. Worktrees are removed by scripts/session_manager.py --cleanup, which also flips the session state to merged.
You get a diff summary and a confirmation prompt before anything is merged. Force-push is never used. If you don't run competing agents in AgentHub, skip this one — it exists to wrap up that comparison.
What it helps with
- merge the winning agent's branch into base without hand-running git merge
- keep losing agents' commits alive as tags instead of deleting them
- remove leftover worktrees after a session
- write the merge summary to
.agenthub/board/results/merge-summary.md - set the session state to merged in one command
Example prompts for the agent
- /hub:merge
- /hub:merge 20260317-143022
- /hub:merge 20260317-143022 --agent agent-2
How to install merge
1Plugin marketplace
/plugin marketplace add alirezarezvani/claude-skills/plugin install agenthub@claude-code-skillsThis installs the whole agenthub plugin with all its skills
2Skills CLI (Vercel)
npx skills add alirezarezvani/claude-skills --skill merge -a claude-code3Manually: put the files in place
~/.claude/skills/merge/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/merge/
Manually: put the files in place
.agents/skills/merge/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/merge/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install alirezarezvani/claude-skills merge2Manually: put the files in place
.github/skills/merge/SKILL.mdPlatform CLI
gemini skills install https://github.com/alirezarezvani/claude-skills --path engineering/agenthub/skills/mergeManually: put the files in place
.devin/skills/merge/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set349
The whole set →Similar
Questions about merge
How do I install merge in Claude?
Add the plugin marketplace with /plugin marketplace add alirezarezvani/claude-skills, then run /plugin install agenthub@claude-code-skills. You can also use npx skills add alirezarezvani/claude-skills --skill merge -a claude-code.
What does merge do?
It merges the chosen agent's branch into base with git merge --no-ff, tags the losing branches for archival, cleans up worktrees, and writes a summary to .agenthub/board/results/merge-summary.md.
How do I pick the winner manually?
Pass the --agent flag, for example /hub:merge 20260317-143022 --agent agent-2. Without it, the skill uses the #1 ranked agent from the last /hub:eval.
Source text
SKILL.md · MIT
---
name: "merge"
description: "Merge the winning agent's branch into base, archive losers, and clean up worktrees. Use when the user runs /hub:merge or asks to land the winning AgentHub result and tidy the session."
metadata:
command: /hub:merge
---
# /hub:merge — Merge Winner
Merge the best agent's branch into the base branch, archive losing branches via git tags, and clean up worktrees.
## Usage
```
/hub:merge # Merge winner of latest session
/hub:merge 20260317-143022 # Merge winner of specific session
/hub:merge 20260317-143022 --agent agent-2 # Explicitly choose winner
```
## What It Does
### 1. Identify Winner
If `--agent` specified, use that. Otherwise, use the #1 ranked agent from the most recent `/hub:eval`.
### 2. Merge Winner
```bash
git checkout {base_branch}
git merge --no-ff hub/{session-id}/{winner}/attempt-1 \
-m "hub: merge {winner} from session {session-id}
Task: {task}
Winner: {winner}
Session: {session-id}"
```
### 3. Archive Losers
For each non-winning agent:
```bash
# Create archive tag (preserves commits forever)
git tag hub/archive/{session-id}/{agent-id} hub/{session-id}/{agent-id}/attempt-1
# Delete branch ref (commits preserved via tag)
git branch -D hub/{session-id}/{agent-id}/attempt-1
```
### 4. Clean Up Worktrees
```bash
python {skill_path}/scripts/session_manager.py --cleanup {session-id}
```
### 5. Post Merge Summary
Write `.agenthub/board/results/merge-summary.md`:
```markdown
---
author: coordinator
timestamp: {now}
channel: results
---
## Merge Summary
- **Session**: {session-id}
- **Winner**: {winner}
- **Merged into**: {base_branch}
- **Archived**: {loser-1}, {loser-2}, ...
- **Worktrees cleaned**: {count}
```
### 6. Update State
```bash
python {skill_path}/scripts/session_manager.py --update {session-id} --state merged
```
## Safety
- **Confirm with user** before merging — show the diff summary first
- **Never force-push** — merge is always `--no-ff` for clear history
- **Archive, don't delete** — losing agents' commits are preserved via tags
- **Clean worktrees** — don't leave orphan directories on disk
## After Merge
Tell the user:
- Winner merged into `{base_branch}`
- Losers archived with tags `hub/archive/{session-id}/agent-{N}`
- Worktrees cleaned up
- Session state: `merged`
© Alireza Rezvani · MIT · alirezarezvani/claude-skills