agentleFS
MaheshAwasareMaheshAwasare/claude-skills-pro/skills/shrink-this-pr/SKILL.md

shrink-this-pr

Skill1 starsChanged 7 months agoMITView on GitHub

Take a PR that's grown too large to review and split it into mergeable, ordered chunks with a dependency graph. Use when you (or someone else) opens a PR with >500 lines, mixes refactoring with features, or touches >10 files for one logical change.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Group small categories: if they truly co-depend; split aggressively otherwise.

    line 35
  2. Distinctive:

    If the feature genuinely needs 1000 lines of code, split *the feature itself* into milestones (skeleton → endpoint A → endpoint B → glue UI …

    line 49
  3. Very specific:

    Schema: add invitations table with migration (~80 LOC).

    line 58
  4. Distinctive:

    If you genuinely cannot split, write the PR description so a reviewer can read it in chunks: a "Read this in order" guide pointing to …

    line 102

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Shrink This PR

PRs over ~400 lines get rubber-stamped or stalled. Both outcomes are bad. This skill is the algorithm for splitting a fat PR into a stack of small, reviewable, mergeable PRs.

When to use

  • PR is >500 lines (excluding lockfiles, generated code).
  • PR mixes mechanical refactor with new feature work.
  • PR touches >10 files for one logical change.
  • Reviewer says "I can't review this" or "lgtm" without comments (the latter is worse).
  • You're about to open a PR like this — better to split before review than after.

When NOT to use

  • Changes are atomic (one schema migration + the matching code change).
  • Time-critical hotfix where review-friendliness is secondary.
  • Generated/scripted refactor of 1000 files (mass rename) — single PR is fine.

The split algorithm

  1. List the categories of change in the diff. Typical categories:
    • Mechanical refactor (rename, move, extract).
    • Type/lint cleanup.
    • Dead code removal.
    • New behavior (the feature).
    • Tests for the new behavior.
    • Config/infra changes.
    • Documentation.
  2. Order them by dependency. Refactor before feature; feature before tests of feature; config before code that needs config.
  3. Group small categories if they truly co-depend; split aggressively otherwise.
  4. Each chunk must merge independently. "Won't compile without #2" means the split is wrong.
  5. Each chunk must be a real improvement on its own. "Just refactor — no behavior change" PRs are easy to review and uncontroversial.

Target sizes

PR typeLines (excluding generated)Reviewer time
Mechanical refactorup to ~8005–10 min
Pure featureup to ~30015–30 min
Schema migrationas small as possiblevaries
Bug fixup to ~1005 min
Config / dependency bumpas small as possible5 min

If the feature genuinely needs 1000 lines of code, split the feature itself into milestones (skeleton → endpoint A → endpoint B → glue UI → polish).

Concrete example

Original PR (1400 lines): "Add team invitations."

Split into:

  1. Refactor: extract email/templates.ts registry from inline strings (~200 LOC, no behavior change). Reviewable as a pure refactor.
  2. Schema: add invitations table with migration (~80 LOC). Independent — table can exist with no consumers.
  3. API skeleton: POST /invitations, GET /invitations/:token, POST /invitations/:token/accept, returning 501 not-implemented for now (~150 LOC). Routing wired but logic stubbed.
  4. Email integration: implement sendInvitationEmail using the registry from #1 (~120 LOC + tests).
  5. Accept flow: implement POST /invitations/:token/accept end-to-end (~250 LOC + tests).
  6. UI: invitation form + accept page (~400 LOC).
  7. Webhook events: emit invitation.created and invitation.accepted to your event stream (~100 LOC).

Six small PRs replace one big one. Each merges independently. Production stays in a known-good state if PR #5 is delayed.

How to actually do the split

# Start from your big branch
git checkout big-feature
git checkout -b split/01-refactor

# Cherry-pick or restage just the refactor parts
git reset --soft main                       # everything becomes uncommitted
git add -p                                  # interactively pick refactor hunks
git checkout -- .                           # reset everything else
git commit -m "refactor: extract email templates registry"

# Open PR for #01
gh pr create

# Now branch from #01 for #02
git checkout -b split/02-schema split/01-refactor
git checkout big-feature -- migrations/*.sql packages/db/schema.ts
git commit -m "feat: add invitations table"
gh pr create --base split/01-refactor

# ... etc

Stack the PRs (each based on the previous). Tools like gh stack or Graphite make this easier.

When the work is intertwined

Sometimes a "refactor + feature" really is mechanically inseparable. Test:

  • Can the refactor be merged with // TODO: use this comments and the feature follow later? If yes, split.
  • Does the refactor change behavior? If yes, it's not a refactor — it's a feature with cleanup.
  • Is the "refactor" actually 50 line moves + 5 logic tweaks? Pull out the moves first; the 5 tweaks become a clean feature PR.

If you genuinely cannot split, write the PR description so a reviewer can read it in chunks: a "Read this in order" guide pointing to specific files.

Anti-patterns

  • Splitting after the giant PR is up — political cost. Try to split before opening.
  • PR that "won't compile until #2 lands" — the split is wrong. Stub or feature-flag.
  • Splitting by file — one PR per file makes 50 PRs nobody reads. Split by concept, not by location.
  • A "tests" PR after the feature PR — code without tests shouldn't merge. Tests in the same PR as the feature.
  • Force-push history rewrites mid-review — review comments orphan. Open a follow-up PR instead.
  • Mixing dependency upgrades with feature work — bump deps in their own PR; isolate the variable.
  • "It's actually fine, just review it" — reviewer fatigue ships bugs. Respect the reviewer's time.
  • A 1000-line "refactor" that also "happens to fix bug X" — the bug fix needs its own PR with a test; reviewers can't audit refactors and behavior changes simultaneously.

Verify it worked

  • Each PR is < 400 lines (excluding generated/lockfiles).
  • Each PR has a clear, independent purpose stated in the description.
  • Each PR merges cleanly — no "depends on PR X" beyond the immediate parent in a stack.
  • Each PR is valuable on its own (a refactor that improves the code without the feature is still valuable).
  • Tests live with the code that needs them, not in a separate "tests PR."
  • Production stays in a known-good state at every merge — no half-feature in main.
  • PR descriptions explain how the chunks compose ("part 3/7 of team-invites").
  • Reviewer can review each PR in < 30 min.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.