GitHub CLI Commands for Pull Request
Pull Requests (PRs) are a fundamental part of collaborative software development on GitHub. They allow developers to propose changes to a codebase, review code, and discuss modifications before merging them into the main branch. Analyzing PRs can provide valuable insights into the development process, code quality, and team collaboration. In this section, we will explore the CLI commands available for fetching and analyzing Pull Requests from GitHub repositories. This is a must step in order to analyze PRs data using the CLI or the dashboard.
Fetch PRs
Fetching PR data from GitHub is the first step before performing any analysis. The CLI provide comments to fetch PRs from a specified repository from GitHub.
smm prs fetch| Option | Description | Example |
|---|---|---|
| Months | It defaults to 1. It is used if no start or end date is given | --months=2 |
| Start date | Fetches PRs created after a date. | --start-date=2025-01-01 |
| End date | Fetches PRs created before a date. | --end-date=2025-12-31 |
| Filters | Allows to pass in filters directly to the GitHub API | --raw-filters=state=open |
| Force | By default a file is stored with the retrieved data to avoid refetching it again. However, using this parameter bypass this cache. | --force=true |
Filtering the data fetch from PRs by date is done logically while fetching the data, this is not a feature that GitHub API provides.
Examples - Fetch PRs
Fetching PRs from the last 3 months:
smm prs fetch --months=3Fetching PRs created between January 1, 2025, and June 30, 2025:
smm prs fetch --start-date=2025-01-01 --end-date=2025-06-30Fetching only open PRs:
smm prs fetch --raw-filters=state=open,head=mainForcing the fetch to ignore already fetched PRs (this overrides the data stored):
smm prs fetch --force=trueFetch PRs comments
Pull requests often have comments that provide insights into the review process. However, in order to fetch comments for Pull Request, you must first fetch the PRs using the smm prs fetch command. The comments are not fetched by default to optimize the data retrieval process as GitHub API has rate limits. Before fetching the comments, it first uses the PRs data already fetched to get the comments for each PR using the property review_comments_url from each PR.
smm prs fetch-comments| Option | Description | Example |
|---|---|---|
| Start date | The PRs created date to filter after this date, this is the PR not the comment pr itself. | --start-date=2025-01-01 |
| End date | The PRs created date to filter before this date, this is the PR not the comment pr itself. | --end-date=2025-12-31 |
| Filters | Allows to pass in filters directly to the GitHub API. It will pass the filters for each PR request. | --raw-filters=sort=created |
| Force | By default a file is stored with the retrieved data to avoid refetching it again. However, using this parameter bypass this cache. | --force=true |
Examples - Fetch PRs comments
Fetching comments for PRs created between January 1, 2025, and June 30, 2025:
smm prs fetch-comments --start-date=2025-01-01 --end-date=2025-06-30Forcing the fetch to ignore already fetched comments (this overrides the data stored):
smm prs fetch-comments --force=trueData quality
Once data is fetched, you might want to check the quality of it and if the data matches the expected values. To achieve that, SMM has a summary command that shows basic information about the quality of the data. Such as:
It will print a summary of the PRs fetched, including:
- Total PRs (total_prs): The total number of pull requests.
- First PR (first_pr): Details of the first pull request.
- Last PR (last_pr): Details of the last pull request.
- Merged PRs (merged_prs): The number of pull requests that were merged.
- Closed PRs (closed_prs): The number of pull requests that were closed but not merged.
- PRs Without Conclusion (without_conclusion): The number of pull requests that are neither closed nor merged.
- Unique Authors (unique_authors): The number of unique authors who created pull requests.
- Unique Labels (unique_labels): The number of unique labels used across pull requests.
- Labels (labels): A list of all unique labels used in pull requests.
The command to get the summary is:
smm prs summary