Examples & Use Cases
PR Size Limits Example
Enforce manageable PR sizes with automatic labeling and feedback
This example shows how to enforce size limits on pull requests and provide helpful feedback to contributors, encouraging smaller, more focused changes.
Configuration
How It Works
This ruleset:
- Triggers when a PR is opened or synchronized (new commits pushed)
- Validates that the PR doesn’t exceed size limits:
- Maximum 10 files changed
- Maximum 500 total lines changed
- Maximum 400 lines added
- Maximum 200 lines deleted
- When the PR is too large:
- Adds a “large-pr” label
- Comments with guidance on how to address the issue
Extending the Example
Ignore Certain Files
Exclude files that often change in bulk but don’t require careful review:
Size-Based Labeling
Automatically label PRs based on their size:
Different Limits by Branch
Set stricter limits for important branches:
Strategies for Managing Large PRs
Include helpful advice in your feedback:
Implementation Tips
- Start with generous limits: Begin with larger limits and gradually reduce them
- Educate your team: Explain the benefits of smaller PRs
- Lead by example: Have maintainers model good PR practices
- Make exceptions when needed: Some valid changes (like major refactoring) might need to be larger
- Set up your workflow: Use branch protection rules alongside Rulesets
Benefits
- Higher quality code: Smaller PRs get more thorough reviews
- Faster cycle time: PRs move through the review process more quickly
- Better collaboration: Reviewers are more willing to review smaller changes
- Lower cognitive load: Reviewers can focus on one concern at a time
- Smoother integration: Smaller changes integrate more easily with the codebase