選項

適用於 GitHub CLI 自動化:gh 指令、儲存庫資訊、工作流程觸發器、GitHub 搜尋、Codespaces、PR 狀態、問題、儲存庫瀏覽,或命令列 GitHub 任務。

...展開全部
34
更新時間 2026-06-29

關於cli-gh

cli-gh 技能為 GitHub CLI (gh) 操作提供專業指引,讓開發者能直接透過終端機管理整個 GitHub 工作流程。 此技能簡化了與 GitHub 的命令列互動,讓開發者無需在執行常見儲存庫任務時,來回切換終端機與瀏覽器。它專注於安全、唯讀或可逆的操作,並嚴格禁止執行具破壞性的指令,例如刪除儲存庫、移除資產或清除快取。

主要功能包括全面的拉取請求管理(建立、審查、合併及追蹤 PR)、問題追蹤與組織、跨 GitHub 儲存庫的全面搜尋、標籤與專案管理、GitHub Actions 工作流程監控與觸發、Codespace 操作、發行自動化,以及基於瀏覽器的儲存庫瀏覽。 此技能支援諸如 Copilot 程式碼審查、PR 草稿、squash 與 rebase 合併策略,以及針對問題和 PR 的大批量操作等進階功能。

此技能專為偏好終端機工作流程的開發人員與 DevOps 工程師、實施 CI/CD 自動化的團隊、管理多個儲存庫的開源維護者,以及任何希望優化 GitHub 互動效率的使用者所設計。 它對於自動化重複性的 GitHub 任務、將 GitHub 操作整合至腳本和工作流程中,以及在不離開命令列的情況下於各團隊間維持一致的開發實務,都具有特別的價值。

常見問題

此技能禁止哪些破壞性操作?

此技能嚴格禁止任何永久性破壞性指令,包括儲存庫刪除、歸檔、版本刪除、工作流程執行紀錄刪除、快取刪除、機密資訊/變數刪除、SSH/GPG 金鑰刪除、程式碼空間刪除,以及任何批次刪除操作。 僅允許執行安全、唯讀或可逆的操作,例如建立資源、檢視資訊、更新內容,以及關閉(但非刪除)拉取請求(PR)/問題(Issue)。

使用 GitHub CLI 指令前是否需要進行驗證?

是的,在使用大多數 gh 指令之前,您必須先透過 'gh auth login' 向 GitHub 進行驗證。您可以使用 'gh auth status' 檢查驗證狀態,並透過 'gh auth setup-git' 設定 Git 整合。此技能支援互動式登入,並能自動將 OAuth 代碼複製到剪貼簿。

我可以使用此技能來管理拉取請求和程式碼審查嗎?

可以,此技能提供全面的 PR 管理功能,包括建立具有自訂標題/內文/基礎分支的 PR、建立草稿 PR、檢視 PR 詳情與差異、將 PR 檢出至本地端、執行程式碼審查(批准、留言、要求修改)、請求 Copilot 程式碼審查,以及採用不同策略 (squash、rebase、merge),以及更新 PR 分支。

此技能的主要使用情境有哪些?

主要使用情境包括基於終端的 GitHub 工作流程管理、透過腳本自動化重複性的 GitHub 任務、CI/CD 管道整合、從命令列管理多個儲存庫、無需切換瀏覽器即可進行程式碼審查、監控 GitHub Actions 工作流程,以及在各團隊間維持一致的開發實務。

這項技能是否支援 GitHub Actions 及工作流程自動化?

是的,此技能具備觸發與監控 GitHub Actions 工作流程、檢查工作流程執行狀態、檢視工作流程日誌,以及取消正在執行的工作流程等功能。它能實現 CI/CD 流程的命令列自動化,並與現有的開發腳本整合。

在 GitHub 上查看

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
  • Browse repositories, PRs, and files in the browser

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)
  • Reverting pull requests (creates a new revert PR)
  • 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

# Login to GitHubgh auth login# Login and copy OAuth code to clipboard automaticallygh auth login --clipboard# Check authentication statusgh auth status# Check auth status with JSON outputgh auth status --json# Configure git to use gh as credential helpergh auth setup-git

Pull Requests

Creating PRs

# Create PR interactivelygh pr create# Create PR with title and bodygh pr create --title "Add feature" --body "Description"# Create PR to specific branchgh pr create --base main --head feature-branch# Create draft PRgh pr create --draft# Create PR from current branchgh pr create --fill  # Uses commit messages# Create PR with Copilot Code Reviewgh pr create --reviewer @copilot

Viewing PRs

# List PRsgh pr list# List my PRsgh pr list --author @me# View PR detailsgh pr view 123# View PR in browsergh pr view 123 --web# View PR diffgh pr diff 123# View PR diff excluding specific filesgh pr diff 123 --exclude "*.lock"# Check PR statusgh pr status

Managing PRs

# Checkout PR locallygh pr checkout 123# Review PRgh pr review 123 --approvegh pr review 123 --comment --body "Looks good!"gh pr review 123 --request-changes --body "Please fix X"# Request Copilot Code Reviewgh pr edit 123 --add-reviewer @copilot# Merge PRgh pr merge 123gh pr merge 123 --squashgh pr merge 123 --rebasegh pr merge 123 --merge# Close PRgh pr close 123# Reopen PRgh pr reopen 123# Ready draft PRgh pr ready 123# Update PR branch with base branchgh pr update-branch 123# Revert a merged PR (creates a new revert PR)gh pr revert 123

PR Checks

# View PR checksgh pr checks 123# Watch PR checksgh pr checks 123 --watch

Issues

Creating Issues

# Create issue interactivelygh issue create# Create issue with title and bodygh issue create --title "Bug report" --body "Description"# Use a Markdown issue template as interactive/editor starting body textgh issue create --template "Bug Report"# Create issue with labelsgh issue create --title "Bug" --label bug,critical# Assign issuegh issue create --title "Task" --assignee @me# Set the issue type (GitHub.com and GHES 3.17+)gh issue create --type Bug

--template cannot be combined with --body or --body-file; use it with prompts, --editor, or --web. For YAML issue forms, fetch and render the form fields yourself for non-interactive automation, or finish in the browser.

Viewing Issues

# List issuesgh issue list# List my issuesgh issue list --assignee @me# List by labelgh issue list --label bug# Filter by issue typegh issue list --type Bug# Advanced issue searchgh issue list --search "is:open label:bug sort:created-desc"# View issue detailsgh issue view 456# View in browsergh issue view 456 --web

Managing Issues

# Close issuegh issue close 456# Close as duplicate, linking to the original issuegh issue close 123 --duplicate-of 456# Reopen issuegh issue reopen 456# Edit issuegh issue edit 456 --title "New title"gh issue edit 456 --add-label buggh issue edit 456 --add-assignee @user# Comment on issuegh issue comment 456 --body "Update"# Create branch to work on issuegh issue develop 456 --checkout

Issue Types, Sub-Issues & Relationships

Issue types and sub-issues require GitHub.com or GHES 3.17+; blocking relationships require GHES 3.19+.

# Set or remove the issue typegh issue edit 456 --type Buggh issue edit 456 --remove-type# Create a sub-issue under a parentgh issue create --parent 100# Organize existing issues into a parent/child hierarchygh issue edit 100 --add-sub-issue 123,124gh issue edit 100 --remove-sub-issue 123gh issue edit 123 --parent 100gh issue edit 123 --remove-parent# Track blocked-by / blocking relationshipsgh issue create --blocked-by 200,201 --blocking 300gh issue edit 123 --add-blocked-by 200 --add-blocking 300,301gh issue edit 123 --remove-blocked-by 200 --remove-blocking 301

Discussions

When the user asks to list, view, create, edit, or comment on GitHub Discussions, see references/discussions.md. The gh discussion command set is in preview and subject to change.

Copilot Agent Tasks

Delegate work to the Copilot coding agent and track its sessions. The gh agent-task command set (aliases gh agent, gh agents) is in preview.

# Create an agent task on the current repositorygh agent-task create "Improve the performance of the data processing pipeline"# List your most recent agent tasksgh agent-task listgh agent-task list --json id,name,state# View an agent task session (by PR number, session ID, or URL)gh agent-task view 123gh agent-task view <session-id> --json state --jq '.state'

Agent Skills

Discover, install, and publish agent skills from GitHub repositories. The gh skill command set (alias gh skills) is in preview.

# Search for skills across GitHubgh skill search terraform# Preview a skill before installinggh skill preview github/awesome-copilot documentation-writer# Install a skill (default scope: project)gh skill install github/awesome-copilot documentation-writergh skill install owner/repo skill-name --scope user --pin v1.2.0# Include skills in hidden dirs (.claude/skills/, .agents/skills/, .github/skills/)gh skill install owner/repo skill-name --allow-hidden-dirs# List installed skills and update themgh skill listgh skill update --all# Validate and publish your own skillsgh skill publish --dry-run

Repository Operations

Repository Info

# View repositorygh repo view# View in browsergh repo view --web# Clone repositorygh repo clone owner/repo# Clone without adding upstream remotegh repo clone owner/repo --no-upstream# Fork repositorygh repo fork owner/repo# List repositoriesgh repo list owner

Repository Management

# Create repositorygh repo create my-repo --publicgh repo create my-repo --private# Sync forkgh repo sync owner/repo# Set default repositorygh repo set-default# Configure the squash-merge commit message defaultgh repo edit --squash-merge-commit-message COMMIT_MESSAGES

Reading Repo Contents

Read files and directories without cloning. The gh repo read-file and gh repo read-dir commands are in preview and subject to change.

# Read a file from the default branch (paged in a TTY, raw when piped)gh repo read-file README.md --repo cli/cli# Read from a specific branch, tag, or commitgh repo read-file go.mod --ref v2.94.0 --repo cli/cli# Write to disk instead of stdout (--clobber to overwrite)gh repo read-file README.md --output ./README.md --clobber# Refuse escape sequences by default; opt in for TTY/piped outputgh repo read-file script.sh --allow-escape-sequences# List a directory (root when no path given)gh repo read-dir script --repo cli/cli# Inspect entries as JSON for scriptinggh repo read-dir docs --repo cli/cli --json name,path,type,size

Search

When the user asks to search GitHub repositories, issues, or pull requests, see references/search.md.

Labels

When the user asks to list, create, edit, or clone repository labels, see references/labels.md.

Codespaces

When the user asks to list, create, connect to, or manage files within GitHub Codespaces, see references/codespaces.md.

Browse

Open repositories, files, and resources in the browser.

# Open current repo in browsergh browse# Open specific filegh browse src/main.go# Open file at specific linegh browse src/main.go:42# Open blame view for a filegh browse --blame src/main.go# Open Actions tabgh browse --actions# Open specific branchgh browse --branch feature

Releases

When the user asks to create, list, view, or download GitHub releases, see references/releases.md.

Gists

When the user asks to create, list, view, or edit GitHub gists, see references/gists.md.

Configuration

# Set default editorgh config set editor vim# Set default git protocolgh config set git_protocol ssh# View configurationgh config list# Set browsergh config set browser firefox

Quick Reference

Common gh operations at a glance:

OperationCommandCommon Flags
Create PRgh pr create--draft, --fill, --reviewer @copilot
List PRsgh pr list--author @me, --label, --search
View PRgh pr view <number>--web, --comments
Merge PRgh pr merge <number>--squash, --rebase, --delete-branch
Revert PRgh pr revert <number>--body
Create issuegh issue create--title, --body, --template, --type
List issuesgh issue list--assignee @me, --label, --type
Close issuegh issue close <number>--duplicate-of, --reason
View issuegh issue view <number>--web, --comments
Link sub-issuegh issue edit <number>--parent, --add-sub-issue
Block issuegh issue edit <number>--add-blocked-by, --add-blocking
List discussionsgh discussion list--answered, --sort, --json
Create agent taskgh agent-task create--json (on list/view)
Install skillgh skill install--scope, --pin, --allow-hidden-dirs
Browse repogh browse--blame, --actions, --branch
Clone repogh repo clone <repo>--no-upstream
Fork repogh repo fork--clone, --remote
View repogh repo view--web
Read repo filegh repo read-file <path>--ref, --output, --clobber, --json
Read repo dirgh repo read-dir [path]--ref, --json
Create releasegh release create <tag>--title, --notes, --draft
Verify releasegh release verify <tag>--repo
Run workflowgh workflow run <name>--ref, --field
Watch rungh run watch <id>--exit-status
Search reposgh search repos <query>--language, --stars
Create labelgh label create <name>--color, --description
Create codespacegh codespace create--repo, --branch

Additional Resources

Reference Guides

For detailed patterns and advanced usage, see:

  • Discussions - List, view, create, edit, and comment on GitHub Discussions (preview)
  • Workflows & Actions - GitHub Actions workflows, runs, cache management, and CI/CD integration patterns
  • Advanced Features - Aliases, API access, extensions, secrets, SSH/GPG keys, organizations, projects, and advanced scripting
  • Automation Workflows - Common automation patterns, daily reports, release automation, and team collaboration workflows
  • Troubleshooting - Solutions for authentication, permissions, rate limiting, and common errors

Example Scripts

Practical automation scripts (see examples/ directory):

  • auto-pr-create.sh - Automated PR creation workflow
  • issue-triage.sh - Bulk issue labeling and assignment
  • workflow-monitor.sh - Watch and notify on workflow completion
  • release-automation.sh - Complete release workflow automation

External Documentation

  • Official Manual: https://cli.github.com/manual
  • GitHub Community: https://github.com/cli/cli/discussions
  • API Documentation: https://docs.github.com/en/rest
  • Extension Marketplace: https://github.com/topics/gh-extension

JSON Output

When the user wants to use --json flags or needs the correct gh CLI JSON field names, see references/json-output.md.

Tips

  1. Use --web flag to open items in browser for detailed view
  2. Leverage interactive prompts by omitting parameters - most commands support interactive mode
  3. Apply filters with --author, --label, --state to narrow down lists efficiently
  4. Add --json flag to enable scriptable output for automation
  5. Always check --help for valid JSON field names - they differ from GitHub API
  6. Use gh repo create --template to scaffold from template repositories
  7. Enable auto-merge with gh pr merge --auto for PRs that pass checks

安裝 cli-gh

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/PaulRBerg/agent-skills/blob/main/skills/cli-gh/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/,Claude 會自動偵測並使用該技能

相關技能

Verification &amp; Quality Assurance
更新時間 2026-06-29
klingai-upgrade-migration
更新時間 2026-07-03
base44-cli
更新時間 2026-06-29
Railway CLI Management
更新時間 2026-07-02
OR