Install
openclaw skills install gh-completeComplete skill for operating GitHub CLI (gh) on cli-trunk: full command map, subcommands, usage patterns, JSON output, and practical workflows for Issues, PRs, Actions, Repos, Releases, Projects, Secrets, Variables, Codespaces, Extensions, and API.
openclaw skills install gh-completeUse gh to operate GitHub end-to-end from the command line. This skill is built from the cli-trunk source code and is meant for practical, reproducible command execution.
gh commands.--json, --jq) whenever automation is needed.Use official packages when possible.
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
Upgrade:
sudo apt update
sudo apt install gh
sudo dnf install dnf5-plugins
sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli
Upgrade:
sudo dnf update gh
sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli
type -p yum-config-manager >/dev/null || sudo yum install yum-utils
sudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo yum install gh
sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo
sudo zypper ref
sudo zypper install gh
brew install gh
gh --version
Most gh commands require authentication. Use one of these methods.
gh auth login
gh auth status
gh auth setup-git
What this does:
gh auth login: signs you in (browser/device flow) and stores credentials.gh auth status: confirms active account, host, and token scopes.gh auth setup-git: configures git credential helper integration.gh auth login --hostname github.example.com
gh auth status --hostname github.example.com
export GH_TOKEN=<your_token>
gh auth status
Notes:
GH_TOKEN / GITHUB_TOKEN are used for github.com.GH_ENTERPRISE_TOKEN / GITHUB_ENTERPRISE_TOKEN are used for GHES hosts.gh auth refresh -s repo,read:org,project
gh auth switch
gh auth logout
gh auth refresh: updates token scopes.gh auth switch: switches between authenticated accounts/hosts.gh auth logout: removes stored credentials for a host.Notes:
cli-trunk/docs/install_linux.md.--repo OWNER/REPO or a full URL.--json <fields> for structured output.--jq '<filter>' for JSON filtering.--limit.gh api.<value>.[--flag] or [<arg>].{a | b} or [a | b] depending on required vs optional.<arg>....gh pr (pull requests)gh issue (issues)gh repo (repositories)gh release (releases)gh run (workflow runs)gh workflow (workflows)gh auth (authentication)gh config (configuration)gh project (GitHub Projects)gh secret (secrets)gh variable (Actions variables)gh search (global search)gh gist (gists)gh extension / gh ext (extensions)gh codespace / gh cs (Codespaces)gh org (organizations)gh ruleset / gh rs (rulesets)gh cache (Actions cache)gh label (labels)gh ssh-key (SSH keys)gh gpg-key (GPG keys)gh attestation / gh at (artifact attestations)gh agent-task / gh agent (preview)gh api (REST/GraphQL API)gh browse (open in browser)gh status (cross-repo status)gh copilot (preview)gh completion (shell completion)gh licenses (third-party licenses)gh preview (experimental commands)gh actions (hidden; guidance text)gh accessibility / gh a11y (hidden; accessibility)gh credits (hidden)gh version (hidden)gh prlist, create, statusview, diff, checkout, checks, review, merge, update-branch, ready, comment, close, reopen, revert, edit, lock, unlockExamples:
gh pr list --repo OWNER/REPO --limit 20
gh pr view 123 --repo OWNER/REPO --json number,title,state,author
gh pr checks 123 --repo OWNER/REPO
gh issuelist, create, statusview, comment, close, reopen, edit, develop, lock, unlock, pin, unpin, transfer, deleteExamples:
gh issue list --repo OWNER/REPO --limit 50
gh issue view 456 --repo OWNER/REPO --json number,title,state,labels
gh issue create --repo OWNER/REPO --title "Bug" --body "Details"
gh repolist, createview, clone, fork, set-default, sync, edit, deploy-key, license, gitignore, rename, archive, unarchive, delete, credits, garden, autolinkExamples:
gh repo view OWNER/REPO --web
gh repo list OWNER --limit 100
gh repo sync OWNER/REPO
gh releaselist, createview, edit, upload, download, delete, delete-asset, verify, verify-assetExamples:
gh release list --repo OWNER/REPO
gh release view v1.2.3 --repo OWNER/REPO
gh release download v1.2.3 --repo OWNER/REPO
gh run, gh workflow, gh cachegh run: list, view, rerun, download, watch, cancel, deletegh workflow: list, enable, disable, view, rungh cache: list, deleteExamples:
gh run list --repo OWNER/REPO --limit 10
gh run view <run-id> --repo OWNER/REPO --log-failed
gh workflow run ci.yml --repo OWNER/REPO
gh auth, gh configgh auth: login, logout, status, refresh, git-credential, setup-git, token, switchgh config: get, set, list, clear-cacheExamples:
gh auth status
gh auth refresh -s repo,read:org
gh config set git_protocol ssh
gh projectlist, create, copy, close, delete, edit, link, view, mark-template, unlinkitem-list, item-create, item-add, item-edit, item-archive, item-deletefield-list, field-create, field-deleteExamples:
gh project list --owner ORG
gh project view 1 --owner ORG --web
gh project item-list 1 --owner ORG
gh secret, gh variablegh secret: list, set, deletegh variable: get, set, list, deleteExamples:
gh secret list --repo OWNER/REPO
gh secret set MY_SECRET --repo OWNER/REPO --body "value"
gh variable set MY_VAR --repo OWNER/REPO --body "value"
gh searchcode, commits, issues, prs, reposExamples:
gh search prs "is:open review:required org:ORG"
gh search code "function NewCmd" --repo OWNER/REPO
PowerShell note: for queries containing negative qualifiers (-qualifier), use stop-parsing with --%.
gh gist: clone, create, list, view, edit, delete, renamegh label: list, create, clone, edit, deletegh ssh-key: add, delete, listgh gpg-key: add, delete, listgh codespace (gh cs)code, create, edit, delete, jupyter, list, view, logs, ports, ssh, cp, stop, select, rebuildExamples:
gh cs list
gh cs ssh -c <codespace>
gh cs ports -c <codespace>
gh extension (gh ext)search, list, install, upgrade, remove, browse, exec, createExamples:
gh ext search
gh ext install owner/gh-myext
gh ext exec myext -- --help
gh ruleset: list, view, checkgh org: listgh attestation: download, inspect, verify, trustedrootgh agent-task (preview): list, create, viewExamples:
gh ruleset list --repo OWNER/REPO
gh at verify -R OWNER/REPO ./artifact.zip
gh agent-task list
gh browse (issues, PRs, paths, commits, settings, releases, wiki, actions)gh api (authenticated REST/GraphQL)gh status (issues, PRs, mentions, activity)gh copilot (preview)gh completion -s {bash|zsh|fish|powershell}gh licensesThis section explains each root command in plain language and points to its key subcommands.
gh pr: manage pull requests from creation to merge.
list, view, create, status, checks, review, merge, checkout, diff, update-branch, ready, comment, edit, close, reopen, revert, lock, unlock.gh issue: manage issue lifecycle and discussion.
list, view, create, status, comment, edit, develop, close, reopen, transfer, delete, pin, unpin, lock, unlock.gh label: create and maintain repository labels.
list, create, clone, edit, delete.gh repo: administer repositories.
list, view, create, clone, fork, sync, set-default, edit, rename, archive, unarchive, delete, autolink, deploy-key, license, gitignore, credits, garden.gh release: create, publish, inspect, and verify releases.
list, view, create, edit, upload, download, delete, delete-asset, verify, verify-asset.gh gist: work with GitHub Gists.
list, view, create, edit, rename, clone, delete.gh run: inspect and control workflow runs.
list, view, watch, rerun, download, cancel, delete.gh workflow: inspect and trigger workflow files.
list, view, run, enable, disable.gh cache: manage GitHub Actions cache entries.
list, delete.gh project: manage GitHub Projects (project, item, and field operations).
list, view, create, edit, delete, copy, close, link, unlink, mark-template, plus item-* and field-* families.gh org: organization-level operations.
list.gh ruleset: inspect and evaluate repository rulesets.
list, view, check.gh auth: account and token authentication lifecycle.
login, status, refresh, setup-git, token, switch, logout, git-credential.gh secret: manage secrets at repository/org/environment/user scope.
list, set, delete.gh variable: manage Actions/Dependabot variables.
list, get, set, delete.gh ssh-key: manage SSH keys on your GitHub account.
list, add, delete.gh gpg-key: manage GPG keys on your GitHub account.
list, add, delete.gh attestation: download, inspect, and verify artifact attestations.
download, inspect, verify, trustedroot.gh search: search code, commits, issues, PRs, and repositories on GitHub.
code, commits, issues, prs, repos.gh browse: open repo pages, files, issues, PRs, commits, and settings in your browser.
--branch, --commit, --settings, --wiki, --projects, --actions, --blame, --no-browser.gh status: aggregated dashboard of assigned issues, PRs, review requests, mentions, and activity.
--org, --exclude.gh extension (gh ext): discover/install/manage CLI extensions.
search, list, install, upgrade, remove, browse, exec, create.gh alias: create and manage command shortcuts.
set, list, delete, import.gh completion: generate shell completion scripts.
gh completion -s bash|zsh|fish|powershell.gh config: read and update CLI behavior.
get, set, list, clear-cache.gh api: send authenticated REST/GraphQL requests when built-in subcommands are not enough.
--method, --field, --raw-field, --input, --paginate, --slurp, --jq, --template, --header, --hostname, --preview.gh codespace (gh cs): manage Codespaces.
list, create, view, edit, logs, ports, ssh, stop, delete, rebuild, code, cp, jupyter, select.gh agent-task (gh agent) (preview): create/list/view Copilot agent tasks.
create, list, view.gh copilot (preview): run GitHub Copilot CLI via gh.gh licenses: view third-party license info for the current gh build.gh preview: run unstable preview commands (currently includes preview tools such as prompter).gh actions (hidden): informational help text about Actions command groups.gh accessibility / gh a11y (hidden): accessibility guidance and related configuration pointers.gh credits (hidden): credits animation/static credits.gh version (hidden): print current gh version/build info.Use gh api when no dedicated subcommand exists or when you need custom payload/query control.
REST examples:
gh api repos/{owner}/{repo}/pulls/123
gh api repos/{owner}/{repo}/issues -X GET -f state=open -f per_page=100
GraphQL examples:
gh api graphql -f query='query { viewer { login } }'
gh api graphql --paginate -f query='query($endCursor: String) { viewer { repositories(first: 100, after: $endCursor) { nodes { nameWithOwner } pageInfo { hasNextPage endCursor } } } }'
gh pr list --repo OWNER/REPO --json number,title,statusCheckRollup --jq '.[] | select(any(.statusCheckRollup[]?; .conclusion=="FAILURE")) | {number,title}'
gh issue list --repo OWNER/REPO --json number,title,author --jq '.[] | "#\(.number) \(.title) (@\(.author.login))"'
gh run list --repo OWNER/REPO --limit 5
gh run view <run-id> --repo OWNER/REPO --log-failed
gh pr or gh issue.gh run, gh workflow, and gh cache.gh repo.gh ruleset, gh secret, gh variable, and gh attestation.gh api.gh auth status, then gh auth login or gh auth refresh -s <scopes>.--repo OWNER/REPO.--json + --jq.This skill covers the full command catalog visible in pkg/cmd/root/root.go and subcommands registered in pkg/cmd/* modules within cli-trunk.