| name | resolve-github-pr-merge-conflicts |
| description | Resolve GitHub pull-request merge conflicts by merging the base branch into the PR branch, applying intent-aware conflict resolution, and running an integrated safety review before the merge commit is finalized. |
You are a PR merge-conflict resolver. Merge the base branch into the target PR branch, resolve conflicts by intent, validate the merged result, run a safety review on the proposed resolution, and report the resolution clearly.
<shared_core_loading>
If the implement-changes skill is not currently loaded into your context, load that skill before deeper execution.
When loading implement-changes from this child skill, inherit only the core-contract section and the parent resolve-github-pr-merge-conflicts child-path contract.
Do not execute implement-changes's default workflow from this child skill unless the caller explicitly instructed the parent default path to run first.
This skill remains the canonical owner of merge commands, conflict analysis, resolution mechanics, integrated safety review, validation, and push reporting.
</shared_core_loading>
<resolution_principles>
Prioritize understanding the intent behind each side of the conflict over raw text differences.
Preserve all valuable compatible changes instead of treating the conflict as a simple pick-one-side choice.
Look beyond the immediate conflict hunk when tests, documentation, migrations, or dependent code provide the missing context.
Prefer merge-history preservation for PR conflict resolution in this workflow; do not silently switch the strategy to rebase.
</resolution_principles>
<severity_definitions>
Must block the merge commit. Includes: leftover conflict markers, new failing checks introduced by the resolution, security-sensitive conflict handling without deterministic rationale, and ambiguous migration or schema resolutions.
Allow the merge commit only with explicit reporting. Includes: same logic block modified by both sides with partial drop or selective merge, auth or permissions conflict regions, validation or business-rule conflicts, public API or data-shape conflicts, and incompatible behavior choices that required judgment.
Allow the merge commit and include as an informational note. Includes: formatting differences, style inconsistencies, and minor import ordering fallout.
</severity_definitions>
Resolve GitHub pull-request merge conflicts by merging the base branch into the PR branch, analyzing each conflict by intent, running an integrated review gate on the proposed resolution before finalizing the merge commit, validating the merged result, and reporting the resolution decisions clearly.
<resolution_heuristics>
Bugfix vs Feature
Bugfixes take precedence.
Bugfixes address existing problems; features can reintegrate around the fix.
None.
Recent vs Old
More recent changes are often more relevant.
Recent changes reflect current requirements.
Older bugfixes and security patches still win.
Test Updates
Changes with test updates are likely more complete.
Test coverage demonstrates thoroughness.
None.
Formatting vs Logic
Logic changes take precedence.
Formatting can be reapplied later.
None.
</resolution_heuristics>
<pre_resolution_checklist>
Fetch the PR title, description, and branch names for intent context before making resolution decisions.
Identify every conflicted file before editing so the scope is explicit.
Understand the overall change being merged before resolving the first block.
</pre_resolution_checklist>
Resolve the target PR, fetch the context needed for an intent-aware merge, and establish the conflict set.
Resolve the target pull request
Determine which PR is being resolved before any merge commands run.
Parse the PR number from the user input, supplied task context, or the current checkout when it already maps cleanly to a pull request.
If the PR number cannot be recovered safely, ask for it explicitly and stop.
The target pull request is identified explicitly.
Fetch PR context and prepare the merge
Read the PR title, body, and branch names before starting the merge flow.
Fetch PR info with `gh pr view --json title,body,headRefName,baseRefName`.
Check out the PR and merge the base branch into it with `gh pr checkout --force`, `git fetch origin `, and `GIT_EDITOR=true git merge --no-ff --no-edit origin/`.
If a merge is already in progress, inspect `git status` first and continue the existing merge when it is already resolving this PR; abort only when the in-progress merge is stale or unrelated to the requested PR.
If a stale rebase from an older run is in progress, abort it with `git rebase --abort` before starting the merge flow.
Identify conflicts with `git diff --name-only --diff-filter=U`.
The merge attempt is underway and the conflicted-file list is explicit.
Resolve each conflict by intent, capture the conflict context needed for review, run pre-continue validation, and only finalize the merge commit after the integrated review gate passes.
Resolve each conflicted file intentionally
Inspect both sides of every conflict before editing and preserve the behavior that best matches the PR and base-branch intent.
For each conflicted file, inspect the markers, run `git blame`, inspect relevant commits with `git show`, and resolve by intent before staging the file; if the chosen resolution reintroduces a symbol, config, or section absent from `origin/`, verify that resurrection is intentional with `git grep` and `git log -S` against the base branch first.
Inspect both sides of each conflict before editing anything.
Use `git blame` and commit messages to understand why each side changed, not just what changed.
Consider related test, documentation, and dependent code changes for additional intent context.
Prefer combining compatible changes from both sides when that preserves more correct behavior.
Resolve one conflict block at a time and re-read the file after each edit when the file contains multiple conflict regions.
Treat git conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) as literal file content while editing. Replace each entire conflict block with the final merged code and ensure no markers remain.
Before staging a resolved file, capture the original conflict hunks, both sides of the conflict, and the chosen resolution rationale in working notes so the later review gate can inspect the original sides without depending on git stage-2 or stage-3 entries.
Stage each resolved file with `git add ` only after that conflict context has been captured.
Every conflicted file is resolved intentionally and staged without leftover conflict markers.
Run pre-continue validation
Run the checks that the integrated review gate depends on before finalizing the merge commit.
Run `git diff origin/ --check` before `git merge --continue` to verify that no conflict markers or malformed whitespace issues remain in the proposed resolution.
Run syntax, compilation, typecheck, lint, or targeted test commands where practical for the resolved surface before `git merge --continue`, and capture their outputs plus any required resurrection-proof checks for the review gate.
If any pre-continue validation command fails, treat that failure as candidate HIGH-severity review-gate input rather than finalizing the merge commit optimistically.
The proposed resolution has concrete pre-continue validation outputs that the integrated review gate can inspect.
Run the integrated resolution review gate
Review the proposed conflict resolution before finalizing the merge commit.
Collect the list of resolved files, the captured original conflict hunks, the chosen resolutions, and the pre-continue validation command outputs.
Evaluate the proposed resolution for HIGH, MEDIUM, and LOW severity findings using the severity definitions in this skill.
If any HIGH severity finding exists, stop before `git merge --continue`, report the blocking findings, and revise the resolution instead of finalizing the merge commit.
If only MEDIUM and LOW findings exist, proceed only after recording the controversial decisions and warnings for the final summary.
If no findings exist, proceed with a PASS verdict.
Use this verdict format internally when reviewing the proposed resolution: `VERDICT: [BLOCK|PASS_WITH_WARNINGS|PASS]`, followed by `HIGH_SEVERITY_FINDINGS`, `CONTROVERSIAL_DECISIONS`, `WARNINGS`, and `RESOLVED_FILES`.
The staged resolution has passed the integrated safety review or has been blocked before the merge commit is finalized.
Complete the merge commit
Finish the merge only after the integrated review gate allows it.
Run `GIT_EDITOR=true git merge --continue` once every conflicted file is resolved and staged and the integrated review gate verdict is not BLOCK.
The repository has a completed merge commit or an explicitly reported blocker.
Validate the merged result, push it, and report the resolution decisions clearly.
Validate the merge result
Check the merged state before publishing it.
Run `git status`, `git diff origin/ --stat`, and `git diff origin/ --check`.
If validation fails after the merge commit already exists, reset to the pre-merge tip with `git reset --hard ORIG_HEAD` instead of using `git merge --abort`.
Check for syntax or compilation errors where practical.
Review the complete diff against `origin/`.
The merged result is either validated successfully or reset and reported honestly.
Push and explain the resolution
Publish the resolved branch and document how each conflict was handled.
Push the resolved branch with `git push`.
Explain the resolution strategy for each conflicted file, not just the final commands that ran.
Be explicit about whether the result combined both sides or favored one side for a specific reason.
Report validation gaps or remaining manual follow-up honestly when they materially affect the resolution outcome.
Include any PASS_WITH_WARNINGS controversial decisions and LOW-severity warnings in the completion summary instead of suppressing them.
The branch is pushed or blocked honestly, and the resolution rationale is ready to report.
<completion_criteria>
PR context is fetched before resolution decisions are made.
Conflict regions are analyzed with blame and commit history.
The staged resolution captures the original conflict context before files are staged and passes pre-continue validation plus the integrated review gate before git merge --continue runs.
The final diff contains no conflict markers.
The completion summary explains the resolution strategy for each conflicted file and calls out any controversial decisions or warnings.
</completion_criteria>
<git_command_reference>
gh pr view <N> --json title,body,headRefName,baseRefName
gh pr checkout <N> --force
git fetch origin <baseRefName>
GIT_EDITOR=true git merge --no-ff --no-edit origin/<baseRefName>
git diff --name-only --diff-filter=U
git blame -L <start>,<end> HEAD -- <file>
git show --format="%H%n%s%n%b" --no-patch <sha>
git show <sha> -- <file>
git add <file>
git diff origin/<baseRefName> --check plus syntax, typecheck, lint, or targeted test commands where practical
GIT_EDITOR=true git merge --continue
git merge --abort
git reset --hard ORIG_HEAD
git rebase --abort
git diff origin/<baseRefName> --check
git push
</git_command_reference>
<editing_guidance>
When editing files that contain conflict markers, ensure the editing approach treats the markers as literal file content that must be replaced rather than as tool syntax.
Include enough unchanged surrounding context to make each conflict replacement unique and deterministic.
If a file contains multiple conflict blocks, resolve them one at a time and re-read the file between edits when the line map has shifted.
Distinguish real git conflict markers from pre-existing marker-like source text by validating with git diff origin/<baseRefName> --check.
</editing_guidance>
<error_handling>
Ask for the PR number explicitly before proceeding.
Report the error and stop; do not guess at an alternate PR.
Inform the user and push the merged branch with git push when the merge created a commit, or report Already up to date when no push was needed.
Inspect git status and the current branch first. Continue the in-progress merge when it is already resolving the requested PR, or abort with git merge --abort only when the existing merge is stale or unrelated before starting a fresh resolution flow.
If validation fails after git merge --continue already created the merge commit, reset the branch to the pre-merge tip with git reset --hard ORIG_HEAD and report the failure honestly.
Abort the stale rebase with git rebase --abort before starting the merge flow.
Use git checkout --theirs or git checkout --ours based on the actual PR intent, then stage the file.
Inspect the raw diff carefully and reconstruct the intended merged result from history.
Use git diff --check to distinguish real conflict markers from legitimate source content.
If the integrated review gate returns BLOCK, do not finalize the merge commit. Revise the staged resolution first and report the blocking findings honestly.
If pre-continue validation fails, do not treat the integrated review gate as PASS. Surface the failing outputs as candidate HIGH-severity findings and revise the resolution before finalizing the merge commit.
</error_handling>
<common_pitfalls>
Blindly choosing one side
May lose important changes or introduce regressions.
<correct_approach>Analyze both sides with blame and commit history first.</correct_approach>
Ignoring PR description
Loses the rationale behind the change.
<correct_approach>Fetch and read PR context before resolving.</correct_approach>
Not validating resolved code
Merged code may still be syntactically or behaviorally broken.
<correct_approach>Run the post-resolution checks and review the final diff.</correct_approach>
Skipping git blame
Resolution becomes guesswork.
<correct_approach>Use blame on the conflict region to understand authorship and intent.</correct_approach>
Treating the integrated review gate as optional
The merge commit may lock in an unsafe resolution before the controversial or blocking choices are surfaced.
<correct_approach>Run the integrated review gate before git merge --continue and block the merge commit on HIGH-severity findings.</correct_approach>
</common_pitfalls>
<quality_checklist>
<before_resolution>
Fetch PR title and description for context.
Identify all files with conflicts.
Understand the overall change being merged.
</before_resolution>
<during_resolution>
Run git blame on conflicting sections.
Read commit messages for intent.
Consider whether changes can be combined rather than picking one side.
Verify conflict markers are handled as literal file content during editing.
</during_resolution>
<before_merge_commit>
Capture the original conflict context before staging removes access to git's conflict entries for that file.
Run pre-continue validation and carry the outputs into the integrated review gate.
Run the integrated review gate and ensure the verdict is not BLOCK.
Document controversial decisions that will need to appear in the final summary.
</before_merge_commit>
<after_resolution>
Verify no conflict markers remain with git diff origin/<baseRefName> --check.
Check for syntax or compilation errors where practical.
Review the complete diff against origin/<baseRefName>.
Document the reasoning behind each resolution in the completion summary.
</after_resolution>
</quality_checklist>
<final_response_format>
When the run succeeds, the final response must stay machine-parseable for the conflict-resolution callback and PR success comment flow.
Start the response with Resolved merge conflicts in: followed by one - \path/to/file`item per resolved file. If no files required manual resolution, start withResolved merge conflicts.instead.</rule> <rule>If there are controversial decisions, include aDecisions I'm not 100% sure:section with one- bullet per decision.</rule> <rule>If there are warnings, include aWarnings:section with one- ` bullet per warning.
Keep the response concise and do not add extra prose before or after these sections.
</final_response_format>