Skip to main content

Cross-PR intelligence for the agentic coding era

Project description

MergeGuard

PyPI version CI License: MIT

MergeGuard

Detect cross-PR conflicts before they reach your merge queue.

MergeGuard analyzes open pull requests and finds conflicts between them — hard overlaps, interface breaks, behavioral incompatibilities, duplications, transitive dependencies, and regressions — while you're still developing, not at merge time.

The Problem

Traditional CI checks a single PR against the base branch. It can't see that two PRs are about to break each other. Merge queues (Mergify, Trunk, Aviator) catch this at merge time — but by then you've already done the work.

MergeGuard catches it during development.

Quick Start

pip install py-mergeguard

cd your-repo
export GITHUB_TOKEN=ghp_...
mergeguard analyze --pr 42

That's it. Auto-detects platform and repo from your git remote.

What It Detects

Type Example
Hard conflict Two PRs modify the same function body
Interface conflict PR A changes a function signature, PR B calls it (cross-file)
Behavioral conflict Incompatible logic changes in the same module
Duplication Two PRs independently implement the same feature
Transitive PR A changes a module that PR B's files depend on
Regression A PR re-introduces something recently removed

GitHub Action

name: MergeGuard
on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Vansh2795/mergeguard@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

How It Compares

MergeGuard Merge Queues (Mergify, Trunk) AI Review (CodeRabbit, Qodo)
Detects cross-PR conflicts During development At merge time No
Requires workflow change No Yes (adopt queue) No
Open source MIT Commercial Commercial
Multi-platform GitHub + GitLab + Bitbucket GitHub only (mostly) GitHub (mostly)

Platforms

Platform Status
GitHub (Cloud + Enterprise Server) Supported
GitLab (Cloud + self-hosted) Supported
Bitbucket Cloud Supported

CLI Commands

mergeguard analyze --pr 42          # Analyze a PR for cross-PR conflicts
mergeguard map                      # Collision map of all open PRs
mergeguard suggest-order            # Optimal merge sequence
mergeguard watch                    # Continuous monitoring
mergeguard serve                    # Webhook server for real-time detection
mergeguard init                     # Interactive setup wizard

Configuration

# .mergeguard.yml
risk_threshold: 50
max_open_prs: 30
ignored_paths:
  - "*.lock"
  - "package-lock.json"

See Configuration Guide for all options.

Benchmarks

Tested against real open-source repos. Transitive accuracy improvements reduced false positives by 59-82% on FastAPI. See Benchmark Results.

Documentation

Also Included

MergeGuard ships with additional features for enterprise workflows:

  • Policy engine — declarative conditions-and-actions for merge automation
  • DORA metrics — conflict resolution time tracking
  • Blast radius visualization — interactive D3.js dependency graph
  • CODEOWNERS routing — team-aware Slack/Teams notifications
  • Merge queue integration — commit status checks with priority labels
  • Stacked PR support — Graphite, branch chains, label-based detection
  • MCP server — AI agent integration (check_conflicts, get_risk_score, suggest_merge_order)

See docs/ for details on each feature.

Development

git clone https://github.com/Vansh2795/mergeguard.git
cd mergeguard
uv sync --dev
uv run pytest
uv run ruff check src/ tests/
uv run mypy src/

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_mergeguard-1.0.1.tar.gz (813.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_mergeguard-1.0.1-py3-none-any.whl (157.9 kB view details)

Uploaded Python 3

File details

Details for the file py_mergeguard-1.0.1.tar.gz.

File metadata

  • Download URL: py_mergeguard-1.0.1.tar.gz
  • Upload date:
  • Size: 813.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_mergeguard-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bf4f2a1be1096fb1b2cfb156fac5c0287f57fa1c7f7fc24a06ab94f2c2a805e1
MD5 a6ab0f50c2fd864040877bf83e3f24ab
BLAKE2b-256 7761238eddc2d3c0e9d625360e312928b5b0191c5a0fec99d72751146eed35e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_mergeguard-1.0.1.tar.gz:

Publisher: release.yml on Vansh2795/mergeguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_mergeguard-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_mergeguard-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 157.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_mergeguard-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 350566fba4432088059e6f7b56fd85d1b92c0990be0af7b187eed8c84903a985
MD5 79a811795ecc6e765391555dbcd79dc5
BLAKE2b-256 f7985a42e70a0e17b52b775a7e52e260dd1f3683f2ee3aa6be3918eab5488b20

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_mergeguard-1.0.1-py3-none-any.whl:

Publisher: release.yml on Vansh2795/mergeguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page