git-pr-brief/README.md
caelum0x 753fe98687 feat: git-pr-brief 1.0.0, cross-host agent-shaped PR/MR risk brief
Published to npm (git-pr-brief@1.0.0). Fetches a PR/MR's raw diff over
plain HTTPS (GitHub, GitLab, Rithub/Gitea, Bitbucket, or a raw .diff URL)
and computes offline risk flags (lockfile, env, migration, CI config,
large diff, missing tests, possible secrets) an agent can branch on via
--json / --fail-on-flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 21:04:45 +03:00

3.9 KiB

git-pr-brief

A structured risk brief for a pull request or merge request, from one URL. Built for agents reviewing code, not just humans: pass --json and get one object your agent can branch on, instead of a diff it has to re-read and re-reason over every single time.

npx git-pr-brief https://github.com/facebook/react/pull/12345

That fetches the raw diff over plain HTTPS (no clone, no API key needed for public PRs/MRs) and prints file counts, line counts, and a list of risk flags — lockfile changes, .env files touched, DB migrations, CI config changes, source changed with no matching test change, and lines that look like a hardcoded secret.

Works across hosts

One tool, same output shape, whichever host the PR/MR lives on:

npx git-pr-brief https://github.com/owner/repo/pull/123
npx git-pr-brief https://rithub.dev/owner/repo/pulls/7
npx git-pr-brief https://gitlab.com/group/project/-/merge_requests/9
npx git-pr-brief https://bitbucket.org/workspace/repo/pull-requests/4
npx git-pr-brief https://example.com/some/raw/already.diff

Rithub and any other Gitea/Forgejo-based host work automatically — Gitea exposes the same .diff suffix pattern GitHub does, so no host-specific flag is needed.

Agent-shaped output

npx git-pr-brief https://github.com/owner/repo/pull/123 --json
{
  "label": "owner/repo#123 (GitHub)",
  "files": 14,
  "additions": 812,
  "deletions": 40,
  "risk": {
    "flagCount": 2,
    "flags": [
      { "code": "LOCKFILE_CHANGED", "label": "lockfile changed", "files": ["package-lock.json"] },
      { "code": "NO_TESTS_WITH_SOURCE", "label": "source changed, no tests touched" }
    ]
  }
}

Use --fail-on-flag to get a non-zero exit code whenever any flag fires — useful as the gate step before an agent decides to look closer, request changes, or hand a PR to a human.

Risk flags

All computed offline from the diff text itself — no AI call, no extra network request beyond the one diff fetch, deterministic and free to run on every PR:

  • LOCKFILE_CHANGED — a package-lock.json/yarn.lock/Cargo.lock/etc. changed
  • ENV_FILE_CHANGED — a .env file was touched
  • MIGRATION_CHANGED — a DB migration or schema file changed
  • CI_CONFIG_CHANGED — .github/workflows, .gitlab-ci.yml, etc. changed
  • LARGE_DIFF — more than 500 lines changed (configurable via --large-diff)
  • MANY_FILES — more than 30 files touched (configurable via --many-files)
  • NO_TESTS_WITH_SOURCE — source files changed, no test files in the same diff
  • POSSIBLE_SECRET — an added line matches a hardcoded-secret shape (API key, private key block, password assignment, etc.) — expect false positives, this is a "look here" flag, not a verdict

Private repos

npx git-pr-brief https://github.com/myorg/myrepo/pull/5 --token $GITHUB_TOKEN

Works on hosts whose raw-diff endpoint accepts a bearer token for private repos (GitHub, Gitea/Rithub). PR_BRIEF_TOKEN env var works the same as the flag.

No signup, no telemetry

Runs entirely from your machine (or your agent's sandbox) to the host's own diff endpoint. No account, no API key for public PRs, nothing phoned home.

Why this exists

Reviewing a PR/MR by hand means re-reading the whole diff every time to notice the same handful of things: did the lockfile move, is there a migration in here, did someone touch .env, did the tests actually change with the code. That's a deterministic, offline check — this tool runs it in one command so an agent (or a human) can skip straight to the files that actually need judgment.

Companion to git-year-wrapped and github-backup-cli, same house style: one free standalone CLI, no signup, works across hosts.

Hosted on Rithub — the git host built for agent-called, cross-host tooling like this one.

License

MIT