Monitor Merge Conflicts
Check mergeability before long-running CI or Codex monitoring, then delegate conflict repair to existing merge skills.
Defaults
- Default
prto the current branch's PR when the user does not provide a PR number or URL. - Default base branch to the PR base, or
mainwhen only a branch is available. - Do not hand-resolve conflicts in this skill.
- If a merge is already in progress, invoke
fix-merge-conflicts. - If GitHub reports the PR branch conflicts with its base and no merge is in progress, invoke
merge-main-into-branch, which fetchesorigin/main, starts the merge, delegates active conflicts tofix-merge-conflicts, finishes the merge commit, and pushes. - If the PR is mergeable or mergeability is still unknown, report that state without changing code.
Workflow
- Resolve the target.
- Prefer a user-provided PR number or URL.
- Otherwise use
gh pr view --json number,url,baseRefName,headRefName,headRefOid,mergeable,mergeStateStatus. - Capture the current branch, upstream branch, PR URL, base branch, and head SHA.
- Check local merge state.
- Run
git status -sb. - If
.git/MERGE_HEADexists orgit diff --name-only --diff-filter=Ureturns paths, invokefix-merge-conflicts.
- Run
- Check PR mergeability.
- Treat
mergeStateStatusvalues such asDIRTY,BEHIND, orUNKNOWNas signals to inspect further. - Treat
mergeable: CONFLICTINGor a GitHub message that the branch has conflicts as a required conflict repair. - Re-check once after a short wait when GitHub returns
UNKNOWN, because mergeability can be asynchronous.
- Treat
- Repair conflicts when needed.
- Use
merge-main-into-branchfor remote PR conflicts when no local merge is active. - That workflow must use
fix-merge-conflictsfor the actual conflict resolution. - After repair, capture the new head SHA and report that monitoring must restart for the new head.
- Use
- Report clean or blocked states.
- If mergeability is clean, report
mergeable. - If conflict repair cannot proceed because the worktree is dirty, auth is missing, or the conflict is ambiguous, report
blocked.
- If mergeability is clean, report
Output
Return a concise status with:
- PR or branch target
- base branch and monitored head SHA
- merge-conflict state:
mergeable,conflicted,repaired,unknown, orblocked - whether
fix-merge-conflictsormerge-main-into-branchwas used - resolved files and final merge commit subject when a repair was made
- latest head SHA if it changed