Comprehensive GitHub CLI (gh) reference. Covers repos, issues, PRs, Actions, releases, gists, search, projects v2, API, secrets/variables, labels, codespaces...
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install github-cli或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install github-cli⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/github-cli/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: github-cli description: "Comprehensive GitHub CLI (gh) reference. Covers repos, issues, PRs, Actions, releases, gists, search, projects v2, API, secrets/variables, labels, codespaces, extensions, auth, and advanced GraphQL patterns." metadata: { "openclaw": { "emoji": "🐙", "requires": { "bins": ["gh"] }, "install": [ { "id": "brew", "kind": "brew", "formula": "gh", "bins": ["gh"], "label": "Install GitHub CLI (brew)", }, { "id": "apt", "kind": "apt", "package": "gh", "bins": ["gh"], "label": "Install GitHub CLI (apt)", }, ], }, } ---
gh) — Comprehensive SkillVersion: gh 2.66.1+ Auth: gh auth login or set GH_TOKEN env var Always use --repo OWNER/REPO (or -R) when not inside a git repo directory.
---
---
# Interactive login (browser-based OAuth)
gh auth login
# Login with a PAT from stdin
echo "$MY_TOKEN" | gh auth login --with-token
# Login to GitHub Enterprise
gh auth login --hostname enterprise.example.com
# Add extra scopes (e.g., project scope for Projects V2)
gh auth refresh -s project
# Add delete_repo scope
gh auth refresh -s delete_repo
# Check auth status (shows active account, scopes, token validity)
gh auth status
gh auth status --show-token
# Switch active account (when multiple accounts configured)
gh auth switch
# Print the active token (useful for piping to other tools)
gh auth token
# Logout
gh auth logout
Required scopes by feature: | Feature | Scope needed | |---------|-------------| | Basic repo/PR/issue ops | repo | | Gists | gist | | Read org membership | read:org | | Projects V2 | project | | Delete repos | delete_repo | | Actions workflows | workflow | | Read user profile | user |
# List all config
gh config list
# Get/set individual values
gh config get git_protocol # https or ssh
gh config set git_protocol ssh
gh config set editor "code --wait"
gh config set pager "less -R"
gh config set prompt disabled # disable interactive prompts (good for scripts)
gh config set browser "firefox"
# Clear CLI cache
gh config clear-cache
# Configure git to use gh for HTTPS auth
gh auth setup-git
---
# Interactive
gh repo create
# Public repo, clone locally
gh repo create my-project --public --clone
# In an org
gh repo create my-org/my-project --private
# From local directory
gh repo create my-project --private --source=. --remote=upstream --push
# From template
gh repo create my-project --template owner/template-repo --clone
# With options
gh repo create my-project --public --description "My project" \
--license mit --gitignore Node --add-readme
gh repo clone owner/repo
gh repo clone owner/repo my-dir
gh repo clone owner/repo -- --depth=1 # shallow clone
# Clone your own repo (owner defaults to you)
gh repo clone my-repo
# Fork current repo
gh repo fork
# Fork and clone
gh repo fork owner/repo --clone
# Fork into an org
gh repo fork owner/repo --org my-org --fork-name new-name
# Fork default branch only
gh repo fork owner/repo --default-branch-only
# View current repo (README + description)
gh repo view
gh repo view owner/repo
# Open in browser
gh repo view --web
# JSON output
gh repo view --json name,description,stargazerCount,url
gh repo view --json name,stargazerCount --jq '.stargazerCount'
JSON fields for repo: archivedAt, assignableUsers, codeOfConduct, createdAt, defaultBranchRef, deleteBranchOnMerge, description, diskUsage, forkCount, hasDiscussionsEnabled, hasIssuesEnabled, hasProjectsEnabled, hasWikiEnabled, homepageUrl, id, isArchived, isEmpty, isFork, isPrivate, isTemplate, languages, latestRelease, licenseInfo, name, nameWithOwner, owner, parent, primaryLanguage, pullRequests, pushedAt, sshUrl, stargazerCount, updatedAt, url, visibility, watchers
# Your repos
gh repo list
gh repo list --limit 100
# Another user/org's repos
gh repo list my-org
# Filter
gh repo list --language go --visibility public
gh repo list --topic cli --no-archived
gh repo list --fork # only forks
gh repo list --source # only non-forks
# JSON output
gh repo list --json name,stargazerCount --jq '.[] | "\(.name): \(.stargazerCount) stars"'
# Edit settings
gh repo edit --description "New description"
gh repo edit --homepage "https://example.com"
gh repo edit --enable-issues --enable-wiki
gh repo edit --enable-projects=false
gh repo edit --default-branch main
gh repo edit --enable-auto-merge
gh repo edit --delete-branch-on-merge
gh repo edit --add-topic "cli,automation"
gh repo edit --remove-topic "old-topic"
gh repo edit --template # make it a template repo
# Change visibility (DANGEROUS — requires acknowledgment)
gh repo edit --visibility public --accept-visibility-change-consequences
gh repo delete owner/repo --yes # requires delete_repo scope
gh repo archive owner/repo --yes
gh repo unarchive owner/repo --yes
gh repo rename new-name # renames current repo
gh repo rename new-name -R owner/repo
# Set which remote is used for gh commands in this local clone
gh repo set-default owner/repo
gh repo set-default --view # see current default
gh repo set-default --unset
# Sync local repo from remote parent
gh repo sync
# Sync specific branch
gh repo sync --branch v1
# Sync remote fork from its parent
gh repo sync owner/my-fork
# Sync from a specific source
gh repo sync owner/repo --source owner2/repo2
# Force sync (hard reset)
gh repo sync --force
---
gh issue create --title "Bug report" --body "Description here"
gh issue create --title "Bug" --label "bug,urgent" --assignee "@me"
gh issue create --title "Feature" --project "Roadmap" --milestone "v2.0"
gh issue create --template "Bug Report" # use issue template
gh issue create --body-file description.md # body from file
gh issue create -R owner/repo --title "Bug" # different repo
gh issue list
gh issue list --state closed
gh issue list --state all --limit 100
gh issue list --label "bug" --assignee "@me"
gh issue list --author monalisa
gh issue list --milestone "v2.0"
gh issue list --search "error no:assignee sort:created-asc"
# JSON output
gh issue list --json number,title,labels,state --jq '.[] | "#\(.number) \(.title)"'
JSON fields for issues: assignees, author, body, closed, closedAt, comments, createdAt, id, isPinned, labels, milestone, number, projectCards, projectItems, reactionGroups, state, stateReason, title, updatedAt, url
...
安装 Github Cli 后,可以对 AI 说这些话来触发它
Help me get started with Github Cli
Explains what Github Cli does, walks through the setup, and runs a quick demo based on your current project
Use Github Cli to comprehensive GitHub CLI (gh) reference
Invokes Github Cli with the right parameters and returns the result directly in the conversation
What can I do with Github Cli in my developer & devops workflow?
Lists the top use cases for Github Cli, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/github-cli/ 目录(个人级,所有项目可用),或 .claude/skills/github-cli/(项目级)。重启 AI 客户端后,用 /github-cli 主动调用,或让 AI 根据上下文自动发现并使用。
Github Cli 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Github Cli 可免费安装使用。请查阅仓库了解许可证信息。
Comprehensive GitHub CLI (gh) reference. Covers repos, issues, PRs, Actions, releases, gists, search, projects v2, API, secrets/variables, labels, codespaces...
Github Cli 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Github Cli
Identifies repetitive steps in your workflow and sets up Github Cli to handle them automatically