Skip to main content
skill Claude Code

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.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add alirezarezvani/claude-skills
/plugin install agenthub@claude-code-skills
Open on GitHub

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

This installs the whole agenthub plugin with all its skills

2Skills CLI (Vercel)

npx skills add alirezarezvani/claude-skills --skill merge -a claude-code

3Manually: put the files in place

~/.claude/skills/merge/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/merge/

From the same set349

The whole set →
engineering-skills Alireza Rezvani An engineering skill index for Claude Code that helps you select one specialist SKILL.md for the task at hand. It covers architecture, testing, DevOps, and data work. Claude Code 2,387installs finance-skills Alireza Rezvani Routes ambiguous finance prompts to the right bundled skill: financial-analyst, saas-metrics-coach, or month-end-close. Claude Code 2,312installs marketing-skills Alireza Rezvani A directory and router for marketing skills in Claude Code. It picks the right specialist skill for SEO, content, CRO, channels, and related tasks. Claude Code 2,264installs business-growth-skills Alireza Rezvani Routes growth and revenue prompts to the right specialized skill across customer success, sales engineering, RevOps, and proposals in Claude Code. Claude Code 2,189installs engineering-advanced-skills Alireza Rezvani An index of 37 engineering skills for architecture, automation, reliability, and platform work. Use it when a project needs task-specific engineering workflows. Claude Code 2,019installs product-skills Alireza Rezvani Product work orchestrator for Claude Code. Routes queries across 16 domain lanes and validates discovery trees with deterministic scripts. Claude Code 1,994installs pm-skills Alireza Rezvani Routes project-delivery requests across 8 PM sub-skills for Jira, Confluence, sprints, reporting, and team communication. Useful for controlled delivery work. Claude Code 1,975installs senior-backend Alireza Rezvani Scaffolds backend APIs, detects database bottlenecks, and runs load tests. Useful when designing Express routes, optimizing PostgreSQL, or preparing for production. Claude Code 1,674installs

Similar

grounded-vault Niksa Barlovic Maintains a durable Markdown knowledge store with per-claim source provenance and zero-token drift detection against code using git diff. Claude Code CX Codex Cursor 1,400installs commit-message-storyteller official github Parses git diffs or change descriptions to generate Conventional Commits messages that explain the intent behind code changes. GitHub Copilot 392installs ai-team-orchestration official github Bootstraps a lightweight multi-agent team inside your editor. It helps plan features, coordinate code changes, and preserve context across chat sessions. GitHub Copilot 381installs triage Matt Pocock This skill moves issues and external PRs through triage states, verification, and agent briefs. It fits maintainers managing an issue queue. Claude Code 990,453installs code-review Matt Pocock Reviews changes from a chosen reference point against repository standards and the originating spec. Use it for a branch, PR, or work in progress. Claude Code 789,521installs implement Matt Pocock Implements work from a specification or tickets, following a test-driven flow and ending with review and a commit. Use it when a coding task needs a defined delivery routine. Claude Code 774,700installs git-guardrails-claude-code Matt Pocock This skill adds a Claude Code hook that stops risky Git commands before they run. Use it when an agent must not push or discard working-tree changes. Claude Code 499,069installs setup-pre-commit Matt Pocock This skill configures pre-commit checks for a JavaScript repository, running Prettier, type checking, and tests before each commit. Claude Code 489,289installs

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

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor