Use when encountering merge conflicts - handle conflicts cleanly, verify resolution, and maintain code integrity
Handles merge conflicts systematically by analyzing both versions, making informed resolutions, and verifying the merged code works correctly. Use when git rebase or merge operations encounter conflicts.
/plugin marketplace add troykelly/claude-skills/plugin install issue-driven-development@troykelly-skillsThis skill is limited to using the following tools:
Handle merge conflicts systematically to maintain code integrity.
Core principle: Conflicts require careful resolution, not just picking one side.
Announce at start: "I'm using conflict-resolution to handle these merge conflicts."
Conflicts happen when:
| Situation | Example |
|---|---|
| Rebasing on updated main | git rebase origin/main |
| Merging main into branch | git merge origin/main |
| Cherry-picking commits | git cherry-pick [sha] |
| Pulling with local changes | git pull |
Conflict Detected
│
▼
┌─────────────────┐
│ 1. UNDERSTAND │ ← What's conflicting and why?
└────────┬────────┘
│
▼
┌─────────────────┐
│ 2. ANALYZE │ ← Review both versions
└────────┬────────┘
│
▼
┌─────────────────┐
│ 3. RESOLVE │ ← Make informed decision
└────────┬────────┘
│
▼
┌─────────────────┐
│ 4. VERIFY │ ← Tests pass, code works
└────────┬────────┘
│
▼
┌─────────────────┐
│ 5. CONTINUE │ ← Complete the operation
└─────────────────┘
# List files with conflicts
git status
# Output shows:
# Unmerged paths:
# both modified: src/services/user.ts
# both modified: src/utils/validation.ts
# See the conflict markers
cat src/services/user.ts
<<<<<<< HEAD
// Your changes
function createUser(data: UserData): User {
return { ...data, id: generateId() };
}
=======
// Their changes (main branch)
function createUser(data: UserData): Promise<User> {
return db.create({ ...data, id: generateId() });
}
>>>>>>> main
# See what changed in each branch
git log --oneline --left-right HEAD...main -- src/services/user.ts
# See the actual changes
git diff HEAD...main -- src/services/user.ts
| Question | Consider |
|---|---|
| What was the intent of your change? | Your feature/fix |
| What was the intent of their change? | Their feature/fix |
| Are they mutually exclusive? | Can both coexist? |
| Which is more recent/correct? | Check issue references |
| Do both need to be kept? | Merge the logic |
## Conflict Analysis: src/services/user.ts
### My Change (feature/issue-123)
- Made createUser synchronous
- Reason: Simplified for local testing
- Issue: #123
### Their Change (main)
- Made createUser async with DB
- Reason: Production database integration
- Issue: #456
### Resolution
Keep their async version (production requirement).
My testing simplification should use mocks instead.
When main's version is correct:
# Use their version
git checkout --theirs src/services/user.ts
git add src/services/user.ts
When your version is correct:
# Use your version
git checkout --ours src/services/user.ts
git add src/services/user.ts
When both changes are needed:
// Remove conflict markers
// Combine both changes intelligently
// Result: Keep async from main, add your new validation
async function createUser(data: UserData): Promise<User> {
// Your addition: validation
validateUserData(data);
// Their change: async DB call
return db.create({ ...data, id: generateId() });
}
# After editing
git add src/services/user.ts
Remove ALL conflict markers:
<<<<<<< HEAD ← Remove
======= ← Remove
>>>>>>> main ← Remove
The final file should have NO conflict markers.
# TypeScript: Check types
pnpm typecheck
# Or for specific file
npx tsc --noEmit src/services/user.ts
# Run all tests
pnpm test
# Run tests for affected area
pnpm test --grep "user"
# See final resolved state
git diff --cached
# Ensure no conflict markers remain
grep -r "<<<<<<" src/
grep -r "======" src/
grep -r ">>>>>>" src/
# Continue the rebase
git rebase --continue
# If more conflicts, repeat resolution
# When complete:
git push --force-with-lease
# Complete the merge
git commit -m "Merge main into feature/issue-123"
# Push
git push
If resolution goes wrong:
# Abort rebase
git rebase --abort
# Abort merge
git merge --abort
# Start fresh
Resolve one file at a time:
# See all conflicts
git status
# Resolve each
# 1. Edit file
# 2. git add file
# 3. Next file
# When all resolved
git rebase --continue
Sometimes code merges cleanly but is semantically broken:
// main: Function signature changed
function process(data: NewFormat): Result
// yours: Called with old format
process(oldFormatData); // No conflict marker, but broken!
Always run tests after resolution.
// package.json conflict
<<<<<<< HEAD
"dependencies": {
"library": "^2.0.0"
=======
"dependencies": {
"library": "^1.5.0"
>>>>>>> main
Resolution:
pnpm-lock.yamlpnpm installWhen conflicts occur during PR:
## Merge Conflict Resolution
This PR had conflicts with main that have been resolved.
### Conflicting Files
- `src/services/user.ts`
- `src/utils/validation.ts`
### Resolution Summary
**user.ts:**
Kept async implementation from main, added validation from this PR.
**validation.ts:**
Merged both validation rules (main added email, this PR added phone).
### Verification
- [x] All tests pass
- [x] Build succeeds
- [x] No conflict markers in code
- [x] Functionality verified manually
When resolving conflicts:
git add)This skill is called when:
git rebase encounters conflictsgit merge encounters conflictsThis skill ensures:
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.