github-api-queries
Query GitHub API for pull requests and issues within a date range, retrieving all metadata needed for metrics collection. Use this skill whenever you need to fetch GitHub PR or issue data with date filtering, especially when gathering activity reports or computing statistics across a time period.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- github-api-queries
- description
- Query GitHub API for pull requests and issues within a date range, retrieving all metadata needed for metrics collection. Use this skill whenever you need to fetch GitHub PR or issue data with date filtering, especially when gathering activity reports or computing statistics across a time period.
03 SKILL.md 正文
GitHub API Queries for Metrics Collection
This skill demonstrates how to query the GitHub API for pull requests and issues using the gh CLI tool, extracting all necessary metadata for downstream analysis.
Prerequisites
ghCLI installed and authenticated to GitHub- Target repository in the format
owner/repo(e.g.,cli/cli) - Date range for filtering (e.g.,
2024-12-01..2024-12-31)
Querying Pull Requests
Use gh pr list with date filtering to retrieve all PRs created during a period:
gh pr list --repo cli/cli \
--state all \
--search "created:2024-12-01..2024-12-31" \
--json number,title,author,createdAt,mergedAt,closedAt,state \
--limit 1000
Key flags:
--state all: Includes both open and closed PRs--search "created:2024-12-01..2024-12-31": GitHub search syntax for date ranges--json: Specify exact fields needed (number, author, timestamps, state)--limit 1000: Fetch up to 1000 results (pagination handled bygh)
Important fields for metrics:
number: PR identifierauthor: Object withloginfield for contributor trackingcreatedAt: ISO timestamp for PR creationmergedAt: ISO timestamp for merge (null if not merged)closedAt: ISO timestamp for closure (null if still open)state: OPEN, CLOSED, or MERGED
Querying Issues
Use gh issue list for issues:
gh issue list --repo cli/cli \
--state all \
--search "created:2024-12-01..2024-12-31" \
--json number,title,labels,createdAt,closedAt,state \
--limit 1000
Key fields for metrics:
labels: Array of label objects withnamefield (use for bug detection)closedAt: Timestamp for closure (null if still open)
Error Handling
If gh returns a rate limit error, wait and retry:
# Check remaining API quota
gh api rate_limit
If authentication fails, ensure:
gh auth status
Output Format
Both queries return JSON arrays. Each item includes the fields specified in --json. Example PR object:
{
"number": 12345,
"title": "Add feature X",
"author": {
"login": "octocat"
},
"createdAt": "2024-12-05T14:30:00Z",
"mergedAt": "2024-12-10T16:45:00Z",
"closedAt": null,
"state": "MERGED"
}
Date Format
All timestamps use ISO 8601 format (UTC). For calculations, parse with standard datetime libraries:
- Python:
datetime.fromisoformat() - JavaScript:
new Date()orDate.parse() - Bash: Convert via epoch for arithmetic
Tips for Reliability
- Always use
--limit 1000or higher to ensure all results are captured (verify count matches expectation) - Dates must use
YYYY-MM-DDformat in search queries - Include both endpoints of the range (results are inclusive of both dates)
- When comparing timestamps, ensure consistent timezone handling (all GitHub timestamps are UTC)
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.