| name | git-gh-client |
| description | Core GitHub CLI operations - check availability, search PRs, get PR details, check status. Invoked by other git skills. |
GitHub CLI (gh) Client Skill
Base skill for interacting with GitHub via the gh CLI tool. This skill is invoked by other git skills that need GitHub operations.
Purpose
Provides reusable GitHub CLI functionality:
- ✅ Check if
gh is installed and authenticated
- 📋 List all PRs for the repository
- 🔍 Search and filter PRs (by author, label, date, state, etc.)
- 📄 Get PR details and metadata
- ✅ Check PR status checks and CI/CD results
- 📝 Create and manage pull requests
Common Use Cases
This skill is used both directly (when user asks to list/filter PRs) and indirectly (invoked by other skills):
Direct usage:
- "List all open PRs" → Shows all open PRs in current repo
- "Find PRs by username" → Filters PRs by author
- "Show PRs with label 'bug'" → Filters by label
- "List recent PRs" → Shows PRs sorted by date
Invoked by other skills:
git-prepare-pull-request - Creating PRs
pr-review - Reviewing PRs
git-pull-request-status - Checking PR status and CI/CD
Phase 1: Check gh CLI Availability
ALWAYS check if gh is installed before attempting gh commands.
Check Installation
which gh
Check Authentication
gh auth status
If Not Installed
Provide installation instructions:
The GitHub CLI (`gh`) is required for this operation.
## Installation
**Linux (Debian/Ubuntu):**
```bash
sudo apt install gh
Linux (Fedora/RHEL/CentOS):
sudo dnf install gh
macOS:
brew install gh
Windows:
winget install --id GitHub.cli
Other platforms:
Visit https://cli.github.com/manual/installation
Authentication
After installation, authenticate with:
gh auth login
Follow the prompts to authenticate with your GitHub account.
### If Not Authenticated
```bash
gh auth login
Phase 2: List and Filter Pull Requests
This is a CORE capability - used both directly by users and by other skills.
Basic PR Listing
gh pr list
gh pr list --limit 100
gh pr list --json number,title,author,createdAt,state
gh pr list | column -t
Filter by State
gh pr list --state open
gh pr list --state closed
gh pr list --state merged
gh pr list --state all
Filter by Author
gh pr list --author <username>
gh pr list --author @me
gh pr list --search "author:user1 author:user2"
Filter by Label
gh pr list --label bug
gh pr list --label "bug,priority:high"
gh pr list --search "label:enhancement"
Filter by Assignee/Reviewer
gh pr list --assignee <username>
gh pr list --assignee @me
gh pr list --search "review-requested:username"
gh pr list --search "reviewed-by:username"
Search by Keywords
gh pr list --search "keyword"
gh pr list --search "in:title keyword"
gh pr list --search "in:body keyword"
gh pr list --search "keyword1 keyword2"
Filter by Date
gh pr list --search "created:>$(date -d '7 days ago' +%Y-%m-%d)"
gh pr list --search "updated:>$(date -d '1 day ago' +%Y-%m-%d)"
gh pr list --search "created:2024-01-01..2024-01-31"
gh pr list --search "created:<2024-01-01"
Advanced Filtering
gh pr list --search "is:draft"
gh pr list --draft
gh pr list --search "is:open -is:draft"
gh pr list --search "is:open conflicts:>0"
gh pr list --search "is:open -label:has-tests"
gh pr list --search "is:open review:required"
gh pr list --search "is:open review:approved"
gh pr list --search "is:open review:changes_requested"
gh pr list --base main
gh pr list --base develop
gh pr list --search "head:feature/*"
Combined Filters (Real-World Examples)
gh pr list --author @me --state open --search "review:required"
gh pr list --label bug --search "is:open review:approved"
gh pr list --author username --search "created:>$(date -d '7 days ago' +%Y-%m-%d)"
gh pr list --label "priority:high" --search "is:open status:failure"
gh pr list --search "is:open review:approved status:success -conflicts:>0"
Sort and Format Output
gh pr list --json number,title,createdAt --jq 'sort_by(.createdAt) | reverse | .[] | "#\(.number) - \(.title)"'
gh pr list --json number,title,updatedAt --jq 'sort_by(.updatedAt) | reverse | .[] | "#\(.number) - \(.title) (updated: \(.updatedAt))"'
gh pr list --json number,title,author,state,createdAt --jq '.[] |
"#\(.number) [\(.state)] \(.title) by @\(.author.login) (\(.createdAt[:10]))"'
gh pr list --json number,title,author,state,createdAt --jq -r '
["Number","Title","Author","State","Created"],
(.[] | [.number, .title, .author.login, .state, .createdAt]) |
@csv'
gh pr list --json labels --jq '[.[].labels[].name] | group_by(.) | map({label: .[0], count: length})'
Get PR Details
gh pr view <PR_NUMBER>
gh pr view <PR_NUMBER> --json number,title,body,author,state,baseRefName,headRefName,createdAt,updatedAt,labels,reviews,files,commits
gh pr diff <PR_NUMBER>
gh pr view <PR_NUMBER> --json commits --jq '.commits[] | "\(.oid[0:7]) \(.messageHeadline)"'
gh pr view <PR_NUMBER> --json files --jq '.files[] | .path'
gh pr view <PR_NUMBER> --json statusCheckRollup
Common Error: If you see "Projects (classic) is being deprecated" error:
- This means you're requesting deprecated fields (projectCards, projectItems)
- Solution: Only request the safe fields listed above
Phase 3: PR Status Checks
Using gh pr checks
IMPORTANT: gh pr checks returns exit code 1 when ANY check fails. This is NORMAL behavior, NOT an error.
ALWAYS handle the exit code when using this command:
gh pr checks <PR_NUMBER> || true
if gh pr checks <PR_NUMBER> 2>&1; then
echo "All checks passed!"
else
echo "Some checks failed (see output above)"
fi
checks_output=$(gh pr checks <PR_NUMBER> 2>&1 || true)
echo "$checks_output"
gh pr checks <PR_NUMBER>
check_exit_code=$?
if [ $check_exit_code -eq 0 ]; then
echo "All checks passed"
else
echo "Some checks failed (exit code: $check_exit_code)"
fi
Exit code behavior:
- Exit code 0 = All checks passed ✅
- Exit code 1 = One or more checks failed ❌ (this is NOT a command error!)
- The output is always valid and shows check status regardless of exit code
Alternative: Get Status Checks via JSON
If you need programmatic parsing, use JSON:
gh pr view <PR_NUMBER> --json statusCheckRollup --jq '.statusCheckRollup'
Parse Status Check Results
The statusCheckRollup contains all CI/CD checks. Parse it to find failures:
gh pr view <PR_NUMBER> --json statusCheckRollup --jq '
.statusCheckRollup[] |
select(.conclusion == "FAILURE" or .conclusion == "ERROR") |
{
name: .name,
conclusion: .conclusion,
detailsUrl: .detailsUrl
}
'
Status Check Conclusions
| Conclusion | Meaning |
|---|
SUCCESS | Check passed |
FAILURE | Check failed |
ERROR | Check encountered an error |
PENDING | Check is running |
SKIPPED | Check was skipped |
CANCELLED | Check was cancelled |
TIMED_OUT | Check timed out |
Get Check Run Details
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/checks --jq '.check_runs[] | {name, conclusion, output: .output.title}'
Get Workflow Run Logs
If a GitHub Actions check failed, get the logs:
gh run list --branch <branch-name> --limit 10
gh run view <RUN_ID> --log
gh run view <RUN_ID> --log-failed
Phase 4: Creating Pull Requests
Create PR with Details
gh pr create
gh pr create --title "PR Title" --body "Description"
gh pr create --title "Feature: Add new capability" --body "$(cat <<'EOF'
## Summary
- Added feature X
- Updated documentation
## Test Plan
- [ ] Unit tests pass
- [ ] Integration tests pass
🤖 Generated with Claude Code
EOF
)"
gh pr create --draft --title "WIP: Feature" --body "Work in progress"
gh pr create --title "Fix bug" --body "..." --reviewer user1,user2 --assignee user3
gh pr create --title "Fix bug" --body "..." --label bug,priority:high
gh pr create --base develop --head feature-branch --title "..." --body "..."
Auto-fill PR Details
gh pr create --fill
gh pr create --fill-first
Phase 5: PR Management
Update PR
gh pr edit <PR_NUMBER> --title "New title"
gh pr edit <PR_NUMBER> --body "New description"
gh pr edit <PR_NUMBER> --add-label bug,priority:high
gh pr edit <PR_NUMBER> --add-reviewer user1,user2
gh pr ready <PR_NUMBER>
gh pr edit <PR_NUMBER> --draft
Merge PR
gh pr merge <PR_NUMBER>
gh pr merge <PR_NUMBER> --merge
gh pr merge <PR_NUMBER> --squash
gh pr merge <PR_NUMBER> --rebase
gh pr merge <PR_NUMBER> --auto