| name | github-docs |
| description | Investigate GitHub repositories using the gh CLI. Analyze PRs, issues, commits, CI/CD status, repo health, contributor activity, security vulnerabilities, and fetch repo docs/content. Use for any GitHub-related investigation or documentation retrieval. |
GitHub Investigation
Investigate repositories using gh CLI. All commands assume gh auth status passes.
Quick Reference
Repository Context
gh repo view [owner/repo]
gh repo view [owner/repo] --json name,description,defaultBranchRef,stargazerCount,forkCount,issues,pullRequests,url
gh api repos/{owner}/{repo}/readme --jq '.content' | base64 -d
gh api repos/{owner}/{repo}/contents --jq '.[] | "\(.type) \(.name)"'
gh api repos/{owner}/{repo}/contents/{path}
Pull Requests
gh pr list
gh pr list --state all --limit 20
gh pr view <number>
gh pr view <number> --json title,body,state,author,reviews,comments,commits,files,mergeable,statusCheckRollup
gh pr diff <number>
gh pr checks <number>
gh api repos/{owner}/{repo}/pulls/<number>/comments
gh api repos/{owner}/{repo}/pulls/<number>/reviews
Issues
gh issue list
gh issue list --state all --limit 30
gh issue list --label "bug" --label "critical"
gh issue view <number>
gh issue view <number> --json title,body,state,author,comments,labels,assignees,milestone
gh api repos/{owner}/{repo}/issues/<number>/timeline
Commits & History
gh api repos/{owner}/{repo}/commits --jq '.[0:10] | .[] | "\(.sha[0:7]) \(.commit.author.name): \(.commit.message | split("\n")[0])"'
gh api repos/{owner}/{repo}/commits/<sha>
gh api repos/{owner}/{repo}/compare/base...head
git log --oneline -20
git log --oneline --since="2 weeks ago"
CI/CD & Workflows
gh run list --limit 10
gh run view <run-id>
gh run view <run-id> --log-failed
gh workflow list
gh api repos/{owner}/{repo}/actions/runs --jq '.workflow_runs[0:5] | .[] | "\(.status) \(.conclusion // "running") - \(.name)"'
Contributors & Activity
gh api repos/{owner}/{repo}/contributors --jq '.[0:10] | .[] | "\(.login): \(.contributions) commits"'
gh api repos/{owner}/{repo}/stats/contributors
gh api repos/{owner}/{repo}/activity
gh api repos/{owner}/{repo}/commits --jq 'group_by(.commit.author.name) | map({author: .[0].commit.author.name, count: length}) | sort_by(-.count)'
Branches & Releases
gh api repos/{owner}/{repo}/branches --jq '.[].name'
gh api repos/{owner}/{repo}/branches/<branch>/protection
gh release list --limit 5
gh release view <tag>
Security
gh api repos/{owner}/{repo}/vulnerability-alerts
gh api repos/{owner}/{repo}/secret-scanning/alerts
gh api repos/{owner}/{repo}/code-scanning/alerts
gh api repos/{owner}/{repo}/dependabot/alerts --jq '.[] | "\(.security_advisory.severity): \(.security_advisory.summary)"'
Search
gh search repos "keyword" --limit 10
gh search repos "keyword" --owner {org}
gh search issues "error" --repo owner/repo
gh search prs "fix" --repo owner/repo --state merged
gh search code "function_name" --repo owner/repo
Investigation Workflows
PR Deep Dive
gh pr view <n> --json title,body,author,state,commits,files,reviews,statusCheckRollup
gh pr diff <n> - examine changes
gh pr checks <n> - CI status
gh api repos/{o}/{r}/pulls/<n>/reviews - review verdicts
gh api repos/{o}/{r}/pulls/<n>/comments - inline comments
Issue Triage
gh issue list --state open --limit 50 --json number,title,labels,createdAt,author
- Group by labels, identify patterns
gh issue view <n> for details on high-priority items
gh api repos/{o}/{r}/issues/<n>/timeline for full context
Repo Health Check
gh repo view --json stargazerCount,forkCount,issues,pullRequests,updatedAt
gh pr list --state open - PR backlog
gh issue list --state open - Issue backlog
gh run list --limit 5 - CI health
gh api repos/{o}/{r}/contributors - active maintainers
gh release list --limit 3 - release cadence
Debug CI Failure
gh run list --limit 5 - find failed run
gh run view <id> - which job failed
gh run view <id> --log-failed - error logs
gh run rerun <id> - retry if flaky
Common Patterns
JSON Output & jq
Most commands support --json for structured output:
gh pr list --json number,title,author,createdAt --jq '.[] | "\(.number): \(.title) by \(.author.login)"'
Pagination
API endpoints paginate. Use --paginate or iterate:
gh api repos/{o}/{r}/issues --paginate --jq '.[].title'
Cross-Repo Operations
Always specify repo when not in a clone:
gh pr list --repo owner/repo
gh issue view 123 --repo owner/repo