CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/pr-size-guard

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.

Quality

97%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

SKILL.md

name:
pr-size-guard
description:
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.

pr-size-guard

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.

When to use

  • The user asks "is this PR too big?", wants a size gate, or a reviewable-size target.
  • A branch has grown and needs to be split before review.
  • You are about to open a PR and want to state its size honestly.

Workflow

  1. 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.diff

    Use the same base the PR will use. --numstat is exact and fastest; --diff works when only a patch is available.

  2. 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.

  3. 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.

  4. 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 --suggest
  5. Re-measure after splitting each part.

Exit codes

CodeMeaning
0ok or warn
1fail
2Usage error, unreadable file, malformed numstat line, invalid option or pattern

What counts

  • Lines = added + deleted per file. Binary files (- in numstat, Binary files ... differ in a diff) count 0.
  • Renames (old => new, pre/{old => new}/post) are counted at the new path.
  • Default ignore list: 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.

Reporting

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.

SKILL.md

tile.json