Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

merge

БесплатноЗапускает вложенные скриптыНе проверен

Merge current branch to the default branch via GitHub PR merge. Use when ready to merge a PR or land a branch.

drnот drn★ 23 звезды на GitHub

Об этом скилле

Context

  • Current branch: !git branch --show-current
  • Git status: !git status --short
  • Remotes: !git remote -v 2>/dev/null | head -10
  • Base ref: !git branch -r 2>/dev/null | grep -oE 'origin/(main|master)' | head -1
  • Commits vs main (upstream): !git log upstream/main..HEAD --oneline 2>/dev/null | head -50
  • Commits vs master (upstream): !git log upstream/master..HEAD --oneline 2>/dev/null | head -50
  • Commits vs main (origin): !git log origin/main..HEAD --oneline 2>/dev/null | head -50
  • Commits vs master (origin): !git log origin/master..HEAD --oneline 2>/dev/null | head -50
  • Diff stat vs main (upstream, branch-only): !git diff upstream/main...HEAD --stat 2>/dev/null | head -50
  • Diff stat vs master (upstream, branch-only): !git diff upstream/master...HEAD --stat 2>/dev/null | head -50
  • Diff stat vs main (origin, branch-only): !git diff origin/main...HEAD --stat 2>/dev/null | head -50
  • Diff stat vs master (origin, branch-only): !git diff origin/master...HEAD --stat 2>/dev/null | head -50

Phase Protocol

This skill participates in a phase chain. Read ~/.claude/skills/_shared/resources/phase-protocol.md for the full protocol.

Before merging: Read the latest .context/phases/ship-*.md for the PR number/URL if available.

After merge completes: Write a land-{ts}.md artifact to .context/phases/ (create with mkdir -p .context/phases). The Detail section should include the merge commit SHA and PR URL. Optionally archive all phase artifacts: mkdir -p .context/phases/archive && mv .context/phases/*.md .context/phases/archive/.

Your task

Merge the current branch into the default branch via GitHub PR merge. An existing PR is NOT required — one will be created if needed.

Step 0: Preflight — ahead/behind check

Before committing anything, verify the branch is in a mergeable state.

Run:

TARGET=$(git remote | grep -q '^upstream$' && echo upstream || echo origin)
git fetch "$TARGET" >/dev/null 2>&1 || true
DEFAULT_BRANCH=$(git branch -r 2>/dev/null | grep -oE "${TARGET}/(main|master)" | head -1 | sed "s|${TARGET}/||")
[ -z "$DEFAULT_BRANCH" ] && DEFAULT_BRANCH="master"
AHEAD=$(git log "$TARGET/$DEFAULT_BRANCH..HEAD" --oneline 2>/dev/null | wc -l | tr -d ' ')
BEHIND=$(git log "HEAD..$TARGET/$DEFAULT_BRANCH" --oneline 2>/dev/null | wc -l | tr -d ' ')
DIRTY=$(git status --short 2>/dev/null | wc -l | tr -d ' ')
echo "ahead=$AHEAD behind=$BEHIND dirty=$DIRTY default_branch=$DEFAULT_BRANCH"

Decide based on the output:

  • ahead=0 and dirty=0 — Stop. Reply: "Nothing to merge — branch has no commits ahead of $DEFAULT_BRANCH and working tree is clean."
  • Otherwise (ahead > 0, or dirty > 0) — Proceed to Step 1. The merge script handles fetch + rebase automatically, so being behind the default branch is fine.

These ahead/behind counts are the authoritative signal for what the branch will land. The injected context block reflects them: the "Commits vs <base>" lines use a two-dot range (<base>..HEAD), which lists exactly the commits this branch adds, and the "Diff stat vs <base> (branch-only)" lines use a three-dot diff (<base>...HEAD, from the merge-base), which shows only this branch's own file changes even when behind > 0. Both are already scoped to the branch — neither inflates when behind.

Caveat for manual checks: if you run a plain two-dot diff yourself (git diff <base>..HEAD --stat) while the branch is behind, it folds base-ahead history in as inverted changes and lists many files unrelated to this branch. That is expected, not a problem with the branch — Step 3 rebases the branch onto the current <base> tip, after which the two-dot and three-dot diffs converge. Trust the Step 0 counts and the three-dot diff stat above, not a raw two-dot diff.

Step 1: Commit uncommitted changes

If git status shows uncommitted changes, stage and commit them with an appropriate message. Skip if working tree is clean.

Step 2: Analyze commits and craft PR metadata

Review all commits and the full diff since the branch diverged from the default branch. Determine:

  • Title: Concise imperative summary of what the branch accomplishes (not individual commits). Under 72 characters.
  • Body: Short description of the changes. Do NOT include Co-Authored-By — the script adds it.

If there are no prior commits (only what was committed in step 1), base the summary on that commit.

Step 3: Run the merge script

Resolve the script path — use the first that exists:

  1. ~/.claude/skills/merge/scripts/merge.sh (deployed via symlink)
  2. agents/skills/merge/scripts/merge.sh (repo-relative, for development/workspaces)
bash <script-path> [--method <squash|merge|rebase>] [--keep-branch] [--no-wait-checks] "<title>" "<body>"

The script fails closed on CI. It waits for pending checks (default 1200s, override with the MERGE_CHECK_TIMEOUT env var in seconds) and refuses to merge when a check is failing. When the repo has GitH

Полный SKILL.md на GitHub

Установить merge в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash(git add:*)
Bash(git commit:*)
Bash(git log:*)
Bash(git diff:*)
Bash(git status:*)
Bash(git rebase:*)
Bash(git checkout:*)
Bash(git reset:*)
Bash(bash ~/.claude/skills/merge/scripts/merge.sh:*)
Bash(bash agents/skills/merge/scripts/merge.sh:*)

Вложенные файлы

scripts/merge.sh

FAQ

Что делает скилл merge?

Merge current branch to the default branch via GitHub PR merge. Use when ready to merge a PR or land a branch.

Как установить скилл merge?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл merge запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить merge с