agentsclimarketplace

Run3 gh search prs precise

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-claude-opus-4-6/github-repo-analytics/run3_gh-search-prs-precise

How to accurately search for pull requests in a specific GitHub repository within a date range using the gh CLI, and correctly distinguish merged vs closed-without-merge PRs.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run3_gh-search-prs-precise

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

3.6 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it

Searching Pull Requests with gh CLI — Precise Filtering

Key Pitfalls

  1. gh search prs may return results from forks or related repos — always use --repo owner/repo flag explicitly.
  2. --state closed includes BOTH merged and closed-without-merge PRs — GitHub treats merged PRs as a subset of closed PRs.
  3. Date range filtering — use --created "2024-12-01..2024-12-31" to filter by creation date.
  4. Result limits — gh search prs defaults to 30 results. Use --limit 300 or higher to get all results (max ~1000).

Getting Total PRs Created in a Date Range

gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 --json number | jq length

This returns the count of all PRs created in the date range in the specified repo.

Getting All PR Details for Processing

gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 \
  --json number,author,state,createdAt,closedAt,mergedAt
  • mergedAt — if non-empty/non-null, the PR was merged. If empty/null, it was NOT merged.
  • state — will be open, closed, or merged in search results.

Counting Merged PRs (as of today)

From the JSON output, count entries where mergedAt is not empty/null:

gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 \
  --json mergedAt | jq '[.[] | select(.mergedAt != "" and .mergedAt != null)] | length'

Counting Closed-Without-Merge PRs (as of today)

These are PRs where state is not open AND mergedAt is empty/null. In other words: closed but NOT merged.

gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 \
  --json state,mergedAt | jq '[.[] | select(.state != "open" and (.mergedAt == "" or .mergedAt == null))] | length'

Important: The closed field in the report means "closed without merge", NOT all closed PRs.

Computing Average Time-to-Merge (in days)

For merged PRs, compute the difference between mergedAt and createdAt:

gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 \
  --json createdAt,mergedAt | jq '
  [.[] | select(.mergedAt != "" and .mergedAt != null) |
    (((.mergedAt | fromdateiso8601) - (.createdAt | fromdateiso8601)) / 86400)
  ] | if length > 0 then (add / length * 10 | round / 10) else 0 end'

This produces the average in days, rounded to 1 decimal place.

Identifying Top Contributor (Most PRs Opened)

gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 \
  --json author | jq '
  [.[] | .author.login] | group_by(.) | map({login: .[0], count: length}) |
  sort_by(-.count) | .[0].login'

Alternative Approach Using gh pr list

If gh search prs is giving unexpected results, try:

gh pr list --repo cli/cli --search "created:2024-12-01..2024-12-31" --state all --limit 300 \
  --json number,author,state,createdAt,closedAt,mergedAt

gh pr list is scoped to the exact repo and won't include forks.

Verifying Result Accuracy

Always verify that:

  1. All returned PRs have createdAt within the expected date range
  2. The repository field (if available) matches cli/cli
  3. The count seems reasonable (check against the GitHub web UI)
# Verify date range of results
gh search prs --repo cli/cli --created "2024-12-01..2024-12-31" --limit 300 \
  --json createdAt | jq '[.[] | .createdAt] | sort | [first, last]'

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.