Skip to main content

Cross-PR intelligence for the agentic coding era

Project description

MergeGuard

PyPI version License: MIT

Cross-PR intelligence for the agentic coding era.

MergeGuard detects conflicts between open pull requests before they become merge headaches. It analyzes overlapping code changes across PRs using AST-level understanding, computes risk scores, and integrates seamlessly as a GitHub Action or CLI tool.

Why MergeGuard?

As AI coding agents (Cursor, Copilot, Devin, Claude Code) generate more PRs in parallel, the likelihood of cross-PR conflicts increases dramatically. Traditional CI only checks a single PR against the base branch — it can't see that two PRs are about to break each other.

MergeGuard fills this gap by:

  • Detecting hard conflicts — two PRs modify the same function body
  • Catching interface conflicts — one PR changes a function signature while another PR calls it
  • Identifying behavioral conflicts — incompatible logic changes in the same module
  • Flagging duplications — two PRs implementing the same feature independently
  • Detecting regressions — a PR re-introduces something recently removed
  • Computing risk scores — composite scoring based on conflict severity, blast radius, code churn, and AI attribution

Quick Start

As a GitHub Action

# .github/workflows/mergeguard.yml
name: MergeGuard
on:
  pull_request:
    types: [opened, synchronize, reopened]

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

As a CLI

# Install from PyPI
pip install py-mergeguard

# Analyze a specific PR
mergeguard analyze --repo owner/repo --pr 42 --token $GITHUB_TOKEN

# Show collision map of all open PRs
mergeguard map --repo owner/repo --token $GITHUB_TOKEN

# Risk dashboard for all open PRs
mergeguard dashboard --repo owner/repo --token $GITHUB_TOKEN

How It Works

  1. Fetch — Retrieves all open PRs and their diffs from GitHub
  2. Parse — Uses Tree-sitter to build AST-level understanding of changed code
  3. Detect — Compares every pair of open PRs for overlapping changes
  4. Classify — Categorizes conflicts (hard, interface, behavioral, duplication, regression)
  5. Score — Computes a composite risk score (0-100) for each PR
  6. Report — Posts actionable comments on PRs or displays results in the terminal

Configuration

Create a .mergeguard.yml in your repository root:

risk_threshold: 50        # Only comment if risk score > 50
check_regressions: true   # Detect regressions against recent merges
max_open_prs: 30          # Performance limit
llm_enabled: false        # Optional AI-powered semantic analysis
ignored_paths:
  - "*.lock"
  - "package-lock.json"

See Configuration Guide for all options.

Documentation

Development

# Clone and setup
git clone https://github.com/Vansh2795/mergeguard.git
cd mergeguard
uv sync --dev

# Run tests
uv run pytest

# Lint
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-0.1.2.tar.gz (190.6 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-0.1.2-py3-none-any.whl (60.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_mergeguard-0.1.2.tar.gz
  • Upload date:
  • Size: 190.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for py_mergeguard-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b862e0cb8526e09eb4b9b8df7f2a2605993d352099423b5947dda1a893dfba47
MD5 85ad3fdce42f8995c69b20149ccc3bc8
BLAKE2b-256 04d008efceecfb6495473d2e1924fd097dce47eb85ff78980363445061e4cbb3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_mergeguard-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for py_mergeguard-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 29a84a0a04bc21d69b0d4a92fa4d5c632c4f4b898ebca714192b5282f9046af5
MD5 6bcf1c390c0d98a9bcfdd157f6f4d8f2
BLAKE2b-256 a81b3f0c31287f052c9838dc178e20ee62f50738674f6311f8b52a3405dd186b

See more details on using hashes here.

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