/git:merge-mainfrom git
Merges the repository's default branch (main, master, production, or whatever it is called) into the current branch, resolves any merge conflicts by combining both sides' intent, and verifies the result builds before committing the merge. Use when the user asks to merge main, update or sync a branch with main, catch a branch up, bring in upstream changes, or resolve merge conflicts. Never rebases, never force-pushes, and pushes only when `--push` is passed.
Ships in git. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You bring the current branch up to date with the repository's default branch by merging, then resolve whatever conflicts that produces. The user has delegated the tedious part: finding out what the default branch is actually called, fetching it, working through each conflicted file with both sides' intent in mind, and confirming the merged result still builds. Act autonomously within the rails below. Conflict resolution embeds intent decisions, so when two sides genuinely disagree and the history does not settle it, ask one focused question rather than guessing.
Before resolving any conflict, read references/conflict-resolution.md relative to this skill. It covers how to read a three-way conflict, per-file-type rules (lockfiles, generated files, changelogs, deletions, binaries), and semantic conflicts that produce no markers.
Parse any arguments included with the invocation or request:
develop): merge this branch instead of the detected default branch.--remote <name>: the remote to fetch from (default origin). Useful for forks where the default branch lives on upstream.--push: push the current branch after a successful merge. Without it, never push.--no-check: skip the build and test verification after the merge.Unless a branch was given, determine the default branch name in this order and record which method succeeded:
git symbolic-ref --short refs/remotes/<remote>/HEAD (e.g., origin/main). If it is unset, git remote set-head <remote> --auto and try again.gh repo view --json defaultBranchRef --jq .defaultBranchRef.name, when the GitHub CLI is available and authenticated.git remote show <remote> and read the HEAD branch: line.main, master, trunk, develop that exists under refs/remotes/<remote>/.If none of these yields a branch, stop and ask. Always merge the remote-tracking ref (<remote>/<branch>), never the local copy, which may be stale.
git status must not report a merge, rebase, cherry-pick, or revert in progress. If one is, stop and ask; do not abort someone else's operation.git pull.git status --porcelain), stop and ask whether to commit them first (the commit skill, git:commit, does that) or set them aside. Never stash, reset, or discard changes on your own.git fetch <remote> <branch>.git merge-base --is-ancestor <remote>/<branch> HEAD. If it succeeds, report that and stop.git rev-list --count HEAD..<remote>/<branch>git diff --stat HEAD...<remote>/<branch>git merge-tree --write-tree --name-only HEAD <remote>/<branch> (Git 2.38 or newer; if unsupported, skip this and find out from the merge itself).Tell the user in one line what you are about to merge: the branch, how it was detected, how many commits, and how many files are expected to conflict.
Record progress with the host's task-tracking feature when available: one item per conflicted file, updated as each is resolved.
git merge --no-edit <remote>/<branch>
Let Git choose fast-forward or a merge commit; do not force either. If the merge completes cleanly, go to Step 5.
If Git reports conflicts, list them with git diff --name-only --diff-filter=U and continue to Step 4. Do not run git merge --abort unless resolution turns out to be impossible or the user asks; if you do abort, say so explicitly.
For every conflicted file, understand both sides before editing anything:
git log --oneline <merge-base>..HEAD -- <file>git log --oneline <merge-base>..<remote>/<branch> -- <file><merge-base> is git merge-base HEAD <remote>/<branch>.git show :1:<file> is the common ancestor, :2: is this branch (ours), :3: is the default branch (theirs). For a text file, re-materialize the conflict with the ancestor visible: git checkout --conflict=diff3 -- <file>. Seeing the base makes it obvious which side changed what.git diff --check and grep -nE '^(<{7}|={7}|>{7})' <file> should both be clean. Then git add <file>.Only touch conflicted files, plus the lockfiles and generated outputs you regenerate from them. Do not fix unrelated problems you notice along the way; mention them in the report instead.
Unless --no-check was passed, confirm the merged tree works before committing. Pick the fastest relevant checks the repository offers:
package.json scripts: typecheck, lint, build, test (in that order of cost); use the repo's package manager, detected from the lockfile.bundle exec rubocop and bundle exec rspec or bundle exec rake test.cargo check then cargo test.go build ./... then go test ./....ruff or flake8, then pytest.Makefile or justfile with obvious check, lint, or test targets.Prefer a typecheck or build over a full test suite when the suite takes more than a few minutes; at minimum run the tests that cover the files you resolved. Semantic conflicts (a function renamed on one side and called on the other) produce no markers and only show up here, so treat a failure as part of the resolution and fix it. If a failure is clearly unrelated to the merge, confirm it also fails on <remote>/<branch> before concluding that, report it, and do not block the merge on it.
If the merge fast-forwarded or Git already committed it, there is nothing to do. Otherwise:
git commit --no-edit
Keep Git's generated merge message. Never pass --no-verify; if a commit hook rejects the merge, show its output and ask how to proceed.
Only when --push was passed:
git push.git push -u <remote> HEAD.Always end with a report, whatever the exit reason:
## Merge report: <remote>/<branch> → <current branch>
- **Default branch:** <name> (detected via <method>)
- **Merged:** <N> commits, <M> files changed
- **Conflicts:** <count>
- `<file>`: <how it was resolved, one line>
- **Checks:** <what ran and the result, or "skipped (--no-check)">
- **Pushed:** <yes | no>
- **Needs you:** <judgment calls you flagged, pre-existing failures, anything deliberately left alone; or "nothing">
-X ours or -X theirs, and never take a whole file with --ours or --theirs without reading both sides first. Lockfiles and generated files follow the reference's regeneration rules instead.--push.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 skills in this plugin
npx claudepluginhub gjtorikian/agent-plugins --plugin git