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
In this repository50 other files it gives its agents.
- algolia-searchSkill
- audit-tautological-testsSkill
- blame-archaeologySkill
- brevo-emailSkill
- bun-runtimeSkill
- clerk-authSkill
- cloudflare-workersSkill
- dbt-data-modelingSkill
- explain-this-diffSkill
- extract-skill-from-sessionSkill
- fastapi-productionSkill
- find-dead-codeSkill
- find-real-bugSkill
- gdpr-dpiaSkill
- github-actions-ciSkill
- graphql-relaySkill
- grpc-servicesSkill
- hipaa-auditSkill
- india-dpdp-actSkill
- java-8-to-21Skill
- jest-to-vitestSkill
- kubernetes-helmSkill
- mongo-to-postgresSkill
- nextjs-pages-to-appSkill
- node-version-upgradeSkill
- opentelemetry-instrumentSkill
- pci-dss-checklistSkill
- plan-the-rollbackSkill
- python-2-to-3Skill
- razorpay-integrationSkill
- react-native-expoSkill
- scaffold-cli-toolSkill
- scaffold-fullstack-appSkill
- scaffold-go-microserviceSkill
- scaffold-new-appSkill
- scaffold-saas-starterSkill
- sentry-monitoringSkill
- soc2-evidenceSkill
- spec-from-conversationSkill
- stripe-integrationSkill
- supabase-backendSkill
- terraform-patternsSkill
- threat-modeling-strideSkill
- triage-stack-traceSkill
- wcag-accessibility-auditSkill
- webpack-to-viteSkill
- write-adrSkill
- write-commit-messageSkill
- write-pr-descriptionSkill
- write-runbookSkill
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
- Distinctive: line 35
Group small categories: if they truly co-depend; split aggressively otherwise.
- Distinctive: line 49
If the feature genuinely needs 1000 lines of code, split *the feature itself* into milestones (skeleton → endpoint A → endpoint B → glue UI …
- Very specific: line 58
Schema: add invitations table with migration (~80 LOC).
- Distinctive: line 102
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 …
≈ “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.
Files
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
- 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.
- Order them by dependency. Refactor before feature; feature before tests of feature; config before code that needs config.
- Group small categories if they truly co-depend; split aggressively otherwise.
- Each chunk must merge independently. "Won't compile without #2" means the split is wrong.
- 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 type | Lines (excluding generated) | Reviewer time |
| Mechanical refactor | up to ~800 | 5–10 min |
| Pure feature | up to ~300 | 15–30 min |
| Schema migration | as small as possible | varies |
| Bug fix | up to ~100 | 5 min |
| Config / dependency bump | as small as possible | 5 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:
- Refactor: extract
email/templates.tsregistry from inline strings (~200 LOC, no behavior change). Reviewable as a pure refactor. - Schema: add
invitationstable with migration (~80 LOC). Independent — table can exist with no consumers. - API skeleton:
POST /invitations,GET /invitations/:token,POST /invitations/:token/accept, returning 501 not-implemented for now (~150 LOC). Routing wired but logic stubbed. - Email integration: implement
sendInvitationEmailusing the registry from #1 (~120 LOC + tests). - Accept flow: implement
POST /invitations/:token/acceptend-to-end (~250 LOC + tests). - UI: invitation form + accept page (~400 LOC).
- Webhook events: emit
invitation.createdandinvitation.acceptedto 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
# ... etcStack 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 thiscomments 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.
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
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.

