원클릭으로
merge
Merge current branch to the default branch via GitHub PR merge. Use when ready to merge a PR or land a branch.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Merge current branch to the default branch via GitHub PR merge. Use when ready to merge a PR or land a branch.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Safely add a directory to Claude Code's Bash tool PATH. Use when a binary runs in your terminal but is "command not found" inside Claude Code's Bash tool, when adding a directory to PATH for Claude Code, when configuring CLAUDE_ENV_FILE, or when settings.json env.PATH did not work. Explains why env.PATH replaces rather than appends PATH and is not variable-expanded, why ~/.zshrc PATH exports are dropped, and the supported SessionStart hook fix.
Create or improve a Claude Code skill/slash command with best practices for structure, dynamic context, and safety. Use for creating new skills, improving existing ones, or learning skill authoring.
Launch a dynamic Workflow where the top-tier session model (Fable, or Opus when Fable is unavailable) handles planning and orchestration while implementation subagents run on Sonnet for routine tasks and Opus for complex ones. Use when the user wants to orchestrate a build, a dynamic workflow, a model-tiered build, fable or opus planning with sonnet and opus implementation, or tiered agents.
Open a PR, wait for CI to pass, fix failures, address review comments, and loop until fully green. Use when opening a PR, fixing CI, or addressing review feedback.
Manage recurring tasks in the local Argus daemon via its HTTP API. Use when the user wants to schedule a task locally in argus, create a cron-driven task, fire X every weekday/hour/morning, set up a recurring agent that needs local filesystem access (logs in ~/.argus, local databases, dotfiles), list or update existing argus schedules, or run an argus schedule now. Distinct from /schedule, which creates remote cloud routines without local access.
Generate a handoff prompt to pass context to another agent thread. Use when switching repos, handing off work, or sharing context between agents.
| name | merge |
| allowed-tools | 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:*) |
| description | Merge current branch to the default branch via GitHub PR merge. Use when ready to merge a PR or land a branch. |
git branch --show-currentgit status --shortgit remote -v 2>/dev/null | head -10git branch -r 2>/dev/null | grep -oE 'origin/(main|master)' | head -1git log upstream/main..HEAD --oneline 2>/dev/null | head -50git log upstream/master..HEAD --oneline 2>/dev/null | head -50git log origin/main..HEAD --oneline 2>/dev/null | head -50git log origin/master..HEAD --oneline 2>/dev/null | head -50git diff upstream/main...HEAD --stat 2>/dev/null | head -50git diff upstream/master...HEAD --stat 2>/dev/null | head -50git diff origin/main...HEAD --stat 2>/dev/null | head -50git diff origin/master...HEAD --stat 2>/dev/null | head -50This 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/.
Merge the current branch into the default branch via GitHub PR merge. An existing PR is NOT required — one will be created if needed.
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:
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.
If git status shows uncommitted changes, stage and commit them with an appropriate message. Skip if working tree is clean.
Review all commits and the full diff since the branch diverged from the default branch. Determine:
If there are no prior commits (only what was committed in step 1), base the summary on that commit.
Resolve the script path — use the first that exists:
~/.claude/skills/merge/scripts/merge.sh (deployed via symlink)agents/skills/merge/scripts/merge.sh (repo-relative, for development/workspaces)bash <script-path> [--method <squash|merge|rebase>] [--keep-branch] "<title>" "<body>"
The script defaults to squash (collapses all commits into one). Pick a different method when squash would lose intentional structure:
--method squash (default) — single commit, ideal for a stream of WIP commits.--method merge (alias --merge) — preserves all commits via a merge commit. Use when each commit is independently meaningful and you want to keep the merge boundary visible on master.--method rebase (alias --rebase) — preserves all commits linearly via fast-forward / rebase. Use this when the user has deliberately split work into multiple commits (e.g., the user ran /squash to condense 7 commits into 2 separate logical commits, and wants both on master). A naive squash merge here would silently undo that intent.Heuristic: if the branch has more than one commit AND the commit messages look distinct rather than incremental ("WIP", "fix typo"), confirm with the user before using the default squash. The deliberate-split case is common after /squash.
After a successful squash merge, the script auto-switches the current worktree to the default branch (master/main). This prevents the next agent or follow-up task in this worktree from committing against the now-divergent feature branch — squash collapses all commits into one new commit on master, so the old feature branch HEAD no longer shares history with the merged result.
--method merge / --method rebase — auto-switch is off by default. Both methods preserve the original commits, so the feature branch may still be useful for stacked PRs or chained follow-on work.--keep-branch — opt out of auto-switch on squash. The worktree stays on the feature branch and the script prints a divergence warning instead. Use this for stacked-PR workflows that squash but still need to keep the branch checked out (rare).If auto-switch fails (e.g., uncommitted changes in the worktree, or master is checked out in another worktree), the script falls back to a loud warning rather than aborting — the merge itself already succeeded.
--admin escalationThe script handles branch protection on its own — you do not need to fall back to a manual gh pr merge --admin. When reviewDecision is REVIEW_REQUIRED or CHANGES_REQUESTED, do_merge escalates through tiers automatically:
--admin (branch-protection bypass; succeeds when you hold admin on the repo). A successful admin merge prints WARNING: merged via --admin (branch protection bypassed) so the bypass is never silent.--admin fails (lacking admin is one cause, but a pending required status check is the more common one — gh refuses an admin merge until required checks resolve), enable --auto (auto-merge) so the PR lands once checks pass. The real admin error is printed (Admin merge failed: …), not swallowed.exit 4 — and the exit-4 message includes the actual admin-merge error so the cause is visible.On a repo where you hold admin, /merge lands the PR through the review gate itself — never substitute a raw gh pr merge --admin, which skips the post-squash worktree auto-switch and strands you on the merged feature branch. A plain non-blocked PR merges directly; the admin tier only kicks in when review is actually blocking.
Exit 0 — Show the output block verbatim as your final response. Do not add commentary.
Exit 2 (rebase conflict) — Resolve conflicts:
git add resolved filesgit rebase --continuebash <script-path> --skip-rebase [--method <method>] "<title>" "<body>"Special case: "distinct types" conflicts. If the rebase reports conflicts because the branch converted regular files to symlinks (or vice versa) while master independently edited those same files, do NOT naively resolve with --theirs or --ours. Both sides "win" — the branch's symlink target was sourced from old master content, so keeping the branch's version silently loses master's content updates.
Recovery pattern:
git rebase --abort.git rebase -i master and drop it, or git reset --soft <sha-before-symlink-commit> then re-stage selectively).--skip-rebase.Exit 3 — Tell the user: "Nothing to merge — branch has no commits ahead of the default branch."
Exit 4 (review blocked) — Review is required (REVIEW_REQUIRED/CHANGES_REQUESTED) and both the --admin bypass and auto-merge failed. The script prints the actual gh pr merge --admin error (admin merge error: …) alongside the auto-merge error — read it before concluding anything. Do not assume "no admin"; an admin merge fails for several reasons, and a pending required status check is the most common (gh refuses an admin merge until required checks resolve, even for an admin).
Exit 1 — Report the error from stderr.