Merge Winner Agent Branch is a ai-agents claude skill built by Alireza Rezvani. Best for: AI agent coordinators use this to consolidate winning agent results into production, archive unsuccessful attempts, and maintain clean repository state..

What it does
Merge winning agent branch to base, archive losers, clean worktrees.
Category
ai-agents
Created by
Alireza Rezvani
Last updated
Claude Skillai-agents GitHub-backed CuratedadvancedClaude Code

Merge Winner Agent Branch

Merge winning agent branch to base, archive losers, clean worktrees.

Skill instructions


name: "merge" description: "Merge the winning agent's branch into base, archive losers, and clean up worktrees." 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

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:

# 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

python {skill_path}/scripts/session_manager.py --cleanup {session-id}

5. Post Merge Summary

Write .agenthub/board/results/merge-summary.md:

---
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

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

Use this skill

Most skills are portable instruction packages. Claude Code supports SKILL.md directly. Other agents can use adapted files like AGENTS.md, .cursorrules, and GEMINI.md.

Claude Code

Save SKILL.md into your Claude Skills folder, then restart Claude Code.

mkdir -p ~/.claude/skills/merge-winner-agent-branch && curl -L "https://raw.githubusercontent.com/alirezarezvani/claude-skills/HEAD/engineering/agenthub/skills/merge/SKILL.md" -o ~/.claude/skills/merge-winner-agent-branch/SKILL.md

Installs to ~/.claude/skills/merge-winner-agent-branch/SKILL.md.

Use cases

AI agent coordinators use this to consolidate winning agent results into production, archive unsuccessful attempts, and maintain clean repository state.

Reviews

No reviews yet. Be the first to review this skill.

No signup required

Stats

Installs0
GitHub Stars11.6k
Forks1507
LicenseMIT
UpdatedMar 27, 2026