当前位置: 首页 > Skill >

Github CLI Complete

Github CLI Complete

Github CLI Complete

在 cli‑trunk 上使用 GitHub CLI (gh) 的完整技能:包括完整命令映射、子命令、使用模式、JSON 输出以及Issues、PR 等实用工作流。

1.0.0 2026.11.25 702
获取Skill文件查看使用说明
作 者:叶澄 许可证: 更新时间:2026.11.25
本文目录展开

Skill: Complete GitHub CLI (cli-trunk)

Use 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.

Goal

  • Solve GitHub tasks with precise and repeatable gh commands.
  • Pick the right command family by domain: PRs, Issues, repositories, Actions, releases, configuration, security, and API.
  • Prefer structured output (--json, --jq) whenever automation is needed.

Install GitHub CLI on Linux

Use official packages when possible.

Debian and Ubuntu (official repository)

(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

RPM-based distros (DNF5)

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

RPM-based distros (DNF4)

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

Amazon Linux 2 (yum)

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

openSUSE and SUSE (zypper)

sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo
sudo zypper ref
sudo zypper install gh

Alternative official methods

  • Homebrew on Linux:
brew install gh
  • Precompiled binaries: https://github.com/cli/cli/releases/latest

Verify installation

gh --version

Login and Authentication (Do This First)

Most gh commands require authentication. Use one of these methods.

Interactive login (recommended for local development)

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.

GitHub Enterprise Server login

gh auth login --hostname github.example.com
gh auth status --hostname github.example.com

Token-based login (CI/non-interactive)

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.

Common auth lifecycle commands

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:

  • Official Linux installation documentation in this repo: cli-trunk/docs/install_linux.md.
  • Recommended official package host: https://cli.github.com/

Operating Rules

  • If you are not inside a local git repository, use --repo OWNER/REPO or a full URL.
  • For automation, prefer:
    • --json <fields> for structured output.
    • --jq '<filter>' for JSON filtering.
  • For large listings and searches, cap output with --limit.
  • If no dedicated subcommand exists, use gh api.

Syntax and Patterns

  • Required placeholder: <value>.
  • Optional argument: [--flag] or [<arg>].
  • Exclusive alternatives: {a | b} or [a | b] depending on required vs optional.
  • Repeatable arguments: <arg>....

Root Commands (Complete Map)

  • 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)

Subcommands by Domain

Pull Requests: gh pr

  • list, create, status
  • view, diff, checkout, checks, review, merge, update-branch, ready, comment, close, reopen, revert, edit, lock, unlock

Examples:

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

Issues: gh issue

  • list, create, status
  • view, comment, close, reopen, edit, develop, lock, unlock, pin, unpin, transfer, delete

Examples:

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"

Repositories: gh repo

  • list, create
  • view, clone, fork, set-default, sync, edit, deploy-key, license, gitignore, rename, archive, unarchive, delete, credits, garden, autolink

Examples:

gh repo view OWNER/REPO --web
gh repo list OWNER --limit 100
gh repo sync OWNER/REPO

Releases: gh release

  • list, create
  • view, edit, upload, download, delete, delete-asset, verify, verify-asset

Examples:

gh release list --repo OWNER/REPO
gh release view v1.2.3 --repo OWNER/REPO
gh release download v1.2.3 --repo OWNER/REPO

GitHub Actions: gh run, gh workflow, gh cache

  • gh run: list, view, rerun, download, watch, cancel, delete
  • gh workflow: list, enable, disable, view, run
  • gh cache: list, delete

Examples:

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

Authentication and Config: gh auth, gh config

  • gh auth: login, logout, status, refresh, git-credential, setup-git, token, switch
  • gh config: get, set, list, clear-cache

Examples:

gh auth status
gh auth refresh -s repo,read:org
gh config set git_protocol ssh

Projects: gh project

  • Project-level: list, create, copy, close, delete, edit, link, view, mark-template, unlink
  • Items: item-list, item-create, item-add, item-edit, item-archive, item-delete
  • Fields: field-list, field-create, field-delete

Examples:

gh project list --owner ORG
gh project view 1 --owner ORG --web
gh project item-list 1 --owner ORG

Secrets and Variables: gh secret, gh variable

  • gh secret: list, set, delete
  • gh variable: get, set, list, delete

Examples:

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"

Global Search: gh search

  • code, commits, issues, prs, repos

Examples:

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 --%.

Gists, Labels, and Keys

  • gh gist: clone, create, list, view, edit, delete, rename
  • gh label: list, create, clone, edit, delete
  • gh ssh-key: add, delete, list
  • gh gpg-key: add, delete, list

Codespaces: gh codespace (gh cs)

  • code, create, edit, delete, jupyter, list, view, logs, ports, ssh, cp, stop, select, rebuild

Examples:

gh cs list
gh cs ssh -c <codespace>
gh cs ports -c <codespace>

Extensions: gh extension (gh ext)

  • search, list, install, upgrade, remove, browse, exec, create

Examples:

gh ext search
gh ext install owner/gh-myext
gh ext exec myext -- --help

Rulesets, Org, Attestation, Agent Task

  • gh ruleset: list, view, check
  • gh org: list
  • gh attestation: download, inspect, verify, trustedroot
  • gh agent-task (preview): list, create, view

Examples:

gh ruleset list --repo OWNER/REPO
gh at verify -R OWNER/REPO ./artifact.zip
gh agent-task list

Useful Standalone Commands

  • 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 licenses

Complete Command Explanations (All Root Commands)

This section explains each root command in plain language and points to its key subcommands.

Collaboration and Code Review

  • gh pr: manage pull requests from creation to merge.
    • Main subcommands: 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.
    • Main subcommands: list, view, create, status, comment, edit, develop, close, reopen, transfer, delete, pin, unpin, lock, unlock.
  • gh label: create and maintain repository labels.
    • Main subcommands: list, create, clone, edit, delete.

Repositories and Releases

  • gh repo: administer repositories.
    • Main subcommands: 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.
    • Main subcommands: list, view, create, edit, upload, download, delete, delete-asset, verify, verify-asset.
  • gh gist: work with GitHub Gists.
    • Main subcommands: list, view, create, edit, rename, clone, delete.

Actions, CI, and Workflow Automation

  • gh run: inspect and control workflow runs.
    • Main subcommands: list, view, watch, rerun, download, cancel, delete.
  • gh workflow: inspect and trigger workflow files.
    • Main subcommands: list, view, run, enable, disable.
  • gh cache: manage GitHub Actions cache entries.
    • Main subcommands: list, delete.

Projects, Organization, and Governance

  • gh project: manage GitHub Projects (project, item, and field operations).
    • Main subcommands: list, view, create, edit, delete, copy, close, link, unlink, mark-template, plus item-* and field-* families.
  • gh org: organization-level operations.
    • Main subcommands: list.
  • gh ruleset: inspect and evaluate repository rulesets.
    • Main subcommands: list, view, check.

Security, Secrets, and Identity

  • gh auth: account and token authentication lifecycle.
    • Main subcommands: login, status, refresh, setup-git, token, switch, logout, git-credential.
  • gh secret: manage secrets at repository/org/environment/user scope.
    • Main subcommands: list, set, delete.
  • gh variable: manage Actions/Dependabot variables.
    • Main subcommands: list, get, set, delete.
  • gh ssh-key: manage SSH keys on your GitHub account.
    • Main subcommands: list, add, delete.
  • gh gpg-key: manage GPG keys on your GitHub account.
    • Main subcommands: list, add, delete.
  • gh attestation: download, inspect, and verify artifact attestations.
    • Main subcommands: download, inspect, verify, trustedroot.

Discovery and Navigation

  • gh search: search code, commits, issues, PRs, and repositories on GitHub.
    • Main subcommands: code, commits, issues, prs, repos.
  • gh browse: open repo pages, files, issues, PRs, commits, and settings in your browser.
    • Useful flags: --branch, --commit, --settings, --wiki, --projects, --actions, --blame, --no-browser.
  • gh status: aggregated dashboard of assigned issues, PRs, review requests, mentions, and activity.
    • Useful flags: --org, --exclude.

Extensions, Aliases, and Developer Experience

  • gh extension (gh ext): discover/install/manage CLI extensions.
    • Main subcommands: search, list, install, upgrade, remove, browse, exec, create.
  • gh alias: create and manage command shortcuts.
    • Main subcommands: set, list, delete, import.
  • gh completion: generate shell completion scripts.
    • Main usage: gh completion -s bash|zsh|fish|powershell.
  • gh config: read and update CLI behavior.
    • Main subcommands: get, set, list, clear-cache.

API and Advanced Power Tools

  • gh api: send authenticated REST/GraphQL requests when built-in subcommands are not enough.
    • Important options: --method, --field, --raw-field, --input, --paginate, --slurp, --jq, --template, --header, --hostname, --preview.
  • gh codespace (gh cs): manage Codespaces.
    • Main subcommands: 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.
    • Main subcommands: create, list, view.
  • gh copilot (preview): run GitHub Copilot CLI via gh.

Informational and Hidden Commands

  • 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.

Advanced API Usage

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 } } } }'

Quick Recipes by Intent

  • Show PRs with failing checks:
gh pr list --repo OWNER/REPO --json number,title,statusCheckRollup --jq '.[] | select(any(.statusCheckRollup[]?; .conclusion=="FAILURE")) | {number,title}'
  • Get open issues in a compact format:
gh issue list --repo OWNER/REPO --json number,title,author --jq '.[] | "#(.number) (.title) (@(.author.login))"'
  • Fast Actions diagnosis:
gh run list --repo OWNER/REPO --limit 5
gh run view <run-id> --repo OWNER/REPO --log-failed

Command Selection Heuristic

  • If the task is about PRs or Issues, start with gh pr or gh issue.
  • If it is CI/CD related, use gh run, gh workflow, and gh cache.
  • If it is repository administration, use gh repo.
  • If it is governance/security, use gh ruleset, gh secret, gh variable, and gh attestation.
  • If no clear coverage exists, use gh api.

Diagnostics and Common Errors

  • Authentication issues: run gh auth status, then gh auth login or gh auth refresh -s <scopes>.
  • Unresolved repository context: run inside a valid git repo or pass --repo OWNER/REPO.
  • Ambiguous PR/Issue selectors: use full URL or explicit number.
  • In scripts, avoid human-oriented output; use --json + --jq.

Completeness Criterion

This skill covers the full command catalog visible in pkg/cmd/root/root.go and subcommands registered in pkg/cmd/* modules within cli-trunk.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
Skill 文件
  • SKILL.md
    • Skill: Complete GitHub CLI (cli-trunk)
    • Goal
    • Install GitHub CLI on Linux
      • Debian and Ubuntu (official repository)
      • RPM-based distros (DNF5)
      • RPM-based distros (DNF4)
      • Amazon Linux 2 (yum)
      • openSUSE and SUSE (zypper)
      • Alternative official methods
      • Verify installation
    • Login and Authentication (Do This First)
      • Interactive login (recommended for local development)
      • GitHub Enterprise Server login
      • Token-based login (CI/non-interactive)
      • Common auth lifecycle commands
    • Operating Rules
    • Syntax and Patterns
    • Root Commands (Complete Map)
    • Subcommands by Domain
      • Pull Requests: gh pr
      • Issues: gh issue
      • Repositories: gh repo
      • Releases: gh release
      • GitHub Actions: gh run, gh workflow, gh cache
      • Authentication and Config: gh auth, gh config
      • Projects: gh project
      • Secrets and Variables: gh secret, gh variable
      • Global Search: gh search
      • Gists, Labels, and Keys
      • Codespaces: gh codespace (gh cs)
      • Extensions: gh extension (gh ext)
      • Rulesets, Org, Attestation, Agent Task
      • Useful Standalone Commands
    • Complete Command Explanations (All Root Commands)
      • Collaboration and Code Review
      • Repositories and Releases
      • Actions, CI, and Workflow Automation
      • Projects, Organization, and Governance
      • Security, Secrets, and Identity
      • Discovery and Navigation
      • Extensions, Aliases, and Developer Experience
      • API and Advanced Power Tools
      • Informational and Hidden Commands
    • Advanced API Usage
    • Quick Recipes by Intent
    • Command Selection Heuristic
    • Diagnostics and Common Errors
    • Completeness Criterion
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期