/merge
Intelligently merge branches with context-aware conflict resolution
Usage
BASH
/merge <branch-name>Overview
Smart branch merging that gathers context from PRs and issues before resolving conflicts. Prevents resolution loops with intelligent conflict handling.
Workflow
- Context Gathering: Check current branch and working tree status
- Feature Analysis: Research PR/issue context using gh cli
- Merge Attempt: Fetch and merge with
--no-commit - Conflict Detection: Parse conflicted files
- Smart Resolution: Apply context-aware resolution strategies
- Verification: Review changes and check for remaining markers
- Failure Handling: Abort after 3 attempts per file
Conflict Resolution Strategies
By File Type
- package.json: Merge dependencies, prefer higher versions
- Config files: Combine settings unless mutually exclusive
- Source code: Use PR/issue context to understand intent
- Tests: Keep all tests unless duplicates
By Pattern
- Import conflicts: Merge all imports, deduplicate
- Function additions: Keep both if different purposes
- Modified same line: Use context to determine correct version
- Deleted vs modified: Check if deletion was intentional
Safety Rules
- ABORT if uncommitted changes exist
- STOP if >10 files conflicted (ask user for guidance)
- NEVER blindly accept theirs/ours without analysis
- Max 3 resolution attempts per file
- Always gather context before merging
Example
BASH
# Merge feature branch into current branch
/merge feature/new-login
# Claude will:
# - Check current branch status
# - Fetch PR/issue context
# - Merge with conflict detection
# - Resolve conflicts intelligently
# - Commit with descriptive messageAllowed Tools
gitandghcommands- Read, Edit, MultiEdit
- Task (for parallel context gathering)