Claude Agent Skill · by Github

Gh Cli

GitHub CLI (gh) is a comprehensive command-line reference tool that enables developers to manage repositories, issues, pull requests, Actions, projects, release

Install
Terminal · npx
$npx skills add https://github.com/github/awesome-copilot --skill gh-cli
Works with Paperclip

How Gh Cli fits into a Paperclip company.

Gh Cli drops into any Paperclip agent that handles this kind of work. Assign it to a specialist inside a pre-configured PaperclipOrg company and the skill becomes available on every heartbeat — no prompt engineering, no tool wiring.

S
SaaS FactoryPaired

Pre-configured AI company — 18 agents, 18 skills, one-time purchase.

$27$59
Explore pack
Source file
SKILL.md2187 lines
Expand
---name: gh-clidescription: GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.--- # GitHub CLI (gh) Comprehensive reference for GitHub CLI (gh) - work seamlessly with GitHub from the command line. **Version:** 2.85.0 (current as of January 2026) ## Prerequisites ### Installation ```bash# macOSbrew install gh # Linuxcurl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/nullsudo apt updatesudo apt install gh # Windowswinget install --id GitHub.cli # Verify installationgh --version``` ### Authentication ```bash# Interactive login (default: github.com)gh auth login # Login with specific hostnamegh auth login --hostname enterprise.internal # Login with tokengh auth login --with-token < mytoken.txt # Check authentication statusgh auth status # Switch accountsgh auth switch --hostname github.com --user username # Logoutgh auth logout --hostname github.com --user username``` ### Setup Git Integration ```bash# Configure git to use gh as credential helpergh auth setup-git # View active tokengh auth token # Refresh authentication scopesgh auth refresh --scopes write:org,read:public_key``` ## CLI Structure ```gh                          # Root command├── auth                    # Authentication│   ├── login│   ├── logout│   ├── refresh│   ├── setup-git│   ├── status│   ├── switch│   └── token├── browse                  # Open in browser├── codespace               # GitHub Codespaces│   ├── code│   ├── cp│   ├── create│   ├── delete│   ├── edit│   ├── jupyter│   ├── list│   ├── logs│   ├── ports│   ├── rebuild│   ├── ssh│   ├── stop│   └── view├── gist                    # Gists│   ├── clone│   ├── create│   ├── delete│   ├── edit│   ├── list│   ├── rename│   └── view├── issue                   # Issues│   ├── create│   ├── list│   ├── status│   ├── close│   ├── comment│   ├── delete│   ├── develop│   ├── edit│   ├── lock│   ├── pin│   ├── reopen│   ├── transfer│   ├── unlock│   └── view├── org                     # Organizations│   └── list├── pr                      # Pull Requests│   ├── create│   ├── list│   ├── status│   ├── checkout│   ├── checks│   ├── close│   ├── comment│   ├── diff│   ├── edit│   ├── lock│   ├── merge│   ├── ready│   ├── reopen│   ├── revert│   ├── review│   ├── unlock│   ├── update-branch│   └── view├── project                 # Projects│   ├── close│   ├── copy│   ├── create│   ├── delete│   ├── edit│   ├── field-create│   ├── field-delete│   ├── field-list│   ├── item-add│   ├── item-archive│   ├── item-create│   ├── item-delete│   ├── item-edit│   ├── item-list│   ├── link│   ├── list│   ├── mark-template│   ├── unlink│   └── view├── release                 # Releases│   ├── create│   ├── list│   ├── delete│   ├── delete-asset│   ├── download│   ├── edit│   ├── upload│   ├── verify│   ├── verify-asset│   └── view├── repo                    # Repositories│   ├── create│   ├── list│   ├── archive│   ├── autolink│   ├── clone│   ├── delete│   ├── deploy-key│   ├── edit│   ├── fork│   ├── gitignore│   ├── license│   ├── rename│   ├── set-default│   ├── sync│   ├── unarchive│   └── view├── cache                   # Actions caches│   ├── delete│   └── list├── run                     # Workflow runs│   ├── cancel│   ├── delete│   ├── download│   ├── list│   ├── rerun│   ├── view│   └── watch├── workflow                # Workflows│   ├── disable│   ├── enable│   ├── list│   ├── run│   └── view├── agent-task              # Agent tasks├── alias                   # Command aliases│   ├── delete│   ├── import│   ├── list│   └── set├── api                     # API requests├── attestation             # Artifact attestations│   ├── download│   ├── trusted-root│   └── verify├── completion              # Shell completion├── config                  # Configuration│   ├── clear-cache│   ├── get│   ├── list│   └── set├── extension               # Extensions│   ├── browse│   ├── create│   ├── exec│   ├── install│   ├── list│   ├── remove│   ├── search│   └── upgrade├── gpg-key                 # GPG keys│   ├── add│   ├── delete│   └── list├── label                   # Labels│   ├── clone│   ├── create│   ├── delete│   ├── edit│   └── list├── preview                 # Preview features├── ruleset                 # Rulesets│   ├── check│   ├── list│   └── view├── search                  # Search│   ├── code│   ├── commits│   ├── issues│   ├── prs│   └── repos├── secret                  # Secrets│   ├── delete│   ├── list│   └── set├── ssh-key                 # SSH keys│   ├── add│   ├── delete│   └── list├── status                  # Status overview└── variable                # Variables    ├── delete    ├── get    ├── list    └── set``` ## Configuration ### Global Configuration ```bash# List all configurationgh config list # Get specific configuration valuegh config list git_protocolgh config get editor # Set configuration valuegh config set editor vimgh config set git_protocol sshgh config set prompt disabledgh config set pager "less -R" # Clear configuration cachegh config clear-cache``` ### Environment Variables ```bash# GitHub token (for automation)export GH_TOKEN=ghp_xxxxxxxxxxxx # GitHub hostnameexport GH_HOST=github.com # Disable promptsexport GH_PROMPT_DISABLED=true # Custom editorexport GH_EDITOR=vim # Custom pagerexport GH_PAGER=less # HTTP timeoutexport GH_TIMEOUT=30 # Custom repository (override default)export GH_REPO=owner/repo # Custom git protocolexport GH_ENTERPRISE_HOSTNAME=hostname``` ## Authentication (gh auth) ### Login ```bash# Interactive logingh auth login # Web-based authenticationgh auth login --web # With clipboard for OAuth codegh auth login --web --clipboard # With specific git protocolgh auth login --git-protocol ssh # With custom hostname (GitHub Enterprise)gh auth login --hostname enterprise.internal # Login with token from stdingh auth login --with-token < token.txt # Insecure storage (plain text)gh auth login --insecure-storage``` ### Status ```bash# Show all authentication statusgh auth status # Show active account onlygh auth status --active # Show specific hostnamegh auth status --hostname github.com # Show token in outputgh auth status --show-token # JSON outputgh auth status --json hosts # Filter with jqgh auth status --json hosts --jq '.hosts | add'``` ### Switch Accounts ```bash# Interactive switchgh auth switch # Switch to specific user/hostgh auth switch --hostname github.com --user monalisa``` ### Token ```bash# Print authentication tokengh auth token # Token for specific host/usergh auth token --hostname github.com --user monalisa``` ### Refresh ```bash# Refresh credentialsgh auth refresh # Add scopesgh auth refresh --scopes write:org,read:public_key # Remove scopesgh auth refresh --remove-scopes delete_repo # Reset to default scopesgh auth refresh --reset-scopes # With clipboardgh auth refresh --clipboard``` ### Setup Git ```bash# Setup git credential helpergh auth setup-git # Setup for specific hostgh auth setup-git --hostname enterprise.internal # Force setup even if host not knowngh auth setup-git --hostname enterprise.internal --force``` ## Browse (gh browse) ```bash# Open repository in browsergh browse # Open specific pathgh browse script/gh browse main.go:312 # Open issue or PRgh browse 123 # Open commitgh browse 77507cd94ccafcf568f8560cfecde965fcfa63 # Open with specific branchgh browse main.go --branch bug-fix # Open different repositorygh browse --repo owner/repo # Open specific pagesgh browse --actions       # Actions tabgh browse --projects      # Projects tabgh browse --releases      # Releases tabgh browse --settings      # Settings pagegh browse --wiki          # Wiki page # Print URL instead of openinggh browse --no-browser``` ## Repositories (gh repo) ### Create Repository ```bash# Create new repositorygh repo create my-repo # Create with descriptiongh repo create my-repo --description "My awesome project" # Create public repositorygh repo create my-repo --public # Create private repositorygh repo create my-repo --private # Create with homepagegh repo create my-repo --homepage https://example.com # Create with licensegh repo create my-repo --license mit # Create with gitignoregh repo create my-repo --gitignore python # Initialize as template repositorygh repo create my-repo --template # Create repository in organizationgh repo create org/my-repo # Create without cloning locallygh repo create my-repo --source=. # Disable issuesgh repo create my-repo --disable-issues # Disable wikigh repo create my-repo --disable-wiki``` ### Clone Repository ```bash# Clone repositorygh repo clone owner/repo # Clone to specific directorygh repo clone owner/repo my-directory # Clone with different branchgh repo clone owner/repo --branch develop``` ### List Repositories ```bash# List all repositoriesgh repo list # List repositories for ownergh repo list owner # Limit resultsgh repo list --limit 50 # Public repositories onlygh repo list --public # Source repositories only (not forks)gh repo list --source # JSON outputgh repo list --json name,visibility,owner # Table outputgh repo list --limit 100 | tail -n +2 # Filter with jqgh repo list --json name --jq '.[].name'``` ### View Repository ```bash# View repository detailsgh repo view # View specific repositorygh repo view owner/repo # JSON outputgh repo view --json name,description,defaultBranchRef # View in browsergh repo view --web``` ### Edit Repository ```bash# Edit descriptiongh repo edit --description "New description" # Set homepagegh repo edit --homepage https://example.com # Change visibilitygh repo edit --visibility privategh repo edit --visibility public # Enable/disable featuresgh repo edit --enable-issuesgh repo edit --disable-issuesgh repo edit --enable-wikigh repo edit --disable-wikigh repo edit --enable-projectsgh repo edit --disable-projects # Set default branchgh repo edit --default-branch main # Rename repositorygh repo rename new-name # Archive repositorygh repo archivegh repo unarchive``` ### Delete Repository ```bash# Delete repositorygh repo delete owner/repo # Confirm without promptgh repo delete owner/repo --yes``` ### Fork Repository ```bash# Fork repositorygh repo fork owner/repo # Fork to organizationgh repo fork owner/repo --org org-name # Clone after forkinggh repo fork owner/repo --clone # Remote name for forkgh repo fork owner/repo --remote-name upstream``` ### Sync Fork ```bash# Sync fork with upstreamgh repo sync # Sync specific branchgh repo sync --branch feature # Force syncgh repo sync --force``` ### Set Default Repository ```bash# Set default repository for current directorygh repo set-default # Set default explicitlygh repo set-default owner/repo # Unset defaultgh repo set-default --unset``` ### Repository Autolinks ```bash# List autolinksgh repo autolink list # Add autolinkgh repo autolink add \  --key-prefix JIRA- \  --url-template https://jira.example.com/browse/<num> # Delete autolinkgh repo autolink delete 12345``` ### Repository Deploy Keys ```bash# List deploy keysgh repo deploy-key list # Add deploy keygh repo deploy-key add ~/.ssh/id_rsa.pub \  --title "Production server" \  --read-only # Delete deploy keygh repo deploy-key delete 12345``` ### Gitignore and License ```bash# View gitignore templategh repo gitignore # View license templategh repo license mit # License with full namegh repo license mit --fullname "John Doe"``` ## Issues (gh issue) ### Create Issue ```bash# Create issue interactivelygh issue create # Create with titlegh issue create --title "Bug: Login not working" # Create with title and bodygh issue create \  --title "Bug: Login not working" \  --body "Steps to reproduce..." # Create with body from filegh issue create --body-file issue.md # Create with labelsgh issue create --title "Fix bug" --labels bug,high-priority # Create with assigneesgh issue create --title "Fix bug" --assignee user1,user2 # Create in specific repositorygh issue create --repo owner/repo --title "Issue title" # Create issue from webgh issue create --web``` ### List Issues ```bash# List all open issuesgh issue list # List all issues (including closed)gh issue list --state all # List closed issuesgh issue list --state closed # Limit resultsgh issue list --limit 50 # Filter by assigneegh issue list --assignee usernamegh issue list --assignee @me # Filter by labelsgh issue list --labels bug,enhancement # Filter by milestonegh issue list --milestone "v1.0" # Search/filtergh issue list --search "is:open is:issue label:bug" # JSON outputgh issue list --json number,title,state,author # Table viewgh issue list --json number,title,labels --jq '.[] | [.number, .title, .labels[].name] | @tsv' # Show comments countgh issue list --json number,title,comments --jq '.[] | [.number, .title, .comments]' # Sort bygh issue list --sort created --order desc``` ### View Issue ```bash# View issuegh issue view 123 # View with commentsgh issue view 123 --comments # View in browsergh issue view 123 --web # JSON outputgh issue view 123 --json title,body,state,labels,comments # View specific fieldsgh issue view 123 --json title --jq '.title'``` ### Edit Issue ```bash# Edit interactivelygh issue edit 123 # Edit titlegh issue edit 123 --title "New title" # Edit bodygh issue edit 123 --body "New description" # Add labelsgh issue edit 123 --add-label bug,high-priority # Remove labelsgh issue edit 123 --remove-label stale # Add assigneesgh issue edit 123 --add-assignee user1,user2 # Remove assigneesgh issue edit 123 --remove-assignee user1 # Set milestonegh issue edit 123 --milestone "v1.0"``` ### Close/Reopen Issue ```bash# Close issuegh issue close 123 # Close with commentgh issue close 123 --comment "Fixed in PR #456" # Reopen issuegh issue reopen 123``` ### Comment on Issue ```bash# Add commentgh issue comment 123 --body "This looks good!" # Edit commentgh issue comment 123 --edit 456789 --body "Updated comment" # Delete commentgh issue comment 123 --delete 456789``` ### Issue Status ```bash# Show issue status summarygh issue status # Status for specific repositorygh issue status --repo owner/repo``` ### Pin/Unpin Issues ```bash# Pin issue (pinned to repo dashboard)gh issue pin 123 # Unpin issuegh issue unpin 123``` ### Lock/Unlock Issue ```bash# Lock conversationgh issue lock 123 # Lock with reasongh issue lock 123 --reason off-topic # Unlockgh issue unlock 123``` ### Transfer Issue ```bash# Transfer to another repositorygh issue transfer 123 --repo owner/new-repo``` ### Delete Issue ```bash# Delete issuegh issue delete 123 # Confirm without promptgh issue delete 123 --yes``` ### Develop Issue (Draft PR) ```bash# Create draft PR from issuegh issue develop 123 # Create in specific branchgh issue develop 123 --branch fix/issue-123 # Create with base branchgh issue develop 123 --base main``` ## Pull Requests (gh pr) ### Create Pull Request ```bash# Create PR interactivelygh pr create # Create with titlegh pr create --title "Feature: Add new functionality" # Create with title and bodygh pr create \  --title "Feature: Add new functionality" \  --body "This PR adds..." # Fill body from templategh pr create --body-file .github/PULL_REQUEST_TEMPLATE.md # Set base branchgh pr create --base main # Set head branch (default: current branch)gh pr create --head feature-branch # Create draft PRgh pr create --draft # Add assigneesgh pr create --assignee user1,user2 # Add reviewersgh pr create --reviewer user1,user2 # Add labelsgh pr create --labels enhancement,feature # Link to issuegh pr create --issue 123 # Create in specific repositorygh pr create --repo owner/repo # Open in browser after creationgh pr create --web``` ### List Pull Requests ```bash# List open PRsgh pr list # List all PRsgh pr list --state all # List merged PRsgh pr list --state merged # List closed (not merged) PRsgh pr list --state closed # Filter by head branchgh pr list --head feature-branch # Filter by base branchgh pr list --base main # Filter by authorgh pr list --author usernamegh pr list --author @me # Filter by assigneegh pr list --assignee username # Filter by labelsgh pr list --labels bug,enhancement # Limit resultsgh pr list --limit 50 # Searchgh pr list --search "is:open is:pr label:review-required" # JSON outputgh pr list --json number,title,state,author,headRefName # Show check statusgh pr list --json number,title,statusCheckRollup --jq '.[] | [.number, .title, .statusCheckRollup[]?.status]' # Sort bygh pr list --sort created --order desc``` ### View Pull Request ```bash# View PRgh pr view 123 # View with commentsgh pr view 123 --comments # View in browsergh pr view 123 --web # JSON outputgh pr view 123 --json title,body,state,author,commits,files # View diffgh pr view 123 --json files --jq '.files[].path' # View with jq querygh pr view 123 --json title,state --jq '"\(.title): \(.state)"'``` ### Checkout Pull Request ```bash# Checkout PR branchgh pr checkout 123 # Checkout with specific branch namegh pr checkout 123 --branch name-123 # Force checkoutgh pr checkout 123 --force``` ### Diff Pull Request ```bash# View PR diffgh pr diff 123 # View diff with colorgh pr diff 123 --color always # Output to filegh pr diff 123 > pr-123.patch # View diff of specific filesgh pr diff 123 --name-only``` ### Merge Pull Request ```bash# Merge PRgh pr merge 123 # Merge with specific methodgh pr merge 123 --mergegh pr merge 123 --squashgh pr merge 123 --rebase # Delete branch after mergegh pr merge 123 --delete-branch # Merge with commentgh pr merge 123 --subject "Merge PR #123" --body "Merging feature" # Merge draft PRgh pr merge 123 --admin # Force merge (skip checks)gh pr merge 123 --admin``` ### Close Pull Request ```bash# Close PR (as draft, not merge)gh pr close 123 # Close with commentgh pr close 123 --comment "Closing due to..."``` ### Reopen Pull Request ```bash# Reopen closed PRgh pr reopen 123``` ### Edit Pull Request ```bash# Edit interactivelygh pr edit 123 # Edit titlegh pr edit 123 --title "New title" # Edit bodygh pr edit 123 --body "New description" # Add labelsgh pr edit 123 --add-label bug,enhancement # Remove labelsgh pr edit 123 --remove-label stale # Add assigneesgh pr edit 123 --add-assignee user1,user2 # Remove assigneesgh pr edit 123 --remove-assignee user1 # Add reviewersgh pr edit 123 --add-reviewer user1,user2 # Remove reviewersgh pr edit 123 --remove-reviewer user1 # Mark as ready for reviewgh pr edit 123 --ready``` ### Ready for Review ```bash# Mark draft PR as readygh pr ready 123``` ### Pull Request Checks ```bash# View PR checksgh pr checks 123 # Watch checks in real-timegh pr checks 123 --watch # Watch interval (seconds)gh pr checks 123 --watch --interval 5``` ### Comment on Pull Request ```bash# Add commentgh pr comment 123 --body "Looks good!" # Comment on specific linegh pr comment 123 --body "Fix this" \  --repo owner/repo \  --head-owner owner --head-branch feature # Edit commentgh pr comment 123 --edit 456789 --body "Updated" # Delete commentgh pr comment 123 --delete 456789``` ### Review Pull Request ```bash# Review PR (opens editor)gh pr review 123 # Approve PRgh pr review 123 --approve --body "LGTM!" # Request changesgh pr review 123 --request-changes \  --body "Please fix these issues" # Comment on PRgh pr review 123 --comment --body "Some thoughts..." # Dismiss reviewgh pr review 123 --dismiss``` ### Update Branch ```bash# Update PR branch with latest base branchgh pr update-branch 123 # Force updategh pr update-branch 123 --force # Use merge strategygh pr update-branch 123 --merge``` ### Lock/Unlock Pull Request ```bash# Lock PR conversationgh pr lock 123 # Lock with reasongh pr lock 123 --reason off-topic # Unlockgh pr unlock 123``` ### Revert Pull Request ```bash# Revert merged PRgh pr revert 123 # Revert with specific branch namegh pr revert 123 --branch revert-pr-123``` ### Pull Request Status ```bash# Show PR status summarygh pr status # Status for specific repositorygh pr status --repo owner/repo``` ## GitHub Actions ### Workflow Runs (gh run) ```bash# List workflow runsgh run list # List for specific workflowgh run list --workflow "ci.yml" # List for specific branchgh run list --branch main # Limit resultsgh run list --limit 20 # JSON outputgh run list --json databaseId,status,conclusion,headBranch # View run detailsgh run view 123456789 # View run with verbose logsgh run view 123456789 --log # View specific jobgh run view 123456789 --job 987654321 # View in browsergh run view 123456789 --web # Watch run in real-timegh run watch 123456789 # Watch with intervalgh run watch 123456789 --interval 5 # Rerun failed rungh run rerun 123456789 # Rerun specific jobgh run rerun 123456789 --job 987654321 # Cancel rungh run cancel 123456789 # Delete rungh run delete 123456789 # Download run artifactsgh run download 123456789 # Download specific artifactgh run download 123456789 --name build # Download to directorygh run download 123456789 --dir ./artifacts``` ### Workflows (gh workflow) ```bash# List workflowsgh workflow list # View workflow detailsgh workflow view ci.yml # View workflow YAMLgh workflow view ci.yml --yaml # View in browsergh workflow view ci.yml --web # Enable workflowgh workflow enable ci.yml # Disable workflowgh workflow disable ci.yml # Run workflow manuallygh workflow run ci.yml # Run with inputsgh workflow run ci.yml \  --raw-field \  version="1.0.0" \  environment="production" # Run from specific branchgh workflow run ci.yml --ref develop``` ### Action Caches (gh cache) ```bash# List cachesgh cache list # List for specific branchgh cache list --branch main # List with limitgh cache list --limit 50 # Delete cachegh cache delete 123456789 # Delete all cachesgh cache delete --all``` ### Action Secrets (gh secret) ```bash# List secretsgh secret list # Set secret (prompts for value)gh secret set MY_SECRET # Set secret from environmentecho "$MY_SECRET" | gh secret set MY_SECRET # Set secret for specific environmentgh secret set MY_SECRET --env production # Set secret for organizationgh secret set MY_SECRET --org orgname # Delete secretgh secret delete MY_SECRET # Delete from environmentgh secret delete MY_SECRET --env production``` ### Action Variables (gh variable) ```bash# List variablesgh variable list # Set variablegh variable set MY_VAR "some-value" # Set variable for environmentgh variable set MY_VAR "value" --env production # Set variable for organizationgh variable set MY_VAR "value" --org orgname # Get variable valuegh variable get MY_VAR # Delete variablegh variable delete MY_VAR # Delete from environmentgh variable delete MY_VAR --env production``` ## Projects (gh project) ```bash# List projectsgh project list # List for ownergh project list --owner owner # Open projectsgh project list --open # View projectgh project view 123 # View project itemsgh project view 123 --format json # Create projectgh project create --title "My Project" # Create in organizationgh project create --title "Project" --org orgname # Create with readmegh project create --title "Project" --readme "Description here" # Edit projectgh project edit 123 --title "New Title" # Delete projectgh project delete 123 # Close projectgh project close 123 # Copy projectgh project copy 123 --owner target-owner --title "Copy" # Mark templategh project mark-template 123 # List fieldsgh project field-list 123 # Create fieldgh project field-create 123 --title "Status" --datatype single_select # Delete fieldgh project field-delete 123 --id 456 # List itemsgh project item-list 123 # Create itemgh project item-create 123 --title "New item" # Add item to projectgh project item-add 123 --owner-owner --repo repo --issue 456 # Edit itemgh project item-edit 123 --id 456 --title "Updated title" # Delete itemgh project item-delete 123 --id 456 # Archive itemgh project item-archive 123 --id 456 # Link itemsgh project link 123 --id 456 --link-id 789 # Unlink itemsgh project unlink 123 --id 456 --link-id 789 # View project in browsergh project view 123 --web``` ## Releases (gh release) ```bash# List releasesgh release list # View latest releasegh release view # View specific releasegh release view v1.0.0 # View in browsergh release view v1.0.0 --web # Create releasegh release create v1.0.0 \  --notes "Release notes here" # Create release with notes from filegh release create v1.0.0 --notes-file notes.md # Create release with targetgh release create v1.0.0 --target main # Create release as draftgh release create v1.0.0 --draft # Create pre-releasegh release create v1.0.0 --prerelease # Create release with titlegh release create v1.0.0 --title "Version 1.0.0" # Upload asset to releasegh release upload v1.0.0 ./file.tar.gz # Upload multiple assetsgh release upload v1.0.0 ./file1.tar.gz ./file2.tar.gz # Upload with label (casing sensitive)gh release upload v1.0.0 ./file.tar.gz --casing # Delete releasegh release delete v1.0.0 # Delete with cleanup taggh release delete v1.0.0 --yes # Delete specific assetgh release delete-asset v1.0.0 file.tar.gz # Download release assetsgh release download v1.0.0 # Download specific assetgh release download v1.0.0 --pattern "*.tar.gz" # Download to directorygh release download v1.0.0 --dir ./downloads # Download archive (zip/tar)gh release download v1.0.0 --archive zip # Edit releasegh release edit v1.0.0 --notes "Updated notes" # Verify release signaturegh release verify v1.0.0 # Verify specific assetgh release verify-asset v1.0.0 file.tar.gz``` ## Gists (gh gist) ```bash# List gistsgh gist list # List all gists (including private)gh gist list --public # Limit resultsgh gist list --limit 20 # View gistgh gist view abc123 # View gist filesgh gist view abc123 --files # Create gistgh gist create script.py # Create gist with descriptiongh gist create script.py --desc "My script" # Create public gistgh gist create script.py --public # Create multi-file gistgh gist create file1.py file2.py # Create from stdinecho "print('hello')" | gh gist create # Edit gistgh gist edit abc123 # Delete gistgh gist delete abc123 # Rename gist filegh gist rename abc123 --filename old.py new.py # Clone gistgh gist clone abc123 # Clone to directorygh gist clone abc123 my-directory``` ## Codespaces (gh codespace) ```bash# List codespacesgh codespace list # Create codespacegh codespace create # Create with specific repositorygh codespace create --repo owner/repo # Create with branchgh codespace create --branch develop # Create with specific machinegh codespace create --machine premiumLinux # View codespace detailsgh codespace view # SSH into codespacegh codespace ssh # SSH with specific commandgh codespace ssh --command "cd /workspaces && ls" # Open codespace in browsergh codespace code # Open in VS Codegh codespace code --codec # Open with specific pathgh codespace code --path /workspaces/repo # Stop codespacegh codespace stop # Delete codespacegh codespace delete # View logsgh codespace logs --tail 100 # View portsgh codespace ports # Forward portgh codespace cp 8080:8080 # Rebuild codespacegh codespace rebuild # Edit codespacegh codespace edit --machine standardLinux # Jupyter supportgh codespace jupyter # Copy files to/from codespacegh codespace cp file.txt :/workspaces/file.txtgh codespace cp :/workspaces/file.txt ./file.txt``` ## Organizations (gh org) ```bash# List organizationsgh org list # List for usergh org list --user username # JSON outputgh org list --json login,name,description # View organizationgh org view orgname # View organization membersgh org view orgname --json members --jq '.members[] | .login'``` ## Search (gh search) ```bash# Search codegh search code "TODO" # Search in specific repositorygh search code "TODO" --repo owner/repo # Search commitsgh search commits "fix bug" # Search issuesgh search issues "label:bug state:open" # Search PRsgh search prs "is:open is:pr review:required" # Search repositoriesgh search repos "stars:>1000 language:python" # Limit resultsgh search repos "topic:api" --limit 50 # JSON outputgh search repos "stars:>100" --json name,description,stargazers # Order resultsgh search repos "language:rust" --order desc --sort stars # Search with extensionsgh search code "import" --extension py # Web search (open in browser)gh search prs "is:open" --web``` ## Labels (gh label) ```bash# List labelsgh label list # Create labelgh label create bug --color "d73a4a" --description "Something isn't working" # Create with hex colorgh label create enhancement --color "#a2eeef" # Edit labelgh label edit bug --name "bug-report" --color "ff0000" # Delete labelgh label delete bug # Clone labels from repositorygh label clone owner/repo # Clone to specific repositorygh label clone owner/repo --repo target/repo``` ## SSH Keys (gh ssh-key) ```bash# List SSH keysgh ssh-key list # Add SSH keygh ssh-key add ~/.ssh/id_rsa.pub --title "My laptop" # Add key with typegh ssh-key add ~/.ssh/id_ed25519.pub --type "authentication" # Delete SSH keygh ssh-key delete 12345 # Delete by titlegh ssh-key delete --title "My laptop"``` ## GPG Keys (gh gpg-key) ```bash# List GPG keysgh gpg-key list # Add GPG keygh gpg-key add ~/.ssh/id_rsa.pub # Delete GPG keygh gpg-key delete 12345 # Delete by key IDgh gpg-key delete ABCD1234``` ## Status (gh status) ```bash# Show status overviewgh status # Status for specific repositoriesgh status --repo owner/repo # JSON outputgh status --json``` ## Configuration (gh config) ```bash# List all configgh config list # Get specific valuegh config get editor # Set valuegh config set editor vim # Set git protocolgh config set git_protocol ssh # Clear cachegh config clear-cache # Set prompt behaviorgh config set prompt disabledgh config set prompt enabled``` ## Extensions (gh extension) ```bash# List installed extensionsgh extension list # Search extensionsgh extension search github # Install extensiongh extension install owner/extension-repo # Install from branchgh extension install owner/extension-repo --branch develop # Upgrade extensiongh extension upgrade extension-name # Remove extensiongh extension remove extension-name # Create new extensiongh extension create my-extension # Browse extensionsgh extension browse # Execute extension commandgh extension exec my-extension --arg value``` ## Aliases (gh alias) ```bash# List aliasesgh alias list # Set aliasgh alias set prview 'pr view --web' # Set shell aliasgh alias set co 'pr checkout' --shell # Delete aliasgh alias delete prview # Import aliasesgh alias import ./aliases.sh``` ## API Requests (gh api) ```bash# Make API requestgh api /user # Request with methodgh api --method POST /repos/owner/repo/issues \  --field title="Issue title" \  --field body="Issue body" # Request with headersgh api /user \  --header "Accept: application/vnd.github.v3+json" # Request with paginationgh api /user/repos --paginate # Raw output (no formatting)gh api /user --raw # Include headers in outputgh api /user --include # Silent mode (no progress output)gh api /user --silent # Input from filegh api --input request.json # jq query on responsegh api /user --jq '.login' # Field from responsegh api /repos/owner/repo --jq '.stargazers_count' # GitHub Enterprisegh api /user --hostname enterprise.internal # GraphQL querygh api graphql \  -f query='  {    viewer {      login      repositories(first: 5) {        nodes {          name        }      }    }  }'``` ## Rulesets (gh ruleset) ```bash# List rulesetsgh ruleset list # View rulesetgh ruleset view 123 # Check rulesetgh ruleset check --branch feature # Check specific repositorygh ruleset check --repo owner/repo --branch main``` ## Attestations (gh attestation) ```bash# Download attestationgh attestation download owner/repo \  --artifact-id 123456 # Verify attestationgh attestation verify owner/repo # Get trusted rootgh attestation trusted-root``` ## Completion (gh completion) ```bash# Generate shell completiongh completion -s bash > ~/.gh-complete.bashgh completion -s zsh > ~/.gh-complete.zshgh completion -s fish > ~/.gh-complete.fishgh completion -s powershell > ~/.gh-complete.ps1 # Shell-specific instructionsgh completion --shell=bashgh completion --shell=zsh``` ## Preview (gh preview) ```bash# List preview featuresgh preview # Run preview scriptgh preview prompter``` ## Agent Tasks (gh agent-task) ```bash# List agent tasksgh agent-task list # View agent taskgh agent-task view 123 # Create agent taskgh agent-task create --description "My task"``` ## Global Flags | Flag                       | Description                            || -------------------------- | -------------------------------------- || `--help` / `-h`            | Show help for command                  || `--version`                | Show gh version                        || `--repo [HOST/]OWNER/REPO` | Select another repository              || `--hostname HOST`          | GitHub hostname                        || `--jq EXPRESSION`          | Filter JSON output                     || `--json FIELDS`            | Output JSON with specified fields      || `--template STRING`        | Format JSON using Go template          || `--web`                    | Open in browser                        || `--paginate`               | Make additional API calls              || `--verbose`                | Show verbose output                    || `--debug`                  | Show debug output                      || `--timeout SECONDS`        | Maximum API request duration           || `--cache CACHE`            | Cache control (default, force, bypass) | ## Output Formatting ### JSON Output ```bash# Basic JSONgh repo view --json name,description # Nested fieldsgh repo view --json owner,name --jq '.owner.login + "/" + .name' # Array operationsgh pr list --json number,title --jq '.[] | select(.number > 100)' # Complex queriesgh issue list --json number,title,labels \  --jq '.[] | {number, title: .title, tags: [.labels[].name]}'``` ### Template Output ```bash# Custom templategh repo view \  --template '{{.name}}: {{.description}}' # Multiline templategh pr view 123 \  --template 'Title: {{.title}}Author: {{.author.login}}State: {{.state}}'``` ## Common Workflows ### Create PR from Issue ```bash# Create branch from issuegh issue develop 123 --branch feature/issue-123 # Make changes, commit, pushgit add .git commit -m "Fix issue #123"git push # Create PR linking to issuegh pr create --title "Fix #123" --body "Closes #123"``` ### Bulk Operations ```bash# Close multiple issuesgh issue list --search "label:stale" \  --json number \  --jq '.[].number' | \  xargs -I {} gh issue close {} --comment "Closing as stale" # Add label to multiple PRsgh pr list --search "review:required" \  --json number \  --jq '.[].number' | \  xargs -I {} gh pr edit {} --add-label needs-review``` ### Repository Setup Workflow ```bash# Create repository with initial setupgh repo create my-project --public \  --description "My awesome project" \  --clone \  --gitignore python \  --license mit cd my-project # Set up branchesgit checkout -b developgit push -u origin develop # Create labelsgh label create bug --color "d73a4a" --description "Bug report"gh label create enhancement --color "a2eeef" --description "Feature request"gh label create documentation --color "0075ca" --description "Documentation"``` ### CI/CD Workflow ```bash# Run workflow and waitRUN_ID=$(gh workflow run ci.yml --ref main --jq '.databaseId') # Watch the rungh run watch "$RUN_ID" # Download artifacts on completiongh run download "$RUN_ID" --dir ./artifacts``` ### Fork Sync Workflow ```bash# Fork repositorygh repo fork original/repo --clone cd repo # Add upstream remotegit remote add upstream https://github.com/original/repo.git # Sync forkgh repo sync # Or manual syncgit fetch upstreamgit checkout maingit merge upstream/maingit push origin main``` ## Environment Setup ### Shell Integration ```bash# Add to ~/.bashrc or ~/.zshrceval "$(gh completion -s bash)"  # or zsh/fish # Create useful aliasesalias gs='gh status'alias gpr='gh pr view --web'alias gir='gh issue view --web'alias gco='gh pr checkout'``` ### Git Configuration ```bash# Use gh as credential helpergh auth setup-git # Set gh as default for repo operationsgit config --global credential.helper 'gh !gh auth setup-git' # Or manuallygit config --global credential.helper github``` ## Best Practices 1. **Authentication**: Use environment variables for automation    ```bash   export GH_TOKEN=$(gh auth token)   ``` 2. **Default Repository**: Set default to avoid repetition    ```bash   gh repo set-default owner/repo   ``` 3. **JSON Parsing**: Use jq for complex data extraction    ```bash   gh pr list --json number,title --jq '.[] | select(.title | contains("fix"))'   ``` 4. **Pagination**: Use --paginate for large result sets    ```bash   gh issue list --state all --paginate   ``` 5. **Caching**: Use cache control for frequently accessed data   ```bash   gh api /user --cache force   ``` ## Getting Help ```bash# General helpgh --help # Command helpgh pr --helpgh issue create --help # Help topicsgh help formattinggh help environmentgh help exit-codesgh help accessibility``` ## References - Official Manual: https://cli.github.com/manual/- GitHub Docs: https://docs.github.com/en/github-cli- REST API: https://docs.github.com/en/rest- GraphQL API: https://docs.github.com/en/graphql