Measure pull request size from git numstat or a diff, skipping lock and generated files, and plan how to split big changes into reviewable slices. Use when the user asks if a PR is too big, wants a size check, or asks to split a PR.
97%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Counts reviewable lines (added plus deleted, non-binary, not on the ignore list), classifies the
change as ok, warn or fail, and proposes directory-based slices that each fit under a line limit.
Python 3.10+, nothing to install, no git or network access from the script.
Produce the diff against the target branch and pipe it in (the script does not run git):
git diff --numstat origin/main...HEAD | python3 scripts/pr_size.py --numstat - --suggest
git diff origin/main...HEAD > change.diff && python3 scripts/pr_size.py --diff change.diffUse the same base the PR will use. --numstat is exact and fastest; --diff works when only a patch is available.
Read the status line, for example status: warn (512 lines counted, 2000 ignored).
Defaults: ok up to 400 counted lines, warn up to 1000, fail above.
If it is warn or fail, use --suggest and read references/splitting.md to turn the slices into
a sequence of smaller PRs. Slices marked oversized are one directory group that is already above the limit by itself:
re-run with --depth 2 to split it by sub-directory.
Tune the team policy with options, not by editing code:
python3 scripts/pr_size.py --numstat stat.txt --warn 300 --fail 800 --limit 300 --depth 2 --suggestRe-measure after splitting each part.
| Code | Meaning |
|---|---|
| 0 | ok or warn |
| 1 | fail |
| 2 | Usage error, unreadable file, malformed numstat line, invalid option or pattern |
- in numstat, Binary files ... differ in a diff) count 0.old => new, pre/{old => new}/post) are counted at the new path.package-lock.json, pnpm-lock.yaml, yarn.lock, poetry.lock, uv.lock, Cargo.lock,
go.sum, *.min.js, *.snap, vendor/**, dist/**, node_modules/**, __snapshots__/**.--ignore PATTERN (repeatable) replaces the list. A pattern is either a file-name glob without /
(matched on the base name) or dirname/** (any path segment equal to dirname). Other shapes are rejected.More detail on options, limits and edge cases: references/usage.md.
State the counted lines, ignored lines, status and thresholds used, and whether a split is recommended. Say which files were ignored by pattern so the number is not mistaken for the full diff size.