Skip to main content

marginal

The Open Source Engineering Intelligence Agent for Pull Requests

marginal reviews pull requests the way a senior engineer who knows your whole codebase would — not just the diff. It reasons over your code graph, git history, engineering policies, ownership, and cross-repository impact to produce high-confidence, actionable feedback, and it runs entirely on infrastructure you control.

License GitHub stars PRs Welcome

Specification · Configuration · Roadmap · Contributing


Why marginal

Diff-only review tools comment on what changed without understanding what it touches. They miss the breaking change in a shared library three repos away, the architecture rule a new handler quietly violates, the technical debt a PR is about to make worse. And most of them require sending your source code to someone else's inference service.

marginal is built around a different bet: context beats volume. One well-evidenced finding that traces a regression to its root cause is worth more than ten shallow comments — and a reviewer that runs on your own infrastructure, with your own model keys, is one you can actually trust with your whole codebase.

How it works

                    GitHub
                      |
               GitHub Actions
                      |
                      v
              +---------------+
              |   marginal    |
              |     Agent     |
              +-------+-------+
                      |
        +-------------+-------------+
        |             |             |
        v             v             v
   Code Graph     Policy Engine   Git Context
        |             |             |
        +-------------+-------------+
                      |
                Agent / Planner
                      |
             +--------+--------+
             |                 |
             v                 v
        Model Provider     Validation
        (BYOK)             / Deduplication
             |                 |
             +--------+--------+
                      |
                      v
                 GitHub PR

The agent inspects the PR, walks the code graph, checks it against your policies and ownership rules, and pulls in git history and dependency context — then validates, deduplicates, and ranks every candidate finding before anything reaches GitHub. Nothing ships to a comment unless it clears your confidence threshold.

What it reviews for

  • Context over diff — changed code is understood in terms of callers, callees, interfaces, tests, and the repositories that depend on it, not in isolation.
  • Breaking changes — signature changes, removed fields, schema changes, and incompatible library updates, flagged with the affected consumers as evidence.
  • Dependency intelligence — when a PR bumps a dependency, marginal correlates the upstream changelog against how your code actually uses it, and only speaks up when something you rely on actually changed.
  • Architecture & policy drift — deviations from the rules your team has written down in .marginal/policies/, evaluated against real repository relationships, not vibes.
  • Ownership & technical debt — findings are connected to CODEOWNERS and known debt items, without pinging anyone unless you've explicitly enabled it.

Quickstart

marginal init
✓ Created .marginal/config.yaml
✓ Created .marginal/policies/
✓ Created .marginal/policies/README.md
✓ Created .github/workflows/marginal.yml

marginal is ready.

Next steps -- pick one provider:

  1. In .marginal/config.yaml, set the reviewer model:

       models:
         reviewer:
           provider: anthropic    # or: openai
           model: <model id>

  2. Add that provider's API key as a repository secret:

       gh secret set ANTHROPIC_API_KEY    # provider: anthropic
       gh secret set OPENAI_API_KEY       # provider: openai

The workflow already passes both secrets, so nothing else needs editing.
Open a pull request to get your first review.
# .github/workflows/marginal.yml
name: marginal

on:
  pull_request:

# One review per PR at a time: two runs started by quick successive pushes
# would each miss the other's review and post the same header twice.
concurrency:
  group: marginal-${{ github.event.pull_request.number }}
  cancel-in-progress: false

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: exactml/marginal-action@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          # Only the key for the provider in .marginal/config.yaml is used;
          # the other secret can stay unset.
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
          openai-api-key: ${{ secrets.OPENAI_API_KEY }}

Open a PR, and marginal builds context, reasons over the change, and posts inline comments plus a summary — all inside your own GitHub Actions run.

Check your setup

marginal doctor checks everything a review needs, without calling a model or posting anything: that .marginal/config.yaml is valid, that models.reviewer is set and each configured provider's API key is in the environment, that permissions let marginal review read the PR, and that GITHUB_TOKEN is set. If permissions.write.comments is off it prints a note rather than a failure, since --comment is only needed to post. With --repo, it also makes one read-only GitHub call to confirm the token is accepted and the repository is reachable.

marginal doctor --repo owner/name
✓ .marginal/config.yaml is valid
✗ models.reviewer: the 'anthropic' provider requires the ANTHROPIC_API_KEY environment variable to be set
    → export it in your shell, and add it as a repository secret for CI
✓ permissions allow `marginal review --comment`
✓ GITHUB_TOKEN is set
✓ GitHub accepted GITHUB_TOKEN and owner/name is reachable

1 check(s) failed.

It exits 0 when every check passes and 1 when any fails, so it also works as a CI step.

marginal is under active, in-the-open development — this is the interface it's being built toward. Follow docs/REQUIREMENTS.md for current scope, or jump into Issues to help build it.

Configuration

Everything lives in your repository, version-controlled alongside your code:

.marginal/
├── config.yaml
├── policies/
│   ├── README.md
│   ├── security.md
│   ├── testing.md
│   ├── architecture.md
│   └── ...
└── ...
version: 1

review:
  enabled: true
  inline_comments: true
  confidence_threshold: 0.85
  max_comments: 8
  max_prompt_tokens: 100000  # estimated; over this, the model is never called
  self_reflect: false  # true: a second model call re-checks findings before they're filtered
  tone: concise

context:
  git_history: true
  code_graph: true
  cross_repository: true

models:
  planner:
    provider: anthropic
    model: claude-sonnet
  reviewer:
    provider: openai
    model: codex

policies:        # rules the review checks the diff against
  - .marginal/policies/security.md
anti_policies:   # deliberate tradeoffs marginal must never flag
  - .marginal/anti-policies/accepted-tradeoffs.md

API keys are never stored in configuration — only in your CI secrets or environment. See the full specification for every option.

Local models (Ollama)

To keep every model call on your own machines, run the model with Ollama and point a role at it. No API key is needed:

models:
  reviewer:
    provider: ollama
    model: qwen2.5-coder:14b
    base_url: http://localhost:11434/v1  # the default; set it for a remote Ollama host

ollama talks to Ollama's OpenAI-compatible API, so any server exposing /v1/chat/completions with JSON-schema structured output (vLLM, for example) works the same way. Install it with pip install 'marginal-review[ollama]'. The machine running marginal must reach that URL, so in GitHub Actions that usually means a self-hosted runner on the same network.

Run it anywhere

The same core agent runs as:

  • GitHub Actions — the primary integration, zero infrastructure to operate
  • Docker — one image, the full runtime
  • CLI — marginal review for local runs
  • Self-hosted runners — for orgs that need everything on their own network

No step requires code to leave your infrastructure, and no step requires a marginal-hosted service.

Roadmap

marginal is being built in three horizons:

Repository Intelligence  →  Organization Intelligence  →  Engineering Intelligence

Today's focus is getting the core loop right on a single repository: diff and repository context, code graph, policies, and high-signal inline review. From there: cross-repository impact analysis, architecture drift detection, an evaluation framework for benchmarking review quality across models, and a local UI for visibility into everything the agent does. The long-term goal is an agent that can answer not just "is this code correct?" but "does this PR actually satisfy the requirement it was written for?"

See docs/REQUIREMENTS.md for the full specification driving this.

Contributing

marginal is being designed in the open, and there's no ship deadline forcing shortcuts — it's built to grow with contributors, not around a single team's timeline. Design discussion, issues, and PRs against both the code and the specification are welcome. A good place to start is docs/REQUIREMENTS.md.

License

MIT

Metadata

Release files for marginal-review 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marginal-review 0.2.8
File Size Uploaded Provenance Actions
marginal_review-0.2.8.tar.gz 84.8 kB With provenance Details for marginal_review-0.2.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for marginal-review 0.2.8
File Interpreter ABI Platform Actions
marginal_review-0.2.8-py3-none-any.whl Python 3 none any Details for marginal_review-0.2.8-py3-none-any.whl

Total release size: 143.6 kB

Release files / marginal_review-0.2.8.tar.gz

Download URL marginal_review-0.2.8.tar.gz
Size 84.8 kB
Tags Source
SHA-256 checksum
How to use checksums
20004707d4ea5941881d05eebc0e1d43955df84175e2b8f66f409bf3fc554389
BLAKE2b-256 checksum
How to use checksums
011a09a3f19883fb0e6e74588f62179298bd9b4c39352d1509dde6fe3a3577c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / marginal_review-0.2.8-py3-none-any.whl

Download URL marginal_review-0.2.8-py3-none-any.whl
Size 58.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b75b7ef21ef3ea3923993aaeb02aae733a9883d765e99c629d95f3c52992c16
BLAKE2b-256 checksum
How to use checksums
c32e694b7c6b68831c1270ded7792309caf4c1fe6932b579a7e4d9d1944c87ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for marginal-review 0.2.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for marginal_review-0.2.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page