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.0.tar.gz (805.8 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.0-py3-none-any.whl (157.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_mergeguard-1.0.0.tar.gz
  • Upload date:
  • Size: 805.8 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.0.tar.gz
Algorithm Hash digest
SHA256 09784c4b27e3ce7a69a6ed2847b4f237e13cde3cc0cb2a671634812ea668fcbe
MD5 92cab19dc17b8ec5fc9e181c5c8dd68d
BLAKE2b-256 4a876ca489163d24742ef9ceb7627b897b52a507292b4d5a91508fc39b8666cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_mergeguard-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: py_mergeguard-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 157.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cb92556329539be436e77e694cf055d8aaadc2ab17f1c123fd0cd7b7865e870
MD5 1905572689fe0b423bd4cc13e438bec1
BLAKE2b-256 98661e67cdd2a8952edbc49cfcd324ffc4d1c08072e72d973843713fdf6fb2fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_mergeguard-1.0.0-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