| name | github |
| description | Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries. Use when the user asks about GitHub issues, pull requests, workflows, or wants to interact with GitHub repositories from the command line — including tasks like check CI status, create PR, list issues, or query the GitHub API. |
GitHub Skill
Use the gh CLI to interact with GitHub. Always specify --repo owner/repo when not in a git directory, or use URLs directly.
Pull Requests
Creating
gh pr create --title "Add feature" --body "Description of changes"
gh pr create --title "WIP: feature" --body "Still working on this" --draft
gh pr create --title "Fix bug" --body "Fixes #42" --reviewer user1,user2 --label bug,urgent
gh pr create --title "Feature" --body "..." --base develop
gh pr create --title "Feature" --body "$(cat <<'EOF'
## Summary
- Added new endpoint
- Updated tests
## Test plan
- [ ] Unit tests pass
- [ ] Manual QA
EOF
)"
Viewing and Listing
gh pr list --repo owner/repo
gh pr list --author @me
gh pr list --label "needs-review"
gh pr view 55 --repo owner/repo
gh pr diff 55 --repo owner/repo
gh pr checkout 55
Reviewing and Commenting
gh pr review 55 --approve
gh pr review 55 --request-changes --body "Please fix the error handling"
gh pr comment 55 --body "Looks good, just one question about the caching layer"
gh api repos/owner/repo/pulls/55/comments
Merging
gh pr merge 55
gh pr merge 55 --squash
gh pr merge 55 --rebase
gh pr merge 55 --squash --delete-branch
gh pr merge 55 --auto --squash
CI Status and Debugging
Check CI status on a PR:
gh pr checks 55 --repo owner/repo
List recent workflow runs:
gh run list --repo owner/repo --limit 10
View a run and see which steps failed:
gh run view <run-id> --repo owner/repo
View logs for failed steps only:
gh run view <run-id> --repo owner/repo --log-failed
Debugging a CI Failure
Follow this sequence to investigate a failing CI run:
- Check PR status — identify which checks are failing:
gh pr checks 55 --repo owner/repo
- List recent runs — find the relevant run ID:
gh run list --repo owner/repo --limit 10
- View the failed run — see which jobs and steps failed:
gh run view <run-id> --repo owner/repo
- Fetch failure logs — get the detailed output for failed steps:
gh run view <run-id> --repo owner/repo --log-failed
Issues
Creating
gh issue create --title "Bug: crash on launch" --body "Steps to reproduce..."
gh issue create --title "Add dark mode" --label enhancement,ui --assignee @me
gh issue create --template "bug_report.md"
Listing and Searching
gh issue list --repo owner/repo
gh issue list --label bug
gh issue list --assignee @me
gh issue list --search "memory leak language:swift"
gh issue list --state closed --limit 20
Managing
gh issue view 42
gh issue close 42
gh issue close 42 --comment "Fixed in #55"
gh issue reopen 42
gh issue edit 42 --add-label "priority:high"
gh issue edit 42 --remove-label "needs-triage"
gh issue edit 42 --add-assignee user1
gh issue comment 42 --body "Reproduced on iOS 18.2"
gh issue pin 42
Releases
Creating
gh release create v1.0.0 --title "v1.0.0" --notes "First stable release"
gh release create v1.1.0 --title "v1.1.0" --draft --notes "Release candidate"
gh release create v1.2.0 --generate-notes
gh release create v1.2.0 --generate-notes --notes-start-tag v1.1.0
gh release create v2.0.0-beta.1 --prerelease --title "v2.0.0 Beta 1" --notes "Beta release"
gh release create v1.0.0 ./build/app.zip ./build/app.dmg --title "v1.0.0"
Managing Assets
gh release upload v1.0.0 ./build/app.zip ./build/checksum.txt
gh release download v1.0.0 --dir ./downloads
gh release download v1.0.0 --pattern "*.dmg"
Listing and Viewing
gh release list --repo owner/repo
gh release view v1.0.0
gh release view --repo owner/repo
Editing and Deleting
gh release edit v1.0.0 --notes "Updated release notes"
gh release edit v1.0.0 --draft=false
gh release delete v1.0.0
Gists
Creating
gh gist create script.py --public
gh gist create config.json
gh gist create snippet.swift --desc "Core Data migration helper"
gh gist create file1.py file2.py file3.py
echo "hello world" | gh gist create --filename greeting.txt
Managing
gh gist list
gh gist view <gist-id>
gh gist edit <gist-id>
gh gist edit <gist-id> --add newfile.md
gh gist delete <gist-id>
gh gist clone <gist-id>
API for Advanced Queries
The gh api command is useful for accessing data not available through other subcommands.
Get PR with specific fields:
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
Paginate large result sets:
gh api repos/owner/repo/issues --paginate --jq '.[].title'
POST request (e.g., add a label):
gh api repos/owner/repo/issues/42/labels --method POST --input - <<< '["bug"]'
JSON Output
Most commands support --json for structured output. Use --jq to filter:
gh issue list --json number,title --jq '.[] | "\(.number): \(.title)"'
gh pr list --json author --jq '.[].author.login' | sort -u
gh pr checks 55 --json name,state --jq '.[] | select(.state != "SUCCESS")'