GitHub CLI (gh)
Comprehensive reference for GitHub CLI (gh) - work seamlessly with GitHub from the command line.
Quick Start
# Verify installation
gh --version
Authentication
gh auth login
gh auth status
Common Workflows
# Create PR from issue
gh issue develop 123 --branch feature/issue-123
git add . && git commit -m "Fix issue #123" && git push
gh pr create --title "Fix #123" --body "Closes #123"
# Repository setup
gh repo create my-project --public --clone --gitignore python --license mit
# CI/CD run and watch
RUN_ID=$(gh workflow run ci.yml --ref main --jq '.databaseId')
gh run watch "$RUN_ID"
# Fork sync workflow
gh repo fork original/repo --clone
gh repo sync
# Bulk close stale issues
gh issue list --search "label:stale" --json number --jq '.[].number' | \
xargs -I {} gh issue close {} --comment "Closing as stale"
Usage
This skill provides full command references for all gh subcommands. See REFERENCE.md for the complete reference organized by:
- Authentication (
gh auth) - login, status, token, refresh, switch, setup-git
- Repositories (
gh repo) - create, clone, list, view, edit, delete, fork, sync
- Issues (
gh issue) - create, list, view, edit, close, comment, pin, transfer
- Pull Requests (
gh pr) - create, list, view, checkout, merge, review, revert
- GitHub Actions (
gh run, gh workflow, gh cache, gh secret, gh variable)
- Projects (
gh project) - create, edit, fields, items
- Releases (
gh release) - create, upload, download, verify
- Gists (
gh gist)
- Codespaces (
gh codespace)
- Search (
gh search) - code, commits, issues, PRs, repos
- Labels, SSH keys, GPG keys
- API (
gh api) - REST and GraphQL
- Extensions, Aliases, Configuration
- Global flags and output formatting
- Best practices and environment setup
Environment Variables
export GH_TOKEN=ghp_xxxxxxxxxxxx
export GH_HOST=github.com
export GH_PROMPT_DISABLED=true
export GH_EDITOR=vim
export GH_PAGER=less
export GH_TIMEOUT=30
export GH_REPO=owner/repo
Shell Integration
eval "$(gh completion -s bash)" # or zsh/fish
alias gs='gh status'
alias gpr='gh pr view --web'
alias gir='gh issue view --web'
alias gco='gh pr checkout'
Getting Help
gh --help
gh pr --help
gh help formatting
gh help environment
gh help exit-codes
References
1---2name: gh-cli3description: Always use when the user needs to work with GitHub from the command line — create or merge PRs, manage issues, run Actions workflows, create releases, manage repos, or automate any GitHub operation. Trigger on: 'gh pr', 'create pull request', 'GitHub CLI', 'gh issue', 'run workflow', 'gh release', 'merge PR', 'clone repo with gh', or any GitHub operation via terminal.4---56# GitHub CLI (gh)78Comprehensive reference for GitHub CLI (gh) - work seamlessly with GitHub from the command line.910## Quick Start1112```bash13# Verify installation14gh --version15```1617### Authentication1819```bash20gh auth login21gh auth status22```2324### Common Workflows2526```bash27# Create PR from issue28gh issue develop 123 --branch feature/issue-12329git add . && git commit -m "Fix issue #123" && git push30gh pr create --title "Fix #123" --body "Closes #123"3132# Repository setup33gh repo create my-project --public --clone --gitignore python --license mit3435# CI/CD run and watch36RUN_ID=$(gh workflow run ci.yml --ref main --jq '.databaseId')37gh run watch "$RUN_ID"3839# Fork sync workflow40gh repo fork original/repo --clone41gh repo sync4243# Bulk close stale issues44gh issue list --search "label:stale" --json number --jq '.[].number' | \45 xargs -I {} gh issue close {} --comment "Closing as stale"46```4748## Usage4950This skill provides full command references for all `gh` subcommands. See [REFERENCE.md](REFERENCE.md) for the complete reference organized by:5152- **Authentication** (`gh auth`) - login, status, token, refresh, switch, setup-git53- **Repositories** (`gh repo`) - create, clone, list, view, edit, delete, fork, sync54- **Issues** (`gh issue`) - create, list, view, edit, close, comment, pin, transfer55- **Pull Requests** (`gh pr`) - create, list, view, checkout, merge, review, revert56- **GitHub Actions** (`gh run`, `gh workflow`, `gh cache`, `gh secret`, `gh variable`)57- **Projects** (`gh project`) - create, edit, fields, items58- **Releases** (`gh release`) - create, upload, download, verify59- **Gists** (`gh gist`)60- **Codespaces** (`gh codespace`)61- **Search** (`gh search`) - code, commits, issues, PRs, repos62- **Labels, SSH keys, GPG keys**63- **API** (`gh api`) - REST and GraphQL64- **Extensions, Aliases, Configuration**65- **Global flags and output formatting**66- **Best practices and environment setup**6768## Environment Variables6970```bash71export GH_TOKEN=ghp_xxxxxxxxxxxx72export GH_HOST=github.com73export GH_PROMPT_DISABLED=true74export GH_EDITOR=vim75export GH_PAGER=less76export GH_TIMEOUT=3077export GH_REPO=owner/repo78```7980## Shell Integration8182```bash83eval "$(gh completion -s bash)" # or zsh/fish84alias gs='gh status'85alias gpr='gh pr view --web'86alias gir='gh issue view --web'87alias gco='gh pr checkout'88```8990## Getting Help9192```bash93gh --help94gh pr --help95gh help formatting96gh help environment97gh help exit-codes98```99100## References101102- Official Manual: https://cli.github.com/manual/103- GitHub Docs: https://docs.github.com/en/github-cli104- REST API: https://docs.github.com/en/rest105- GraphQL API: https://docs.github.com/en/graphql