Project Info
What it does
## Inspiration Every developer knows that sinking feeling when a git pull command results in a merge conflict. The resulting scramble to pursue multiple lines of code is tedious and severely detrimental to the development process. What it does What if you never had to worry about merge conflicts again? That is why we built merj, a robust command-line tool that harnesses the power of modern Artificial Intelligence to streamline this process for developers. When a developer runs a pull command from their terminal, our software automatically scans for potential merge conflicts. It uses codebase context to resolve them effectively while preserving the goals of both branches.
How we built it
merj is a tool we built on top of Git to minimize the learning curve for developers using our software. At a high level, merj has two states immediately after being called: a clean state and a conflict state. When the state is clean, our merj pull command behaves like git pull and updates the codebase; however, if our git pull results in a merge conflict, we immediately start our troubleshooting logic. The first thing we do is take a diff between the remote node and the last common ancestor node of the divergent nodes, and a diff between the local node and the same last common ancestor node. We then run a Retrieval Augmented Generation pipeline using the voyageai API to embed text, and ChromaDB to store vector embeddings, to retrieve code chunks from our codebase that are most relevant to the merge conflict, providing context for future LLM calls. After we get the code context, we use CodeRabbitβs powerful agent to summarize the changes between each divergent node and its common ancestor, providing semantic context alongside our code context. Finally, we combine all this context with the current merge conflict in Claude 3.5 Sonnet to perform our final resolution.
Challenges we ran into
System design Integration LLM Formatting One of the key challenges that we spent a lot of time working on was designing the entire end-to-end system. This was the first time any member of our team had created a command-line interface tool or built something related to version control, so we had to gain a deep understanding of the inner workings of merge conflicts to develop an effective plan. Another major problem we ran into was integrating all our components. Our program consists of many different elements, such as version control, Retrieval Augmented Generation, CodeRabbitβs API, and LLM calling, which made it very hard to integrate into a single end-to-end pipeline. Lastly, we spent time optimizing the format of our LLM prompt to get the desired output for our clients.
Accomplishments we're proud of
The main accomplishment we are proud of is our ability to integrate many different software components, with which we have minimal experience, into a single, cohesive software application that solves a practical problem many developers have faced. We were also really excited to learn about CodeRabbit and integrate their powerful ability to semantically synthesize information in git histories to enhance the quality of our final product response.
What we learned
Throughout the hackathon, our team learned practical skills in version control, Retrieval Augmented Generation, and command-line interfaces. We were very excited to explore many new tools in the software space and to persevere through the learning curves to deliver a high-quality final product.
What's next
The future of merj falls into two different buckets. The first bucket focuses on scaling merj to work for many people across many different repositories and large codebases while reducing command latency. The second bucket of merj is potentially integrating a live component into the git mechanism. This will work as follows: One person will push their code, and every other member of the project will receive an update that someone has pushed code, allowing them to automatically merge the new commit into their current working directory with just a click of the button.
Merj - AI-Powered Git Merge Conflict Resolver
π Winner β Best Use of CodeRabbit AI @ Cal Hacks 12.0 Β· π Productionized at CodeRabbit, now serving 1000+ users
πΊ Demo Video Β· π Devpost Β· βοΈ merj's journey to production (CodeRabbit blog)
Merj automatically detects and resolves Git merge conflicts using Claude AI, CodeRabbit code reviews, and intelligent code context from your repository.
Table of Contents
- What is Merj?
- Quick Start
- Complete Setup Guide
- Getting API Keys
- Running Merj
- How It Works
- Troubleshooting
- Testing Your Setup
- Cost Estimates
What is Merj?
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.
Quick Start
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 pull
For full functionality with CodeRabbit and RAG, continue to Complete Setup Guide.
Complete Setup Guide
Prerequisites
- 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)
Step 1: Clone and Install Node.js Components
# 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
Step 2: Set Up Python Environment (for RAG Pipeline)
# 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
Step 3: Install CodeRabbit CLI
# 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 login
Step 4: Configure All API Keys
Create 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
Step 5: Authenticate GitHub
# Run authentication command
merj auth
# Enter your GitHub Personal Access Token when prompted
# The token will be stored securely in ~/.merjrc
Step 6: Start the Flask Backend (for RAG)
# 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"
Getting API Keys
1. Anthropic (Claude AI) - REQUIRED
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
2. Voyage AI (Code Embeddings) - Required for RAG
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
3. GitHub Personal Access Token - REQUIRED
- 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
4. CodeRabbit Account -
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
Running Merj
Basic Workflow
# 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 resolutions
What Happens During Conflict Resolution
When 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
Example Session
$ 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
Advanced Commands
# 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
How It Works
βββββββββββββββ
β 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) β
βββββββββββββββββββββββββββ
Troubleshooting
Installation Issues
"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
API Key Issues
"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
Runtime Issues
"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
Performance Issues
- 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
Testing Your Setup
1. Dry Run Test (No API Keys Needed)
Test your installation without making API calls:
./test_dry_run.sh
This validates:
- β All files installed correctly
- β Dependencies are present
- β File permissions are correct
2. Full Integration Test
Test with real API calls using a mock conflict:
export ANTHROPIC_API_KEY="your-key"
./test_full_integration.sh
This tests:
- Complete conflict resolution flow
- API integrations
- User approval workflow
3. Create a Test Conflict
# 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 pull
Cost Estimates
Per 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
Common Workflows
Working with Feature Branches
# 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 conflicts
CI/CD Integration
Add 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-accept
Project Structure
MergeConflictResolver/
βββ 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
Support
- Issues: GitHub Issues
- Documentation: This README
- Updates: Watch the repository for new features
License
ISC License - See LICENSE file
Authors
Anay, Sam, Ayush, and Josh
Ready to resolve conflicts intelligently? Follow the Quick Start to begin!
Analysis
View
Metric
- 12
- 12
- 4
- 2
- 1
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- FlaskIn code
- JavaScriptIn code
- PythonIn code
3 of 3 appear in the indexed code.
AI coding agents
- Claude CodeCommits
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
162 KB
Source files
18
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
Anay-jo/merj
27 files Β· 537 KB Β· @ 5e8dbab
Structure
Application logic
14 files Β· 52%Domain rules, services and shared utilities.
+1 more
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here β open the file browser to check anything the diagram implies.
Languages
- Python45%
- JavaScript35%
- Markdown18%
- Shell3%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
package.json
npm Β· 6- @octokit/rest
- commander
- dotenv
- inquirer
- parse-diff
- simple-git
requirements.txt
pypi Β· 6- numpy
- orjson
- tqdm
- tree-sitter
- tree-sitter-languages
- voyageai
flask_backend/requirements.txt
pypi Β· 5- chromadb
- Flask
- Flask-CORS
- tree-sitter-languages
- voyageai
Declared in the repositoryβs manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
Feature verification
`merj push` command with force-with-lease optionVerified
Advanced command `merj push --force` for force pushing changes.
Claimed on readmehigh confidencebin/index.js:428β The 'push' command supports -f/--force and calls pushToRemote which uses git.push with --force-with-lease when force is set.
Auto-staging and auto-commit of resolved filesVerified
Accepted resolutions are staged in git; all accepted files are committed.
Claimed on readmehigh confidencebin/index.js:382β git add is run on each resolved file, and git commit --no-edit is run once all files are resolved.
Automatic merge conflict detection after git pullVerified
Merj automatically detects merge conflicts after `git pull`.
Claimed on readmehigh confidencebin/index.js:39β hasConflicts() checks `git ls-files -u` output to detect conflict state.bin/index.js:256β Pull command branches into conflict-resolution flow only if hasConflicts() is true.
Claude 3.5/4.5 Sonnet-based automatic conflict resolution combining RAG + CodeRabbit contextVerified
Combine RAG and CodeRabbit context with the current merge conflict in Claude to perform the final resolution.
Claimed on Devposthigh confidencebin/resolve_with_claude.js:266β buildResolutionPrompt combines codeRabbitContext and ragContext with the conflicted file markers into a single prompt sent to Claude.bin/resolve_with_claude.js:342β callClaude POSTs to https://api.anthropic.com/v1/messages with model claude-sonnet-4-5 to generate the merged resolution.
CodeRabbit-based analysis of both branchesVerified
Uses CodeRabbit's agent to summarize changes between each divergent node and its common ancestor for semantic context.
Claimed on Devposthigh confidencescripts/review_two_sides_with_cr.py:40β run_cr_committed() invokes the `coderabbit review --plain --type committed --base-commit` CLI against worktrees checked out at the local tip and main tip.bin/index.js:123β runCodeRabbitSideReviews() calls the python helper and captures per-branch CodeRabbit output, later summarized and saved to rag_output/coderabbit_review.json.
Flask backend REST API for the RAG pipelineVerified
Start the Flask backend (`python app.py`) which processes diff data from merj.js through the RAG pipeline.
Claimed on readmehigh confidenceflask_backend/app.py:189β /api/data endpoint receives lbd/rbd diff JSON from merj.js and calls process_git_diff_json, exactly matching README's described flow.bin/merj.js:100β merj.js POSTs diff JSON to http://127.0.0.1:5000/api/data, matching the Flask backend contract.
GitHub authentication via `merj auth` with Personal Access TokenVerified
Set up GitHub authentication with Personal Access Token via `merj auth`, token stored securely.
Claimed on readmehigh confidencebin/index.js:188β The 'auth' command prompts for a GitHub PAT via inquirer and writes GITHUB_TOKEN to a .env file, then verifies via Octokit users.getAuthenticated.lib/auth.js:27β storeToken() persists the token to ~/.merjrc with 0600 permissions, matching the README's claim that the token is stored in ~/.merjrc, though bin/index.js's auth command actually writes to .env instead, indicating lib/auth.js is unused/inconsistent with the active CLI path.
One-command git pull with automatic conflict resolutionVerified
One command. Zero headaches. `merj pull` behaves like git pull, and on conflicts automatically resolves them.
Claimed on Devposthigh confidencebin/index.js:228β The 'pull' command runs git pull, detects conflicts via git ls-files -u, and on conflict proceeds to resolution.bin/merj.js:40β Alternate/legacy pull implementation with the same clean-state vs conflict-state logic described in the README.
RAG pipeline using Voyage AI embeddings and ChromaDB for code context retrievalVerified
Runs a RAG pipeline using the voyageai API to embed text, and ChromaDB to store vector embeddings, to retrieve relevant code chunks.
Claimed on Devposthigh confidencerag_pipeline/embedder.py:28β embed_chunk/embed_chunks call voyageai.Client(...).embed with model voyage-code-3.rag_pipeline/chroma.py:22β insert_to_chroma uses chromadb.PersistentClient to store embeddings with metadata.rag_pipeline/local_remote_rag.py:65β query_similar_chunks queries the ChromaDB collection for k nearest neighbors given an embedding, used by process_git_diff_json.
User review/approval of AI-generated resolutions before commitCode-supported
Presents solutions for your review and approval; options to Accept/Reject.
Claimed on readmemedium confidencebin/index.js:336β inquirer confirm prompt 'Proceed with automatic conflict resolution?' gates the whole batch, but there is no per-file Accept/Reject step or 'View details' option as the README example session implies.
CI/CD integration with `merj pull --auto-accept`Claimed only
README example shows a GitHub Actions workflow running `merj pull --auto-accept`.
Claimed on readmehigh confidenceLive/collaborative auto-merge on push notification (future work)Claimed only
Future: one person pushes, others get notified and can auto-merge the new commit with a click.
Claimed on Devposthigh confidenceTest scripts: dry run and full integration testsClaimed only
`./test_dry_run.sh` and `./test_full_integration.sh` validate installation and full flow without/with API calls.
Claimed on readmehigh confidence
An AI agent derived these features from the projectβs Devpost page and readme, then searched the code for each one. Verified features are backed by cited code; claimed-only features had no supporting code, which is not by itself proof a feature is missing.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.