Gh cli pr stats
Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-opus-4-6/github-repo-analytics/gh-cli-pr-stats
Computing pull request statistics (merge time, top contributors) from gh CLI JSON output using jq.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill gh-cli-pr-statsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.4 KB, 399 tokens by cl100k_base, as published. Nobody here has run it
PR Statistics from gh CLI Output
Fetching PR Data with Timestamps
gh pr list --repo owner/repo --state all \
--search "created:2024-12-01..2024-12-31" \
--limit 500 \
--json number,state,author,createdAt,mergedAt
The author field returns an object: {"login": "username"}.
The state field returns: OPEN, CLOSED, or MERGED.
Computing Average Merge Time with jq
# Filter merged PRs and compute average days to merge
echo "$pr_json" | jq '
[.[] | select(.state == "MERGED") |
{ created: (.createdAt | fromdateiso8601),
merged: (.mergedAt | fromdateiso8601) } |
(.merged - .created) / 86400
] | add / length
'
fromdateiso8601converts ISO 8601 strings to Unix epoch seconds.- Divide difference by 86400 to get days.
add / lengthcomputes the mean.
Finding Top Contributor
echo "$pr_json" | jq '
group_by(.author.login) |
map({login: .[0].author.login, count: length}) |
sort_by(-.count) |
.[0]
'
Counting by State
echo "$pr_json" | jq '{
total: length,
merged: [.[] | select(.state == "MERGED")] | length,
closed: [.[] | select(.state == "CLOSED")] | length
}'
Note: In gh CLI output, CLOSED and MERGED are distinct states. A merged PR has state MERGED, not CLOSED.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.