GitHub CLI (gh)
Overview
Expert guidance for GitHub CLI (gh) operations and workflows. Use this skill for command-line GitHub operations including pull request management, issue tracking, repository operations, workflow automation, and codespace management.
Key capabilities:
- Create and manage pull requests from the terminal
- Track and organize issues efficiently
- Search across all of GitHub (repos, issues, PRs)
- Manage labels and project organization
- Trigger and monitor GitHub Actions workflows
- Work with codespaces
- Automate repository operations and releases
Safety Rules
CRITICAL: This skill NEVER uses destructive gh CLI operations.
This skill focuses exclusively on safe, read-only, or reversible GitHub operations. The following commands are PROHIBITED and must NEVER be used:
Permanently destructive commands:
gh repo delete - Repository deletion
gh repo archive - Repository archival
gh release delete - Release deletion
gh release delete-asset - Asset deletion
gh run delete - Workflow run deletion
gh cache delete - Cache deletion
gh secret delete - Secret deletion
gh variable delete - Variable deletion
gh label delete - Label deletion
gh ssh-key delete - SSH key deletion (can lock out users)
gh gpg-key delete - GPG key deletion
gh codespace delete - Codespace deletion
gh extension remove - Extension removal
gh gist delete - Gist deletion
- Bulk deletion operations using
xargs with any destructive commands
- Shell commands:
rm -rf (except for temporary file cleanup)
Allowed operations:
- Creating resources (PRs, issues, releases, labels, repos)
- Viewing and listing (status, logs, information, searches)
- Updating and editing existing resources
- Closing PRs/issues (reversible - can be reopened)
- Canceling workflow runs (stops execution without deleting data)
- Merging pull requests (after proper review)
- Read-only git operations (
git status, git log, git diff)
Installation & Setup
gh auth login
gh auth status
gh auth setup-git
Pull Requests
Creating PRs
gh pr create
gh pr create --title "Add feature" --body "Description"
gh pr create --base main --head feature-branch
gh pr create --draft
gh pr create --fill
Viewing PRs
gh pr list
gh pr list --author @me
gh pr view 123
gh pr view 123 --web
gh pr diff 123
gh pr status
Managing PRs
gh pr checkout 123
gh pr review 123 --approve
gh pr review 123 --comment --body "Looks good!"
gh pr review 123 --request-changes --body "Please fix X"
gh pr merge 123
gh pr merge 123 --squash
gh pr merge 123 --rebase
gh pr merge 123 --merge
gh pr close 123
gh pr reopen 123
gh pr ready 123
gh pr update-branch 123
PR Checks
gh pr checks 123
gh pr checks 123 --watch
Issues
Creating Issues
gh issue create
gh issue create --title "Bug report" --body "Description"
gh issue create --title "Bug" --label bug,critical
gh issue create --title "Task" --assignee @me
Viewing Issues
gh issue list
gh issue list --assignee @me
gh issue list --label bug
gh issue view 456
gh issue view 456 --web
Managing Issues
gh issue close 456
gh issue reopen 456
gh issue edit 456 --title "New title"
gh issue edit 456 --add-label bug
gh issue edit 456 --add-assignee @user
gh issue comment 456 --body "Update"
gh issue develop 456 --checkout
Repository Operations
Repository Info
gh repo view
gh repo view --web
gh repo clone owner/repo
gh repo fork owner/repo
gh repo list owner
Repository Management
gh repo create my-repo --public
gh repo create my-repo --private
gh repo sync owner/repo
gh repo set-default
Search
Search across all of GitHub for repositories, issues, and pull requests.
Search Repositories
gh search repos "machine learning" --language=python
gh search repos --stars=">1000" --topic=kubernetes
Search Issues
gh search issues "bug" --label=critical --state=open
gh search issues -- "memory leak -label:wontfix"
Search Pull Requests
gh search prs --author=@me --state=open
gh search prs "refactor" --created=">2024-01-01"
Labels
Manage repository labels for issue and PR organization.
List and View Labels
gh label list
Create and Edit Labels
gh label create "priority: high" --color FF0000 --description "High priority items"
gh label edit "bug" --color FFAA00 --description "Something isn't working"
Clone Labels Between Repos
gh label clone owner/source-repo
Codespaces
Manage GitHub Codespaces directly from the terminal.
List and Create Codespaces
gh codespace list
gh codespace create --repo owner/repo
Connect to Codespaces
gh codespace ssh
gh codespace code
gh codespace jupyter
Manage Codespace Files
gh codespace cp local-file.txt remote:~/path/
gh codespace cp remote:~/path/file.txt ./local-dir/
gh codespace logs
Releases
Creating Releases
gh release create v1.0.0
gh release create v1.0.0 --notes "Release notes"
gh release create v1.0.0 dist/*.tar.gz
gh release create v1.0.0 --draft
gh release create v1.0.0 --generate-notes
Managing Releases
gh release list
gh release view v1.0.0
gh release download v1.0.0
Gists
gh gist create file.txt
echo "content" | gh gist create -
gh gist list
gh gist view <gist-id>