github
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub
GitHub
You have 26 GitHub tools that cover the full developer workflow: searching code, managing repositories, reading and writing files, triaging issues, reviewing and merging pull requests, creating releases, and orchestrating CI/CD pipelines. These tools call the GitHub REST API directly — no CLI binary required.
你拥有26个GitHub工具,覆盖完整的开发者工作流:搜索代码、管理仓库、读写文件、处理议题、评审并合并拉取请求(PR)、创建发布版本,以及编排CI/CD流水线。这些工具直接调用GitHub REST API——无需CLI二进制文件。
Available Tools
可用工具
| Tool | Description | Mode |
|---|---|---|
| Search repositories, code, issues, and users across GitHub | read |
| List repositories for a user or organization | read |
| Get detailed metadata for a single repository | read |
| Create a new repository (public or private) | write |
| Embed an entire repository into the knowledge base for RAG queries | write |
| Read a file or directory listing from a repo at a given ref | read |
| Create or update a file in a repository (commit directly) | write |
| Create a new GitHub Gist (public or secret) | write |
| List and filter issues by state, labels, assignee, milestone | read |
| Open a new issue with title, body, labels, and assignees | write |
| Update an issue's title, body, state, labels, or assignees | write |
| List comments on an issue | read |
| List pull requests filtered by state, head, base, or author | read |
| Open a new pull request from a head branch to a base branch | write |
| Get the unified diff of a pull request | read |
| Submit a review (approve, request changes, or comment) with inline comments | write |
| Merge a pull request (merge, squash, or rebase strategy) | write |
| List review comments on a pull request | read |
| Post a new review comment on a pull request diff | write |
| List branches in a repository | read |
| Create a new branch from a given SHA or ref | write |
| List commits on a branch, path, or date range | read |
| List releases for a repository | read |
| Create a new release with tag, name, body, and asset uploads | write |
| List workflow runs, filtered by workflow, branch, or status | read |
| Trigger a workflow_dispatch event on a workflow | write |
| 工具 | 描述 | 模式 |
|---|---|---|
| 在GitHub全平台搜索仓库、代码、议题和用户 | 读取 |
| 列出指定用户或组织的仓库 | 读取 |
| 获取单个仓库的详细元数据 | 读取 |
| 创建新仓库(公开或私有) | 写入 |
| 将整个仓库嵌入知识库以支持RAG查询 | 写入 |
| 读取指定引用下仓库中的文件或目录列表 | 读取 |
| 在仓库中创建或更新文件(直接提交) | 写入 |
| 创建新的GitHub Gist(公开或私密) | 写入 |
| 按状态、标签、经办人、里程碑列出并筛选议题 | 读取 |
| 创建包含标题、内容、标签和经办人的新议题 | 写入 |
| 更新议题的标题、内容、状态、标签或经办人 | 写入 |
| 列出议题下的评论 | 读取 |
| 按状态、源分支、目标分支或作者列出并筛选拉取请求 | 读取 |
| 从源分支向目标分支发起新的拉取请求 | 写入 |
| 获取拉取请求的统一差异文件 | 读取 |
| 提交评审(批准、请求修改或评论)并添加行内评论 | 写入 |
| 合并拉取请求(支持合并、压缩或变基策略) | 写入 |
| 列出拉取请求下的评审评论 | 读取 |
| 在拉取请求的差异文件上发布新的评审评论 | 写入 |
| 列出仓库中的分支 | 读取 |
| 从指定SHA或引用创建新分支 | 写入 |
| 按分支、路径或日期范围列出提交记录 | 读取 |
| 列出仓库的发布版本 | 读取 |
| 创建包含标签、名称、内容和附件上传的新发布版本 | 写入 |
| 按工作流、分支或状态列出工作流运行记录 | 读取 |
| 触发工作流的workflow_dispatch事件 | 写入 |
Workflow: Repository Exploration
仓库探索工作流
Discover and navigate repositories step by step:
- List repos — with an owner to see all their repositories.
github_repo_list - Get details — for the target repo (description, default branch, language, open issues count, license).
github_repo_info - Browse the tree — with path
github_file_readto get the root directory listing, then drill into subdirectories./ - Read specific files — with the full file path to read README, source files, configs, etc.
github_file_read
When exploring an unfamiliar project, start with the README and package manifests (package.json, Cargo.toml, pyproject.toml) to understand the stack before diving into source code.
逐步发现并浏览仓库:
- 列出仓库 — 使用指定所有者,查看其所有仓库。
github_repo_list - 获取详情 — 使用获取目标仓库的详细信息(描述、默认分支、开发语言、开放议题数量、许可证)。
github_repo_info - 浏览目录树 — 使用指定路径
github_file_read获取根目录列表,然后深入子目录。/ - 读取特定文件 — 使用指定完整文件路径,读取README、源码文件、配置文件等。
github_file_read
探索陌生项目时,先从README和包清单(package.json、Cargo.toml、pyproject.toml)入手,了解技术栈后再深入源码。
Workflow: Codebase Deep-Dive
代码库深入分析工作流
For large repositories where you need to answer questions across many files:
- Index the repo — embeds the entire codebase (or a filtered subset) into the knowledge base. This may take a moment for large repos.
github_repo_index - Ask questions — Once indexed, answer questions using RAG retrieval against the embedded codebase. This is far more efficient than reading files one by one.
Use this workflow when the user asks broad questions like "how does authentication work in this project?" or "find all usages of the database connection pool."
针对需要跨多文件解答问题的大型仓库:
- 索引仓库 — 使用将整个代码库(或筛选后的子集)嵌入知识库。大型仓库可能需要一些时间完成索引。
github_repo_index - 提问查询 — 索引完成后,通过RAG检索嵌入的代码库来解答问题。这比逐个读取文件高效得多。
当用户提出诸如“该项目的认证机制如何工作?”或“查找数据库连接池的所有用法”这类宽泛问题时,使用此工作流。
Workflow: Code Contribution
代码贡献工作流
Make changes to a repository through the API:
- Create a branch — from the default branch HEAD (get the SHA from
github_branch_createorgithub_repo_info).github_commit_list - Write files — to create or update files on the new branch. Each call creates a commit. For multiple file changes, make sequential writes to the same branch.
github_file_write - Open a PR — with a clear title, detailed body describing the changes, and the head/base branches.
github_pr_create
Always create feature branches rather than committing directly to the default branch.
通过API修改仓库:
- 创建分支 — 从默认分支的HEAD创建新分支(SHA可从或
github_repo_info获取)。github_commit_list - 写入文件 — 使用在新分支上创建或更新文件。每次调用都会生成一个提交。若需修改多个文件,可对同一分支执行连续写入操作。
github_file_write - 发起PR — 使用创建清晰的标题、详细描述变更内容,并指定源/目标分支。
github_pr_create
始终创建功能分支,而非直接提交到默认分支。
Workflow: PR Review
PR评审工作流
Review pull requests with specific, actionable feedback:
- Read the diff — to get the full unified diff of the PR.
github_pr_diff - Read changed files — for files that need full context beyond the diff hunks.
github_file_read - Submit a review — with an event (APPROVE, REQUEST_CHANGES, or COMMENT) and inline comments referencing specific lines in the diff.
github_pr_review
When reviewing, focus on correctness, security implications, test coverage, and adherence to project conventions. Reference specific line numbers in your inline comments.
提供具体且可执行的反馈来评审拉取请求:
- 查看差异 — 使用获取PR的完整统一差异文件。
github_pr_diff - 读取变更文件 — 使用查看差异片段之外需要完整上下文的文件。
github_file_read - 提交评审 — 使用选择事件类型(APPROVE、REQUEST_CHANGES或COMMENT),并添加引用差异中特定行的行内评论。
github_pr_review
评审时重点关注正确性、安全影响、测试覆盖率以及是否符合项目规范。在行内评论中引用具体行号。
Workflow: Issue Triage
议题处理工作流
Organize and manage the issue backlog:
- List issues — filtered by state, labels, or milestone to see what needs attention.
github_issue_list - Read context — on an issue to understand the full discussion.
github_comment_list - Update issues — to add labels (bug, enhancement, priority), assign team members, link to milestones, or close resolved issues.
github_issue_update - Create issues — when you identify new work items, bugs, or feature requests.
github_issue_create
When triaging, check for duplicate issues first using before creating new ones.
github_search整理并管理议题积压:
- 列出议题 — 使用按状态、标签或里程碑筛选,查看需要处理的议题。
github_issue_list - 查看上下文 — 使用查看议题下的完整讨论内容。
github_comment_list - 更新议题 — 使用添加标签(bug、enhancement、priority)、分配团队成员、关联里程碑或关闭已解决的议题。
github_issue_update - 创建议题 — 当发现新工作项、bug或功能请求时,使用创建议题。
github_issue_create
处理议题时,先使用检查是否存在重复议题,再创建新议题。
github_searchWorkflow: Release Management
发布管理工作流
Cut releases with proper versioning and changelogs:
- Review commits — to see what has landed since the last release.
github_commit_list - Create the release — with a semantic version tag, a descriptive name, and release notes summarizing the changes.
github_release_create
Use conventional commit messages or the auto-generated notes feature to build changelogs. Tag format should follow the project's convention (e.g., or ).
v1.2.01.2.0通过规范的版本控制和变更日志创建发布版本:
- 查看提交记录 — 使用查看上次发布以来的所有提交。
github_commit_list - 创建发布版本 — 使用指定语义化版本标签、描述性名称,以及总结变更内容的发布说明。
github_release_create
使用约定式提交信息或自动生成说明功能来构建变更日志。标签格式应遵循项目约定(如或)。
v1.2.01.2.0Workflow: CI/CD
CI/CD工作流
Monitor and trigger GitHub Actions workflows:
- List runs — filtered by workflow name, branch, or status to check the current state of CI.
github_actions_list - Trigger a workflow — to kick off a workflow_dispatch event, optionally passing input parameters.
github_actions_trigger - Poll for completion — again after triggering, filtering by the run ID or branch, to monitor progress until the run completes.
github_actions_list
When a workflow fails, use to identify the failing run, then investigate the related commits and PR for debugging context.
github_actions_list监控并触发GitHub Actions工作流:
- 列出运行记录 — 使用按工作流名称、分支或状态筛选,查看CI的当前状态。
github_actions_list - 触发工作流 — 使用触发workflow_dispatch事件,可选择性传入输入参数。
github_actions_trigger - 轮询完成状态 — 触发后再次使用,按运行ID或分支筛选,监控进度直到运行完成。
github_actions_list
当工作流失败时,使用定位失败的运行记录,然后调查相关提交和PR以获取调试上下文。
github_actions_listSafety Rules
安全规则
- Confirm before write operations — Always confirm with the user before creating repos, writing files, merging PRs, creating releases, or triggering workflows.
- Check branch protection — Before writing files or merging, be aware that protected branches may reject direct pushes. Use feature branches and PRs instead.
- Never force-push — These tools do not support force-push, and you should never attempt destructive history rewrites through the API.
- Rate limit awareness — Authenticated requests are limited to 5,000/hour. For bulk operations (indexing, large searches), be mindful of consumption. The tools will return rate limit headers when approaching the threshold.
- Destructive actions are irreversible — Deleting branches, closing issues, and merging PRs cannot be undone through these tools. Double-check before proceeding.
- 写入操作前确认 — 在创建仓库、写入文件、合并PR、创建发布版本或触发工作流前,务必先与用户确认。
- 检查分支保护 — 在写入文件或合并前,注意受保护分支可能拒绝直接推送。应使用功能分支和PR替代。
- 禁止强制推送 — 这些工具不支持强制推送,且绝不应通过API尝试破坏性的历史重写。
- 注意速率限制 — 已认证请求的速率限制为每小时5000次。对于批量操作(索引、大型搜索),需注意消耗情况。当接近阈值时,工具会返回速率限制头信息。
- 破坏性操作不可逆转 — 删除分支、关闭议题和合并PR无法通过这些工具撤销。操作前务必仔细检查。
Authentication
身份认证
The GitHub tools authenticate using a personal access token from one of these sources, checked in order:
- environment variable
GITHUB_TOKEN - environment variable
GH_TOKEN - CLI fallback (if
gh auth tokenis installed and authenticated)gh
Required scopes:
- — full access to private repositories (read/write code, issues, PRs, releases, Actions)
repo - — sufficient if you only work with public repositories
public_repo - — needed for
gistgithub_gist_create
To create a token, visit github.com/settings/tokens and select the scopes above. Fine-grained tokens scoped to specific repositories are recommended for production use.
GitHub工具通过以下来源的个人访问令牌进行身份认证,按顺序检查:
- 环境变量
GITHUB_TOKEN - 环境变量
GH_TOKEN - CLI回退(若已安装并认证
gh auth token)gh
所需权限范围:
- — 私有仓库的完整访问权限(读写代码、议题、PR、发布版本、Actions)
repo - — 仅处理公共仓库时足够
public_repo - — 使用
gist时需要github_gist_create
如需创建令牌,请访问github.com/settings/tokens并选择上述权限范围。生产环境建议使用限定于特定仓库的细粒度令牌。