agents/skills/merge/SKILL.md
Merge current branch to the default branch via GitHub PR merge. Use when ready to merge a PR or land a branch.
npx skillsauth add drn/dots mergeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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:
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>] "<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.
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) — The PR requires review and auto-merge is not available. Tell the user: "PR requires an approving review before it can merge. Auto-merge is not enabled on this repository — ask a reviewer to approve, then re-run /merge."
Exit 1 — Report the error from stderr.
development
Walk every unresolved review thread on a PR, triage each one, reply with a rationale of whether or not the comment will be acted upon, make the code change if warranted, and mark the thread resolved. Use when the user asks to address only the open PR comments without re-running CI, respond to review feedback, resolve review threads, or clear bot comments on a PR.
tools
Iteratively run /rereview, fix the findings, and loop until reviewers approve clean. Use for iterative automated review, when you want /rereview to loop until clean, or for a paranoid pre-merge review that auto-addresses every blocker.
development
Generate self-contained HTML visualizations with Plannotator theming. Use for implementation plans, PR explainers, architecture diagrams, data tables, slide decks, and any visual explanation of technical concepts. Plans and PR explainers follow Plannotator's prescriptive approach; all other visual content delegates to nicobailon/visual-explainer.
development
Create reviewed Codex goal setup packages for long-running /goal work. Use when the user wants to turn an idea, backlog, project mission, or vague objective into durable goal files under a project goals slug folder, with Plannotator review gates for brief, narrative plan with acceptance criteria, verification, blockers, and the final /goal prompt.