Merj automatically detects and resolves Git merge conflicts using Claude AI, CodeRabbit code reviews, and intelligent code context from your repository.
- What is Merj?
- Quick Start
- Complete Setup Guide
- Getting API Keys
- Running Merj
- How It Works
- Troubleshooting
- Testing Your Setup
- Cost Estimates
Merj transforms the tedious process of resolving Git merge conflicts into an intelligent, semi-automated workflow:
- Detects merge conflicts automatically after
git pull - Analyzes both sides of the conflict using CodeRabbit
- Understands your codebase using RAG (Retrieval-Augmented Generation)
- Resolves conflicts intelligently using Claude AI
- Presents solutions for your review and approval
Instead of manually editing conflict markers, you get AI-powered resolutions with explanations.
Get Merj running in 5 minutes:
# 1. Clone the repository
git clone https://github.com/Anay-jo/MergeConflictResolver.git
cd MergeConflictResolver
# 2. Run quick setup (Node.js dependencies only)
npm install && npm link
# 3. Set up GitHub authentication
merj auth
# 4. Set Claude AI key (required)
export ANTHROPIC_API_KEY="sk-ant-..."
# 5. Try it!
cd your-git-repo
merj pullFor full functionality with CodeRabbit and RAG, continue to Complete Setup Guide.
- Node.js v18+ (Download)
- Python 3.8+ (Download)
- Git 2.0+
- GitHub Account with Personal Access Token
- API Keys for Claude AI and Voyage AI (see Getting API Keys)
# Clone the repository
git clone https://github.com/Anay-jo/MergeConflictResolver.git
cd MergeConflictResolver
# Install Node.js dependencies
npm install
# Make 'merj' command available globally
npm link
# Verify installation
merj --help# Create Python virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
pip install -r flask_backend/requirements.txt# Install CodeRabbit CLI globally
curl -fsSL https://cli.coderabbit.ai/install.sh | sh
# Reload your shell configuration
source ~/.zshrc # or ~/.bashrc for bash users
# Verify installation
coderabbit --version
# Log in to CodeRabbit (opens browser)
coderabbit auth loginCreate a .env file in the project root (or set environment variables):
# Required API Keys
export ANTHROPIC_API_KEY="sk-ant-api03-xxxxx" # Claude AI (Required)
export VOYAGE_API_KEY="pa-xxxxx" # Embeddings (Required for RAG)
# Optional Configuration
export MAIN_REF="origin/main" # Your main branch
export MODEL="claude-3-5-sonnet-20241022" # Claude model to use# Run authentication command
merj auth
# Enter your GitHub Personal Access Token when prompted
# The token will be stored securely in ~/.merjrc# In a separate terminal, activate Python environment
source venv/bin/activate
# Start Flask backend
cd flask_backend
python app.py
# You should see: "Running on http://127.0.0.1:5000"Claude AI analyzes and resolves your merge conflicts.
- Visit https://console.anthropic.com
- Sign up or log in
- Go to API Keys section
- Click Create Key
- Copy the key (starts with
sk-ant-api03-) - Set it:
export ANTHROPIC_API_KEY="your-key-here"
Pricing: ~$0.01-0.02 per conflict resolution
Voyage AI creates semantic embeddings of your code for intelligent context retrieval.
- Visit https://www.voyageai.com
- Sign up for an account
- Go to Dashboard β API Keys
- Create a new key
- Copy the key (starts with
pa-) - Set it:
export VOYAGE_API_KEY="your-key-here"
Pricing: ~$0.001 per 1000 tokens
- Visit https://github.com/settings/tokens
- Click Generate new token (classic)
- Name it (e.g., "Merj CLI")
- Select scopes:
- β
repo(Full control of private repositories) - β
read:org(Read org and team membership)
- β
- Click Generate token
- Copy immediately (won't be shown again!)
- Use with:
merj auth
CodeRabbit provides intelligent code review insights for both sides of the conflict.
- Visit https://coderabbit.ai
- Sign up for free account
- Install CLI (see Step 3 above)
- Authenticate:
coderabbit auth login
# 1. Ensure Flask backend is running (in separate terminal)
cd flask_backend && python app.py
# 2. Navigate to your git repository
cd /path/to/your/repo
# 3. Pull changes (Merj will handle conflicts)
merj pull
# 4. Follow the prompts to review and accept/reject resolutionsWhen you run merj pull and conflicts are detected:
-
Detection Phase
- Git pull executes and conflicts are identified
- Conflicted files are listed
-
Analysis Phase (for each conflict)
- CodeRabbit reviews changes on both branches
- RAG pipeline extracts relevant code context
- Context is saved to
rag_output/
-
Resolution Phase
- Claude AI receives:
- The conflicted file with markers
- CodeRabbit's analysis
- Similar code patterns from your codebase
- Claude generates a clean, merged version
- Claude AI receives:
-
Review Phase
- You're shown the AI's resolution
- Options: Accept, Reject, or View details
- Accepted resolutions are staged in git
-
Completion
- All accepted files are committed
- Summary shows resolved/rejected counts
$ merj pull
π Checking authentication...
β
Authenticated as: joshuachen
π¦ Repository: merj/test-repo
πΏ Current branch: feature-branch
π― Remote: origin
Pulling from origin...
β οΈ Merge conflicts detected in 2 files:
- src/auth.py
- src/database.py
Starting AI-powered resolution...
[1/2] Resolving: src/auth.py
π CodeRabbit: Found 3 code quality issues
π§ Claude AI: Analyzing conflict...
β¨ Resolution ready!
The conflict is between:
- LOCAL: Added password hashing with bcrypt
- REMOTE: Added rate limiting for login attempts
Proposed resolution combines both features safely.
Accept this resolution? (Y/n): Y
β
Resolution applied to src/auth.py
[2/2] Resolving: src/database.py
...
Summary:
β
Resolved: 2 files
β Rejected: 0 files
β οΈ Failed: 0 files# Force push changes
merj push --force
# Use a different Claude model
MODEL=claude-3-opus-20240229 merj pull
# Debug mode (verbose output)
DEBUG=true merj pull
# Skip CodeRabbit analysis
SKIP_CODERABBIT=true merj pullβββββββββββββββ
β merj pull β
βββββββ¬ββββββββ
β
βββββββββββββββββββββββββββ
β Git Pull & Detect β
β Conflicts β
βββββββ¬ββββββββββββββββββββ
β
βββββββββββββββββββββββββββ
β CodeRabbit Analysis β
β (Review both branches) β
βββββββ¬ββββββββββββββββββββ
β
βββββββββββββββββββββββββββ
β RAG Pipeline β
β (Find similar code) β
βββββββ¬ββββββββββββββββββββ
β
βββββββββββββββββββββββββββ
β Claude AI β
β (Generate resolution) β
βββββββ¬ββββββββββββββββββββ
β
βββββββββββββββββββββββββββ
β User Review β
β (Accept/Reject) β
βββββββ¬ββββββββββββββββββββ
β
βββββββββββββββββββββββββββ
β Git Commit β
β (Stage accepted files) β
βββββββββββββββββββββββββββ
"merj: command not found"
# Re-link the CLI
npm link
# Or use npx
npx merj pull"Python module not found"
# Ensure virtual environment is activated
source venv/bin/activate # macOS/Linux
# or
venv\Scripts\activate # Windows
# Reinstall dependencies
pip install -r requirements.txt"CodeRabbit: command not found"
# Reinstall CodeRabbit CLI
curl -fsSL https://cli.coderabbit.ai/install.sh | sh
# Restart terminal or reload shell
source ~/.zshrc # or ~/.bashrc"Claude API error 401: Unauthorized"
- Check your Anthropic API key is correct
- Ensure it starts with
sk-ant-api03- - Verify at https://console.anthropic.com
"Voyage AI authentication failed"
- Verify your Voyage API key
- Should start with
pa- - Check key has access to
voyage-code-3model
"GitHub authentication failed"
- Regenerate token at GitHub Settings
- Ensure token has
reposcope - Run
merj authagain
"Flask backend connection refused"
# Check if Flask is running
curl http://127.0.0.1:5000/api/health
# If not, start it:
cd flask_backend
python app.py"No conflicts detected"
# Verify conflicts exist
git status
# Should show:
# both modified: filename.py"ChromaDB error"
# Clear ChromaDB cache
rm -rf rag_pipeline/demo_chroma_db/
# Restart Flask backend"Resolution looks wrong"
- Check RAG context:
cat rag_output/llm_context.txt - Review CodeRabbit findings:
cat rag_output/coderabbit_review.json - Try different Claude model:
MODEL=claude-3-opus-20240229
- Slow resolution: Reduce RAG context chunks (default: 5)
- High API costs: Use smaller Claude model (sonnet vs opus)
- Memory issues: Process one conflict at a time
Test your installation without making API calls:
./test_dry_run.shThis validates:
- β All files installed correctly
- β Dependencies are present
- β File permissions are correct
Test with real API calls using a mock conflict:
export ANTHROPIC_API_KEY="your-key"
./test_full_integration.shThis tests:
- Complete conflict resolution flow
- API integrations
- User approval workflow
# Create test repository
mkdir test-merge && cd test-merge
git init
# Create initial file
echo "original content" > test.txt
git add test.txt
git commit -m "Initial commit"
# Create conflicting changes
git checkout -b feature
echo "feature change" > test.txt
git add test.txt
git commit -m "Feature change"
git checkout main
echo "main change" > test.txt
git add test.txt
git commit -m "Main change"
# Merge with conflicts
git merge feature # Creates conflict
# Now use Merj
merj pullPer conflict resolution:
- Claude AI: $0.01-0.02 (2 API calls)
- Voyage AI: <$0.001 (embeddings)
- CodeRabbit: Free tier available
- Total: ~$0.02 per conflict
Monthly estimates (100 conflicts):
- Light usage: ~$2
- Regular usage: ~$5-10
- Heavy usage: ~$20-30
# Create feature branch
git checkout -b feature/new-feature
# Make changes and push
git add .
git commit -m "Add new feature"
merj push
# Later, pull with conflict resolution
git checkout main
git pull origin main
git checkout feature/new-feature
merj pull origin main # Merj handles conflictsAdd to your CI pipeline:
# .github/workflows/merge.yml
- name: Setup Merj
run: |
npm install -g merj
merj auth
- name: Resolve conflicts
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
merj pull --auto-acceptMergeConflictResolver/
βββ bin/
β βββ index.js # CLI entry point
β βββ merj.js # Main commands
β βββ resolve_with_claude.js # Claude AI integration
βββ lib/
β βββ auth.js # GitHub authentication
β βββ git.js # Git operations
βββ rag_pipeline/
β βββ chunker.py # Code parser
β βββ embedder.py # Voyage AI integration
β βββ chroma.py # Vector database
β βββ local_remote_rag.py # RAG retrieval
βββ flask_backend/
β βββ app.py # REST API server
βββ scripts/
β βββ review_two_sides_with_cr.py # CodeRabbit integration
βββ rag_output/ # Generated context files
β βββ llm_context.txt
β βββ coderabbit_review.json
βββ package.json # Node dependencies
- Issues: GitHub Issues
- Documentation: This README
- Updates: Watch the repository for new features
ISC License - See LICENSE file
Anay, Sam, Ayush, and Josh
Ready to resolve conflicts intelligently? Follow the Quick Start to begin!