github-pr-stats
- Repo stars 0
- Author repo skills-registry
GitHub PR Statistics
Overview
After fetching PR data from the GitHub API, use Python or jq to compute:
- Total PR count
- Merged vs closed counts
- Average time-to-merge (days)
- Top contributor by PR count
Fetching PRs for a Date Range
# Using gh search (handles pagination, date filtering)
gh pr list -R cli/cli \
--search "created:2024-12-01..2024-12-31" \
--state all \
--limit 500 \
--json number,author,createdAt,mergedAt,closedAt,state
Python: Compute Stats from JSON
import json
from datetime import datetime, timezone
from collections import Counter
# Load PR data (from gh pr list --json output)
with open('prs.json') as f:
prs = json.load(f)
total = len(prs)
# Count merged vs closed-but-not-merged
merged = [pr for pr in prs if pr['mergedAt']]
closed = [pr for pr in prs if not pr['mergedAt'] and pr['state'] == 'CLOSED']
# Average time to merge (creation -> mergedAt), in days
def parse_dt(s):
return datetime.fromisoformat(s.replace('Z', '+00:00'))
merge_days = []
for pr in merged:
created = parse_dt(pr['createdAt'])
merged_at = parse_dt(pr['mergedAt'])
delta = (merged_at - created).total_seconds() / 86400
merge_days.append(delta)
avg_merge_days = round(sum(merge_days) / len(merge_days), 1) if merge_days else 0.0
# Top contributor
authors = Counter(pr['author']['login'] for pr in prs)
top_contributor = authors.most_common(1)[0][0]
print(json.dumps({
"total": total,
"merged": len(merged),
"closed": len(closed),
"avg_merge_days": avg_merge_days,
"top_contributor": top_contributor
}, indent=2))
Notes on State Values
gh pr list --jsonreturnsstateas"OPEN","CLOSED", or"MERGED"mergedAtis non-null only for merged PRs- A PR with
state == "CLOSED"andmergedAt == nullis truly closed (not merged)
Notes on the Search API
created:2024-12-01..2024-12-31is inclusive on both ends- Dec 31 means up to
2024-12-31T23:59:59Z - Use
--limit 500to avoid truncation for active repos
<!-- tomevault:4.0:skill_md:2026-05-22 -->Source: cxcscmu/SkillLearnBench — distributed by TomeVault.
- Fluxly category
- Data
- Author-declared agents
- No explicit declaration found; this is not inferred or tested compatibility
- Static check
- 88 / 100 · heuristic scan, not runtime safety proof
- Author / version / license
- @tomevault-io · no license declared
- Fluxly token estimate
- Lean
- Fluxly setup estimate
- Plug-and-play
- External API key
- No requirement detected
- Detected OS requirements
- Unspecified
- Runtime requirements
- Python
- Detected file/system behavior
-
- Read-only
- Write / modify
- Detected network behavior
- Local-only
- Install commands
- None (reference only)
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
The current SKILL.md does not define a fixed output example. After fetching PR data from the GitHub API, use Python or jq to compute: Total PR count Merged vs closed counts
Fetching PRs for a Date Range
Python: Compute Stats from JSON
gh pr list --json returns state as "OPEN", "CLOSED", or "MERGED" mergedAt is non-null only for merged PRs A PR with state == "CLOSED" and mergedAt == null is truly closed (not merged)
created:2024-12-01..2024-12-31 is inclusive on both ends Dec 31 means up to 2024-12-31T23:59:59Z Use --limit 500 to avoid truncation for active repos
# GitHub PR Statistics
## Overview
After fetching PR data from the GitHub API, use Python or jq to compute:
- Total PR count
- Merged vs closed counts
- Average time-to-merge (days)
- Top contributor by PR count
## Fetching PRs for a Date Range
```bash
# Using gh search (handles pagination, date filtering)
gh pr list -R cli/cli \
--search "created:2024-12-01..2024-12-31" \
--state all \
--limit 500 \
--json number,author,createdAt,mergedAt,closedAt,state
```
## Python: Compute Stats from JSON
```python
import json
from datetime import datetime, timezone
from collections import Counter
# Load PR data (from gh pr list --json output)
with open('prs.json') as f:
prs = json.load(f)
total = len(prs)
# Count merged vs closed-but-not-merged
merged = [pr for pr in prs if pr['mergedAt']]
closed = [pr for pr in prs if not pr['mergedAt'] and pr['state'] == 'CLOSED']
# Average time to merge (creation -> mergedAt), in days
def parse_dt(s):
return datetime.fromisoformat(s.replace('Z', '+00:00'))
merge_days = []
for pr in merged:
created = parse_dt(pr['createdAt'])
merged_at = parse_dt(pr['mergedAt'])
delta = (merged_at - created).total_seconds() / 86400
merge_days.append(delta)
avg_merge_days = round(sum(merge_days) / len(merge_days), 1) if merge_days else 0.0
# Top contributor
authors = Counter(pr['author']['login'] for pr in prs)
top_contributor = authors.most_common(1)[0][0]
print(json.dumps({
"total": total,
"merged": len(merged),
"closed": len(closed),
"avg_merge_days": avg_merge_days,
"top_contributor": top_contributor
}, indent=2))
```
## Notes on State Values
- `gh pr list --json` returns `state` as `"OPEN"`, `"CLOSED"`, or `"MERGED"`
- `mergedAt` is non-null only for merged PRs
… Author text anchors workflow facts; Fluxly only indexes current sections, terms, files, and commands.
sections -> Overview → Fetching PRs for a Date Range → Python: Compute Stats from JSON → Notes on State Values → Notes on the Search API
terms -> --- > Source: [cxcscmu/SkillLearnBench](https://github.com/cxcscmu/SkillLearnBench) — distributed by [TomeVault](https://tomevault.io).
files/cmd -> gh pr list --json · state · "OPEN" · "CLOSED" · "MERGED" · mergedAt · state == "CLOSED" · mergedAt == null
body sha256 -> 8ccfebd8b45d
Decide Fit First
Design Intent
How To Use It
Boundaries And Review