github-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Automation
GitHub自动化
This Skill helps you manage GitHub operations using the CLI, including repositories, issues, pull requests, releases, and GitHub Actions workflows.
gh本Skill帮助你使用 CLI管理GitHub操作,包括仓库、Issue、Pull Request(PR)、发布版本和GitHub Actions工作流。
ghCapabilities
功能特性
- Repositories: Create, clone, fork, view, and manage repos
- Issues: Create, list, view, close, comment, and label issues
- Pull Requests: Create, review, merge, list, and comment on PRs
- Releases: Create releases and manage tags
- Workflows: View and manage GitHub Actions
- Gists: Create and manage gists
- Search: Search repos, issues, PRs, code, and users
- 仓库管理:创建、克隆、复刻、查看和管理仓库
- Issue处理:创建、列出、查看、关闭、评论和标记Issue
- 拉取请求(PR):创建、评审、合并、列出和评论PR
- 版本发布:创建发布版本并管理标签
- 工作流:查看和管理GitHub Actions
- Gist管理:创建和管理Gist
- 搜索功能:搜索仓库、Issue、PR、代码和用户
Authentication
认证方式
The environment variable is pre-configured. Verify with:
GITHUB_TOKENbash
gh auth statusGITHUB_TOKENbash
gh auth statusInstructions
操作步骤
Phase 1: Understand the Request
阶段1:理解需求
- Clarify what GitHub operation the user needs
- Identify the target repository (if not specified, ask)
- Confirm any destructive operations before executing
- 明确用户需要执行的GitHub操作
- 确定目标仓库(若未指定,需询问用户)
- 执行破坏性操作前需先确认
Phase 2: Execute the Operation
阶段2:执行操作
Use CLI commands. Common patterns:
ghRepository Operations
bash
gh repo view <owner>/<repo>
gh repo clone <owner>/<repo>
gh repo create <name> --public/--private
gh repo list <owner>Issue Operations
bash
gh issue list --repo <owner>/<repo>
gh issue create --repo <owner>/<repo> --title "Title" --body "Body"
gh issue view <number> --repo <owner>/<repo>
gh issue close <number> --repo <owner>/<repo>
gh issue comment <number> --repo <owner>/<repo> --body "Comment"Pull Request Operations
bash
gh pr list --repo <owner>/<repo>
gh pr create --repo <owner>/<repo> --title "Title" --body "Body"
gh pr view <number> --repo <owner>/<repo>
gh pr merge <number> --repo <owner>/<repo>
gh pr review <number> --repo <owner>/<repo> --approve/--comment/--request-changes
gh pr checks <number> --repo <owner>/<repo>Search Operations
bash
gh search repos <query>
gh search issues <query>
gh search prs <query>
gh search code <query>GitHub Actions
bash
gh run list --repo <owner>/<repo>
gh run view <run-id> --repo <owner>/<repo>
gh workflow list --repo <owner>/<repo>Releases
bash
gh release list --repo <owner>/<repo>
gh release create <tag> --repo <owner>/<repo> --title "Title" --notes "Notes"使用 CLI命令。常见命令示例:
gh仓库操作
bash
gh repo view <owner>/<repo>
gh repo clone <owner>/<repo>
gh repo create <name> --public/--private
gh repo list <owner>Issue操作
bash
gh issue list --repo <owner>/<repo>
gh issue create --repo <owner>/<repo> --title "Title" --body "Body"
gh issue view <number> --repo <owner>/<repo>
gh issue close <number> --repo <owner>/<repo>
gh issue comment <number> --repo <owner>/<repo> --body "Comment"拉取请求(PR)操作
bash
gh pr list --repo <owner>/<repo>
gh pr create --repo <owner>/<repo> --title "Title" --body "Body"
gh pr view <number> --repo <owner>/<repo>
gh pr merge <number> --repo <owner>/<repo>
gh pr review <number> --repo <owner>/<repo> --approve/--comment/--request-changes
gh pr checks <number> --repo <owner>/<repo>搜索操作
bash
gh search repos <query>
gh search issues <query>
gh search prs <query>
gh search code <query>GitHub Actions操作
bash
gh run list --repo <owner>/<repo>
gh run view <run-id> --repo <owner>/<repo>
gh workflow list --repo <owner>/<repo>版本发布操作
bash
gh release list --repo <owner>/<repo>
gh release create <tag> --repo <owner>/<repo> --title "Title" --notes "Notes"Guidelines
操作指南
- Always specify when not in a cloned repository
--repo <owner>/<repo> - For destructive operations (delete, close, merge), confirm with user first
- Use flag when you need to parse output programmatically
--json - Handle errors gracefully and suggest fixes
- When creating issues/PRs, use clear titles and descriptive bodies
- 若未在已克隆的仓库目录下,执行命令时需指定参数
--repo <owner>/<repo> - 执行破坏性操作(删除、关闭、合并)前,需先征得用户确认
- 若需以编程方式解析输出结果,使用参数
--json - 优雅处理错误并给出修复建议
- 创建Issue/PR时,使用清晰的标题和描述性内容
Phase 3: Report Results
阶段3:结果反馈
- Summarize what was done
- Provide relevant links (PR URLs, issue numbers, etc.)
- Suggest next steps if applicable
- 总结已执行的操作
- 提供相关链接(PR地址、Issue编号等)
- 若适用,给出后续操作建议
Output Format
输出格式
When listing items, format clearly:
#123 - Issue title (open/closed) - @author
#456 - PR title (open/merged/closed) - @authorWhen creating items, always report:
- The created item's number/ID
- Direct URL to the item
- Any relevant status information
列出内容时,需清晰格式化:
#123 - Issue标题 (open/closed) - @作者
#456 - PR标题 (open/merged/closed) - @作者创建内容后,需反馈以下信息:
- 已创建内容的编号/ID
- 内容的直接访问链接
- 相关状态信息
Examples
示例
Create an issue:
bash
gh issue create --repo <owner>/<repo> --title "Bug: Login fails" --body "Steps to reproduce..."List open PRs awaiting review:
bash
gh pr list --repo <owner>/<repo> --state open --search "review:required"Get PR details as JSON:
bash
gh pr view <number> --repo <owner>/<repo> --json title,state,reviews,checks创建Issue:
bash
gh issue create --repo <owner>/<repo> --title "Bug: Login fails" --body "Steps to reproduce..."列出待评审的开放PR:
bash
gh pr list --repo <owner>/<repo> --state open --search "review:required"以JSON格式获取PR详情:
bash
gh pr view <number> --repo <owner>/<repo> --json title,state,reviews,checksPrerequisites
前置条件
This Skill requires the GitHub CLI () to be installed and authenticated:
ghbash
gh auth statusIf not authenticated, run:
bash
gh auth loginAlternatively, set the environment variable with a personal access token.
GITHUB_TOKENImportant: When using environment variables in commands with pipes, wrap the command in to avoid variable substitution issues:
bash -c '...'bash
bash -c 'gh pr view <number> --repo $OWNER/$REPO --json title,state' | jq '.title'Without environment variables, the pipe is fine:
bash
gh pr view <number> --repo <owner>/<repo> --json title,state | jq '.title'使用本Skill需预先安装并认证GitHub CLI ():
ghbash
gh auth status若未完成认证,执行以下命令:
bash
gh auth login或者,使用个人访问令牌设置环境变量。
GITHUB_TOKEN重要提示:在包含管道的命令中使用环境变量时,需将命令包裹在中,以避免变量替换问题:
bash -c '...'bash
bash -c 'gh pr view <number> --repo $OWNER/$REPO --json title,state' | jq '.title'不使用环境变量时,管道可正常使用:
bash
gh pr view <number> --repo <owner>/<repo> --json title,state | jq '.title'