# Analyzing pull request batch size

There are several ways of measuring the complexity of pull requests. Analyzing the amount of changes, or the absolute size of the diff, is the most common and robust way to do this.

While there are circumstances where very large pull requests are valid, it's recommended to break down the work into smaller increments.

The main benefit of doing so is an improved flow of work. This tends to happen because the team is changing things in smaller increments, which are quicker to author and also easier to review. Reviews can be more thorough when there are fewer changes to analyze at one go, and this adds up to an increase in the quality of the code base. Furthermore, smaller changes help get the reviews more quickly than, say, for a 500+ line monster, which might be demoralizing to even start looking at.

## Reducing the number of large pull requests

There's no absolute limit to a large pull request, but what matters most is the typical batch size. We recommend keeping close attention on the number of PRs with more than 200 lines of changes.

The pull request [Batch Size Insights](https://app.swarmia.com/insights/code/batch-size) provide visibility to the typical batch size and the batch size distribution. Teams can see how many large PRs are going through the system, and analyze these more closely.

By interacting with the distribution, you can analyze a section or sections in the distribution. Doing this filters both the scatter plot and the table containing detailed pull request information to the selected bucket(s).

<figure><img src="https://2772466312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMa8uBmGhQgR7MTPq9yh7%2Fuploads%2Fgit-blob-43accab450cb6dcd3fb5846e0ab1c450febe20e6%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

We recommend looking for patterns or similarities to help analyze what's driving a trend for a large batch size or significantly lower cycle time. You may find that certain themes of work, some repositories, or specific features often result in bigger batches or changes that take significantly more time and effort.

See also: [Diagnosing low pull request throughput](https://help.swarmia.com/guides/improve-pull-request-flow/diagnosing-low-pull-request-throughput)

## Excluding auto-generated files

It's important to focus on only the actual changes when analyzing pull requests. However, repositories often contain generated files, which could be related to e.g. package dependencies.

In order to provide an accurate view of the real changes, [Swarmia automatically cleans up the total change count of some commonly used generated files](https://help.swarmia.com/definitions/batch-size).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.swarmia.com/guides/improve-pull-request-flow/analyzing-pull-request-batch-size.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
