Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

pr-stats

Daily accountability for your GitHub PR habits. Reports, for a trailing window (default 7 days):

  • PRs you opened
  • PRs you authored that were closed (merged or otherwise)
  • PR reviews you submitted

and fires a desktop notification (and exits non-zero) when either target is missed:

  • Review pull-weight — reviews >= RATIO × opened (default RATIO=1.5). Roughly: every PR you open consumes ~1.2 reviews from teammates, so 1.5 keeps you a net contributor of review attention.
  • Backlog drain — closed - opened >= DROP × days (default DROP=0, i.e. don't let your open-PR count grow; set DROP=1 to wind a backlog down by one PR a day).
GitHub PR activity for octocat — last 7 days (since 2026-07-02T09:00:00Z)

  PRs opened          12
  PRs closed          18   (merged or otherwise)
  Reviews submitted   14
  Net open-PR change  -6   (opened - closed)

  🧐 Review 4 PRs — Reviewed 14, want 18.0 (1.5× 12 opened) over 7d
  ✅ Backlog on target — Net -6 open over 7d, target <= 0 (close 0/day)

Requirements

  • gh installed and authenticated (gh auth login) — all API access goes through your own gh credentials; nothing else is stored
  • Python 3.9+ (stock macOS python3 is fine); the script itself is stdlib-only, no pip installs
  • macOS for the scheduled runs and notifications (terminal-notifier optional, for nicer banners); the CLI itself works anywhere

Install

git clone https://github.com/brandonrule11/pr-stats ~/src/pr-stats
~/src/pr-stats/bin/pr-stats-install-agent

The installer writes a LaunchAgent plist to ~/Library/LaunchAgents/ that runs pr-stats weekdays at 09:00 (HOUR=8 MINUTE=30 bin/pr-stats-install-agent to change), logging to ~/.local/state/pr-stats.log. Runs missed while the Mac is asleep are caught up on wake — a wrapper script waits until the network is genuinely back before querying GitHub. Update with git pull; uninstall with the launchctl bootout line the installer prints.

For ad-hoc use, just put bin/pr-stats on your PATH.

Usage

pr-stats                       # last 7 days, you
pr-stats 14                    # last 14 days
pr-stats 30 octocat            # last 30 days for a specific user
pr-stats -r 2.0 -d 1 30        # RATIO=2.0, drain 1 PR/day, 30 days

Defaults for ratio/drop/days/user live in ~/.config/pr-stats.ini, created with commented defaults on first run. CLI flags override the config per run.

Exit codes: 0 all targets met, 1 a target missed, 2 the run aborted (GitHub unreachable after retries — pr-stats fails loudly rather than reporting numbers built from partial data).

How reviews are counted

Reviews are counted from each PR's GraphQL timeline (itemTypes: PULL_REQUEST_REVIEW) rather than the REST /reviews list, because REST returns one review object per reply posted in an existing thread — which never renders as its own review in the UI. The timeline matches what GitHub itself displays as "a review". Self-reviews on your own PRs are excluded.

License

MIT

About

Daily accountability for your GitHub PR habits

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages