This mode resolves merge conflicts for a specific pull request by analyzing git history,
commit messages, and code changes to make intelligent resolution decisions. It receives
a PR number (e.g., "#123") and handles the entire conflict resolution process.
Parse PR number from user input
Extract the PR number from input like "#123" or "PR #123"
Validate that a PR number was provided
Fetch PR information
gh pr view [PR_NUMBER] --json title,body,headRefName,baseRefName
Get PR title and description to understand the intent
Identify the source and target branches
Checkout PR branch and prepare for rebase
gh pr checkout [PR_NUMBER] --force
git fetch origin main
GIT_EDITOR=true git rebase origin/main
Force checkout the PR branch to ensure clean state
Fetch the latest main branch
Attempt to rebase onto main to reveal conflicts
Use GIT_EDITOR=true to ensure non-interactive rebase
Check for merge conflicts
git status --porcelain
git diff --name-only --diff-filter=U
Identify files with merge conflicts (marked with 'UU')
Create a list of files that need resolution
Analyze each conflicted file to understand the changes
Read the conflicted file to identify conflict markers
Extract the conflicting sections between <<<<<<< and >>>>>>>
Run git blame on both sides of the conflict
Fetch commit messages and diffs for relevant commits
Analyze the intent behind each change
Determine the best resolution strategy for each conflict
Categorize changes by intent (bugfix, feature, refactor, etc.)
Evaluate recency and relevance of changes
Check for structural overlap vs formatting differences
Identify if changes can be combined or if one should override
Consider test updates and related changes
Apply the resolution strategy to resolve conflicts
For each conflict, apply the chosen resolution
Ensure proper escaping of conflict markers in diffs
Validate that resolved code is syntactically correct
Stage resolved files with git add
Verify the resolution and prepare for commit
Run git status to confirm all conflicts are resolved
Check for any compilation or syntax errors
Review the final diff to ensure sensible resolutions
Prepare a summary of resolution decisions
gh pr checkout [PR_NUMBER] --force
Force checkout the PR branch to ensure clean state
git fetch origin main
Get the latest main branch from origin
GIT_EDITOR=true git rebase origin/main
Rebase current branch onto main to reveal conflicts (non-interactive)
git blame -L [start_line],[end_line] [commit_sha] -- [file_path]
Get commit information for specific lines
git show --format="%H%n%an%n%ae%n%ad%n%s%n%b" --no-patch [commit_sha]
Get commit metadata including message
git show [commit_sha] -- [file_path]
Get the actual changes made in a commit
git ls-files -u
List unmerged files with stage information
GIT_EDITOR=true git rebase --continue
Continue rebase after resolving conflicts (non-interactive)
true
Set to 'true' (a no-op command) to prevent interactive prompts during rebase operations
Prefix git rebase commands with GIT_EDITOR=true to ensure non-interactive execution
All merge conflicts have been resolved
Resolved files have been staged
No syntax errors in resolved code
Resolution decisions are documented