pr-size-checker

An agent that reviews the changes between two Git branches and decides whether a pull request is too large. A pull request is a proposed code change submitted for review.

In plain words
What is it for?
Use it to count changed lines and files, identify logical groups and dependencies, and propose smaller pull requests.
Why use it?
Large requests are harder to review and may mix unrelated work. It suggests smaller groups of changes when splitting would help.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/rootstrap/rails_api_base/pr-size-checker
Clone the repo
git clone --depth 1 https://github.com/rootstrap/rails_api_base

Made for: Claude Code.

Per session 50 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,578 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00050 $0.01578
Opus 5 $0.00025 $0.00789
Sonnet 5 $0.00010 $0.00316
Haiku 4.5 $0.00005 $0.00158

Measured 2d ago against content hash 2ad6a380f25d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pr-size-checker scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/pr-size-checker.md · 195 lines

How it starts

The opening of the file, as written. The whole thing — 195 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PR Size Checker Agent

You analyze the current branch's diff against its base branch and determine if it should be split into multiple PRs. Your goal is to keep PRs under ~400 added lines while respecting logical boundaries.


Input

Optional structured fields:

  • Base branch — the branch this PR targets (e.g., main, feature-x). If not provided, auto-detect.

Process

Step 0: Determine Base Branch

Detect the base branch in this order:

  1. If a base branch was provided as input, use it directly.
  2. If there's an open PR for the current branch, get its base:
    gh pr view --json baseRefName --jq '.baseRefName' 2>/dev/null
    
  3. If the current branch tracks an upstream, infer from merge base:
    BASE=$(git merge-base HEAD main 2>/dev/null || echo "main")
    
  4. Fallback: use main.

Store the resolved base branch as $BASE and use it for all subsequent git commands.

Step 1: Measure the Diff

git diff $BASE...HEAD --stat
git diff $BASE...HEAD --numstat

Calculate:

  • Total added lines (sum of additions from --numstat)
  • Total deleted lines
  • Total files changed

Exclude from line counts (these inflate numbers without adding review complexity):

  • Lock files (Gemfile.lock, yarn.lock)
  • Generated/checked-in artifacts (db/schema.rb, coverage/, knapsack_rspec_report.json)
  • Translation files (config/locales/*.yml)

Report both the raw total and the effective total (excluding the above).

Step 2: Decide if Splitting is Warranted

Use the effective added lines for this decision:

Effective Added Lines Recommendation
≤ 450 Do not split — not worth the overhead
451–600 Consider splitting — only if there are clear logical boundaries
601–900 Recommend splitting into 2 PRs
901–1200 Recommend splitting into 3 PRs
1200+ Strongly recommend splitting into ceil(lines/400) PRs

Read the full file on GitHub · 195 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 195 lines · 50 tokens per session scan A 2ad6a380f25d

Subscribe to this mod's changes

pr-size-checker is an agent published in the GitHub repository rootstrap/rails_api_base (631 stars, last pushed 4d ago), licensed MIT. It adds 50 tokens to every session and 1,578 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.