بنقرة واحدة
resolve-conflicts
Resolve merge or rebase conflicts between branches.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Resolve merge or rebase conflicts between branches.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Capture session learnings and save to skills, guidelines, or reference docs under ~/.claude/.
Orchestrate parallel claude -p sessions — bootstrap, launch, monitor, and converge. Works with any skill that produces manifest.json, item directories, and a runner script.
Create a request (pull request or merge request) or update an existing one following project conventions.
Assess open PRs with unaddressed review comments and generate a parallel addressing script — produces manifest.json and let-it-rip.sh for address-request-comments execution.
Assess open work items and generate a parallel execution script — produces manifest.json and let-it-rip.sh for implement/clarify execution.
Analyze a file for refactoring opportunities and apply selected improvements.
استنادا إلى تصنيف SOC المهني
| name | resolve-conflicts |
| description | Resolve merge or rebase conflicts between branches. |
git branch --show-current 2>/dev/nullResolve merge or rebase conflicts between your PR branch and its base branch.
/resolve-conflicts - Auto-select strategy (rebase preferred, merge when cheaper)/resolve-conflicts --rebase - Force rebase (skip auto-selection)/resolve-conflicts --merge - Force merge (skip auto-selection)/resolve-conflicts <PR-number> - Resolve conflicts on a specific PR (checks out the branch)/resolve-conflicts <base-branch> - Resolve against specified base branch/resolve-conflicts --preview - Preview conflicts only (no merge or rebase)Flags can be combined: /resolve-conflicts --merge main
! preprocessing. No detection needed.0.5. Detect in-flight conflict state: run git status --porcelain first. If any path shows UU, AA, DU, UD, DD, AU, or UA, you're mid-resolution — conflicts already exist from a prior git merge, git rebase, git stash pop, or git cherry-pick. In that case:
IN_FLIGHT=true. Finalize with the mode's native continuation: merge → git commit, rebase → git rebase --continue, stash-pop → git stash drop after staging (no commit needed on the in-flight op itself), cherry-pick → git cherry-pick --continue..git/rebase-merge/git-rebase-todo to drop redundant pick lines before git rebase --skip.Worktree CWD check: if the target branch is checked out in another worktree, git checkout <branch> will fail with "already used by worktree at ". Run git worktree list and cd into the worktree's path before proceeding. All subsequent git commands operate on that worktree's state.
Parse arguments:
$ARGUMENTS contains --preview, set PREVIEW_ONLY=true$ARGUMENTS contains --merge, set STRATEGY=merge (skip auto-selection in step 5)$ARGUMENTS contains --rebase, set STRATEGY=rebase (skip auto-selection in step 5)--merge nor --rebase, set STRATEGY=autoPR_NUMBER)Determine branches:
If PR_NUMBER is set:
Fetch both branches:
!`cat ~/.claude/platform-commands/fetch-pr-branches.sh 2>/dev/null || echo "UNCONFIGURED: run setup-claude.sh to set up platform-commands"`
base and head branch from headheadRefName, check out the PR branch:
!`cat ~/.claude/platform-commands/checkout-review.sh 2>/dev/null || echo "UNCONFIGURED: run setup-claude.sh to set up platform-commands"`
Otherwise:
git branch --show-currentorigin/main:
!`cat ~/.claude/platform-commands/fetch-pr-base-branch.sh 2>/dev/null || echo "UNCONFIGURED: run setup-claude.sh to set up platform-commands"`
Fall back to echo "main" if the command fails (no PR for current branch).Check for dirty working tree:
git status --porcelain
If dirty files exist, stash them before proceeding:
git stash push -m "resolve-conflicts: stash before <STRATEGY>"
Set STASHED=true to restore later.
Fetch latest:
git fetch origin <base-branch>
Preview conflicts and select strategy:
Preview which files will conflict:
git merge-tree $(git merge-base HEAD origin/<base-branch>) HEAD origin/<base-branch>
Extract the list of conflicted files from the output. If PREVIEW_ONLY=true, show conflicts and stop here.
If STRATEGY=auto, analyze the branch to select the best strategy:
Run these in parallel:
# (a) Check for merge commits on the branch
git log --merges --oneline origin/<base-branch>..HEAD
# (b) Count commits on the branch
git rev-list --count origin/<base-branch>..HEAD
# (c) For each commit, list which files it touches (intersect with conflicted files)
git log --name-only --pretty=format:--- origin/<base-branch>..HEAD
Then compute:
has_merge_commits = whether (a) returned any resultscommit_count = result of (b)rebase_rounds = for each conflicted file, count how many commits touch it (from c). Sum across all conflicted files.merge_rounds = number of conflicted filesDecision logic:
has_merge_commits → MERGE. Rebasing merge commits requires --rebase-merges and produces confusing conflict contexts — strictly worse for token cost.rebase_rounds > merge_rounds × 1.5 → MERGE. Multiple commits touching the same conflicted files means rebase will re-conflict on the same file repeatedly, multiplying resolution rounds.Announce the selection with the estimate:
Strategy: auto → <REBASE|MERGE>
Reason: <why>
Estimated resolution rounds: rebase=<N>, merge=<N>
Start the operation:
If STRATEGY=merge:
git merge origin/<base-branch>
If STRATEGY=rebase:
git rebase origin/<base-branch>
Rebase note: Conflicts appear per-commit, not all at once. After resolving each commit's conflicts, git rebase --continue advances to the next. Be prepared for multiple conflict rounds.
For each conflicted file:
grep -n '<<<<<<' <file>
Rebase-specific: --ours/--theirs are inverted. During rebase, --ours = the base branch (what you're rebasing onto), --theirs = your commit being replayed. This is the opposite of merge. Always verify with a content check after using git checkout --ours/--theirs.
Rebase-specific: check for file renames. If the base branch renamed files, conflicts appear under the new filename but contain content from the old. Check both filenames on the base branch to determine what content is already covered before resolving.
Classify each conflict as additive or contested:
Resolution flow:
pr_num → item_num). Apply the other side's intent against the new names, not verbatim. Cross-check any references the stash/commit introduced.foo + siblings; your branch has a later commit renaming foo → bar) resolves as: keep all main's additions, apply the rename to the one symbol, drop the conflict frame. Propose as a single action.Apply the resolution and stage each file:
git add <resolved-file>
Scan for symbol drift outside conflict regions (code files only):
When one side renames symbols (variables, functions, keys) outside the conflict boundaries, git auto-merges content from the unchanged side that still references old names. Conflict markers don't flag this — the merged file parses but uses inconsistent names.
After staging each code file, check for renames in the commits touching it:
git log --oneline -p origin/<base-branch>..HEAD -- <file> | grep -E '^[-+].*\b\w+\s*=' | head -20
If renames exist, grep the resolved file for the old names and rewrite stragglers before finalizing. Prose-heavy files (docs, learnings) rarely need this check.
Complete the operation:
If IN_FLIGHT=true (from pre-flight): finalize with the mode's native continuation — git commit for merge, git rebase --continue for rebase, git stash drop for stash-pop (no commit of the pop itself), git cherry-pick --continue for cherry-pick. Skip steps 11-12.
If STRATEGY=merge:
git commit -m "Merge <base-branch> into <current-branch>"
If STRATEGY=rebase:
git rebase --continue
Repeat steps 7-9 for each commit with conflicts until rebase completes.
Restore stashed changes (if STASHED=true):
git stash pop
If stash pop itself conflicts (common after rebase — stash has pre-rebase content), resolve by keeping the post-rebase version (authoritative), then git stash drop.
Run project formatters/linters (rebase-only; merge skips this):
Rebasing across formatter config or dependency changes routinely produces unstaged Prettier/ESLint/gofmt drift after git rebase --continue succeeds. Detect and run the project's fix command. Check for common scripts in order:
# JS/TS projects (check package.json scripts)
yarn lint --fix || npm run lint -- --fix || pnpm lint --fix
# Go
gofmt -w . && goimports -w .
# Python
ruff format . && ruff check --fix .
# Java (Maven + Spotless)
./mvnw spotless:apply || mvn spotless:apply
After running, check for unstaged changes:
git status --porcelain
If changes exist, ask the operator:
Do NOT silently amend or commit — the decision depends on project convention (squash-merge vs linear history) and the operator's preference.
Push to update the PR:
If STRATEGY=merge: Ask: "Conflicts resolved. Push to update the PR?"
git push origin <current-branch>
If STRATEGY=rebase: Ask: "Rebase complete. This requires a force push (history was rewritten). Push?"
git push --force-with-lease origin <current-branch>
Verify PR status:
!`cat ~/.claude/platform-commands/check-pr-mergeable.sh 2>/dev/null || echo "UNCONFIGURED: run setup-claude.sh to set up platform-commands"`
Report whether the PR is now mergeable.
Resolving conflicts: feature/my-branch vs main
Strategy: auto → REBASE
Reason: no merge commits, low conflict overlap (2 rounds either way)
Estimated resolution rounds: rebase=2, merge=2
Rebasing (3/5) — conflict in src/config.py
...
Resolving conflicts: feature/my-branch vs main
Strategy: auto → MERGE
Reason: 4 commits touch the same 2 conflicted files (rebase=7 rounds vs merge=2)
Estimated resolution rounds: rebase=7, merge=2
Conflicts detected in 2 files:
1. src/config.py
2. src/utils.py
...
Resolving conflicts (merge): feature/my-branch ← main
Conflicts detected in 2 files:
1. src/config.py
2. README.md
--- Conflict 1/2: src/config.py ---
How should this be resolved?
> Combine both
All conflicts resolved. Push to update PR? → Pushed. PR #8 is now mergeable.
Resolving conflicts (rebase): feature/my-branch onto main
Rebasing (3/5) — conflict in src/config.py
--- Conflict: src/config.py ---
Note: during rebase, "ours" = main, "theirs" = your commit
How should this be resolved?
> Combine both
Resolved. Continuing rebase...
Rebasing (4/5) — clean
Rebasing (5/5) — clean
Rebase complete. Force push to update PR? → Pushed. PR #8 is now mergeable.
--rebase or --merge to skip auto-selection and force a strategygit status already shows unmerged paths (from stash pop, interrupted merge/rebase, cherry-pick), the skill jumps to resolution and uses the right native continuationcd into its path first — git checkout <branch> fails while another worktree holds itgit merge --abort · git rebase --abort · git stash pop keeps stash, so git checkout . + leave stash · git cherry-pick --abort--force-with-lease push