git-conflicts
Resolve merge conflicts file-by-file. Use when a merge/rebase has conflicts, a PR can't merge, "fix conflicts" is requested, or branches have diverged.
What this skill does
# /git:conflicts Resolve merge conflicts using modern git features. ## When to Use This Skill | Use this skill when... | Use git-ops agent instead when... | |------------------------|-----------------------------------| | Merge or rebase produced conflicts | Complex multi-branch cherry-pick across many commits | | PR shows "can't merge" / "fix conflicts" | Conflicts require deep business logic understanding | | Config files (JSON, YAML, lockfiles) diverged | Interactive rebase with squash/fixup needed | | Need to accept one side wholesale (`--ours`/`--theirs`) | Architectural redesign spanning many files | ## Context - Current branch: !`git branch --show-current` - Git status: !`git status --porcelain=v2 --branch` - Merge state: !`find .git -maxdepth 1 -name 'MERGE_HEAD' -o -name 'REBASE_HEAD' -o -name 'rebase-merge' -o -name 'rebase-apply'` - Conflicted files: !`git diff --name-only --diff-filter=U` - Conflict style: !`git config merge.conflictStyle` - Rerere enabled: !`git config rerere.enabled` - Git version: !`git version` ## Parameters Parse these from `$ARGUMENTS`: - `$1`: File path (resolve single file) OR PR number (fetch and merge base branch) - `--ours`: Accept current branch version for all conflicts - `--theirs`: Accept incoming branch version for all conflicts - `--push`: Push after resolution is committed ## Execution Execute this conflict resolution workflow: ### Step 1: Assess the situation 1. Check context for existing merge/rebase state (`MERGE_HEAD`, `REBASE_HEAD`, `rebase-merge`, `rebase-apply`) 2. If PR number provided and no active merge state: - Get PR details: `gh pr view <number> --json headRefName,baseRefName,mergeable` - Fetch base: `git fetch origin <base-branch>` - Start merge: `git merge origin/<base-branch> --no-ff` - If merge succeeds cleanly, report "No conflicts" and exit 3. If no PR number and no active merge state, detect from current branch: - `gh pr list --head $(git branch --show-current) --json number,baseRefName,mergeable` - Use the detected PR number and base branch; proceed as above 3. List conflicted files: `git diff --name-only --diff-filter=U` 4. If no conflicted files found, report current status and exit ### Step 2: Configure zdiff3 (if not set) Check the conflict style from context. If `merge.conflictStyle` is not `zdiff3`: 1. Set for this repo: `git config merge.conflictStyle zdiff3` 2. Re-checkout conflicted files with zdiff3 markers: `git checkout --conflict=zdiff3 -- <file>` for each conflicted file 3. Enable rerere if not already: `git config rerere.enabled true` 4. Enable rerere autoupdate: `git config rerere.autoupdate true` (auto-stages files resolved by rerere) This gives three-way conflict markers with the common ancestor, compacted by removing shared lines at conflict boundaries. Much easier to resolve than the default two-way markers. ### Step 3: Resolve conflicts **If `--ours` flag**: Accept current branch for all conflicted files: ``` git restore --ours -- <file> # for each file git add <file> ``` **If `--theirs` flag**: Accept incoming branch for all conflicted files: ``` git restore --theirs -- <file> # for each file git add <file> ``` **Otherwise, resolve each file intelligently:** For each file from `git diff --name-only --diff-filter=U`: 1. Read the file — with zdiff3, conflict markers look like: ``` <<<<<<< HEAD (current branch changes) ||||||| (common ancestor) (what the code looked like before both changes) ======= (incoming changes) >>>>>>> branch-name ``` 2. The `|||||||` section (common ancestor) shows what both sides started from — use it to understand intent 3. Apply resolution strategy by file type: | File Type | Strategy | |-----------|----------| | `package.json`, `plugin.json` | Merge objects/arrays, take higher versions | | YAML config | Merge keys from both sides | | `CHANGELOG.md` | Include entries from both sides in chronological order | | `README.md`, docs | Include content from both sides | | Source code | Integrate both changes preserving logic of each | | Lock files (`bun.lock`, `package-lock.json`) | Delete and regenerate after resolving other files | | `.release-please-manifest.json` | Take higher version numbers | 4. Edit the file to remove ALL conflict markers (`<<<<<<<`, `|||||||`, `=======`, `>>>>>>>`) and combine changes 5. Stage: `git add <file>` **Important ours/theirs note for rebases:** During `git rebase`, the meaning of ours/theirs is swapped — `--ours` refers to the branch being rebased onto (usually main), `--theirs` refers to your feature branch commits. ### Step 4: Verify and complete 1. Check no conflict markers remain: search all resolved files for `<<<<<<<` 2. Check `git diff --name-only --diff-filter=U` returns empty (no remaining unmerged paths) 3. Check if rerere recorded anything: `git rerere status` 4. Complete the operation: - If merging: `git commit --no-edit` - If rebasing: `git rebase --continue` 5. If `--push` flag: `git push origin $(git branch --show-current)` ### Step 5: Report results Summarize what was resolved: - List each file and how it was resolved (merged both sides, accepted ours/theirs, regenerated) - Note if rerere recorded new resolutions for future reuse - If PR number was provided (or detected from branch), comment on the PR: ``` gh pr comment <number> --body "Merge conflicts with <base-branch> resolved automatically. Resolved files: - file1.json (merged entries from both sides) - file2.md (combined changelog entries) " ``` ## Conflict Resolution Patterns ### JSON Files - Merge array entries from both sides, deduplicate - For version fields, take the higher version - For object properties, include properties from both sides - Validate JSON after resolution ### Markdown Files - Include content from both sides - Maintain chronological order for changelogs - Include table rows from both sides ### Source Code - Use the common ancestor (zdiff3 `|||||||` section) to understand what both sides changed - Integrate both modifications preserving the intent of each - If same line changed incompatibly, prefer the PR branch change and note in commit message ### Squash Merge Pitfall If the same conflicts keep recurring, the likely cause is squash merges. Squash-merging breaks the common ancestry chain, so stacked or sibling branches lose their merge base. Rerere mitigates this by replaying recorded resolutions, but the root fix is to avoid squash merges on branches with dependents. ### When to Abort Abort with `git merge --abort` or `git rebase --abort` if: - Conflicts span many files with incompatible architectural changes - Resolution requires understanding business requirements you don't have context for - Lock files are the only conflicts (delete, regenerate, commit) ## Quick Reference | Task | Command | |------|---------| | List conflicted files | `git diff --name-only --diff-filter=U` | | Re-checkout with zdiff3 | `git checkout --conflict=zdiff3 -- <file>` | | Accept current branch | `git restore --ours -- <file>` | | Accept incoming branch | `git restore --theirs -- <file>` | | Recreate conflict markers | `git checkout -m -- <file>` | | Check rerere status | `git rerere status` | | View rerere diff | `git rerere diff` | | Forget bad resolution | `git rerere forget <file>` | | Abort merge | `git merge --abort` | | Abort rebase | `git rebase --abort` | | Continue rebase | `git rebase --continue` | ## Agentic Optimizations | Context | Command | |---------|---------| | List conflicts | `git diff --name-only --diff-filter=U` | | Conflict count | `git diff --name-only --diff-filter=U \| wc -l` | | Full conflict diff | `git diff --diff-filter=U` | | PR mergeable state | `gh pr view N --json mergeable` | | Check markers remain | `grep -rn '<<<<<<<' <files>` | | Porcelain status | `git status --porcelain=v2` | | Detect merge/rebase state | `test -f .git/MERGE_HEAD && echo merge \|\| test -d .git/rebase-merge && echo reb
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.