Work with GitHub from the command line using the GitHub CLI (gh). Use when managing repositories, pull requests, issues, releases, GitHub Actions, or any GitHub operations. Keywords: github, gh, pull request, PR, issue, release, workflow, actions, repository, fork, clone, merge
Resources
1Install
npx skillscat add wcygan/dotfiles/gh-cli Install via the SkillsCat registry.
SKILL.md
GitHub CLI (gh)
Use the gh CLI to interact with GitHub directly from the terminal. Prefer gh over raw git commands or API calls for GitHub-specific operations.
Quick Reference
Authentication
gh auth login # Interactive login
gh auth status # Check authentication
gh auth token # Print current tokenRepository Operations
gh repo clone owner/repo # Clone repository
gh repo view # View current repo details
gh repo create name --public # Create new repository
gh repo fork owner/repo --clone # Fork and clone
gh repo sync # Sync fork with upstreamPull Requests
gh pr create # Create PR interactively
gh pr list # List open PRs
gh pr view 123 # View PR details
gh pr checkout 123 # Checkout PR branch
gh pr merge 123 --squash # Merge with squash
gh pr diff 123 # View PR diff
gh pr checks 123 --watch # Watch CI checksIssues
gh issue create # Create issue interactively
gh issue list # List open issues
gh issue view 123 # View issue details
gh issue close 123 # Close issue
gh issue comment 123 --body "x" # Add commentGitHub Actions
gh run list # List workflow runs
gh run view 123456 # View run details
gh run watch 123456 # Watch run in real-time
gh run rerun 123456 # Rerun failed run
gh workflow run ci.yml # Trigger workflow manuallyReleases
gh release list # List releases
gh release create v1.0.0 # Create release
gh release download v1.0.0 # Download release assetsInstructions
When the user needs to interact with GitHub:
Verify authentication if operations fail:
gh auth statusUse appropriate subcommands based on the task:
- Repository management →
gh repo - Pull requests →
gh pr - Issues →
gh issue - CI/CD →
gh run,gh workflow - Releases →
gh release
- Repository management →
Prefer JSON output for parsing:
gh pr list --json number,title,author gh issue view 123 --json title,body,labelsUse jq for filtering:
gh pr list --json number,title --jq '.[] | select(.title | contains("fix"))'Open in browser when useful:
gh pr view 123 --web gh issue view 123 --web gh browse
Common Workflows
Create PR from Current Branch
gh pr create --title "Feature: Add X" --body "Description" --draftReview and Merge PR
gh pr checkout 123
# Review code...
gh pr review 123 --approve
gh pr merge 123 --squash --delete-branchCheck CI Status
gh pr checks 123 --watch
gh run list --workflow ci.yml --limit 5Link Issue to PR
gh pr create --title "Fix #123" --body "Closes #123"For detailed reference, see REFERENCE.md.