github

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub

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

可用工具

ToolDescriptionMode
github_search
Search repositories, code, issues, and users across GitHubread
github_repo_list
List repositories for a user or organizationread
github_repo_info
Get detailed metadata for a single repositoryread
github_repo_create
Create a new repository (public or private)write
github_repo_index
Embed an entire repository into the knowledge base for RAG querieswrite
github_file_read
Read a file or directory listing from a repo at a given refread
github_file_write
Create or update a file in a repository (commit directly)write
github_gist_create
Create a new GitHub Gist (public or secret)write
github_issue_list
List and filter issues by state, labels, assignee, milestoneread
github_issue_create
Open a new issue with title, body, labels, and assigneeswrite
github_issue_update
Update an issue's title, body, state, labels, or assigneeswrite
github_comment_list
List comments on an issueread
github_pr_list
List pull requests filtered by state, head, base, or authorread
github_pr_create
Open a new pull request from a head branch to a base branchwrite
github_pr_diff
Get the unified diff of a pull requestread
github_pr_review
Submit a review (approve, request changes, or comment) with inline commentswrite
github_pr_merge
Merge a pull request (merge, squash, or rebase strategy)write
github_pr_comment_list
List review comments on a pull requestread
github_pr_comment_create
Post a new review comment on a pull request diffwrite
github_branch_list
List branches in a repositoryread
github_branch_create
Create a new branch from a given SHA or refwrite
github_commit_list
List commits on a branch, path, or date rangeread
github_release_list
List releases for a repositoryread
github_release_create
Create a new release with tag, name, body, and asset uploadswrite
github_actions_list
List workflow runs, filtered by workflow, branch, or statusread
github_actions_trigger
Trigger a workflow_dispatch event on a workflowwrite
工具描述模式
github_search
在GitHub全平台搜索仓库、代码、议题和用户读取
github_repo_list
列出指定用户或组织的仓库读取
github_repo_info
获取单个仓库的详细元数据读取
github_repo_create
创建新仓库(公开或私有)写入
github_repo_index
将整个仓库嵌入知识库以支持RAG查询写入
github_file_read
读取指定引用下仓库中的文件或目录列表读取
github_file_write
在仓库中创建或更新文件(直接提交)写入
github_gist_create
创建新的GitHub Gist(公开或私密)写入
github_issue_list
按状态、标签、经办人、里程碑列出并筛选议题读取
github_issue_create
创建包含标题、内容、标签和经办人的新议题写入
github_issue_update
更新议题的标题、内容、状态、标签或经办人写入
github_comment_list
列出议题下的评论读取
github_pr_list
按状态、源分支、目标分支或作者列出并筛选拉取请求读取
github_pr_create
从源分支向目标分支发起新的拉取请求写入
github_pr_diff
获取拉取请求的统一差异文件读取
github_pr_review
提交评审(批准、请求修改或评论)并添加行内评论写入
github_pr_merge
合并拉取请求(支持合并、压缩或变基策略)写入
github_pr_comment_list
列出拉取请求下的评审评论读取
github_pr_comment_create
在拉取请求的差异文件上发布新的评审评论写入
github_branch_list
列出仓库中的分支读取
github_branch_create
从指定SHA或引用创建新分支写入
github_commit_list
按分支、路径或日期范围列出提交记录读取
github_release_list
列出仓库的发布版本读取
github_release_create
创建包含标签、名称、内容和附件上传的新发布版本写入
github_actions_list
按工作流、分支或状态列出工作流运行记录读取
github_actions_trigger
触发工作流的workflow_dispatch事件写入

Workflow: Repository Exploration

仓库探索工作流

Discover and navigate repositories step by step:
  1. List repos
    github_repo_list
    with an owner to see all their repositories.
  2. Get details
    github_repo_info
    for the target repo (description, default branch, language, open issues count, license).
  3. Browse the tree
    github_file_read
    with path
    /
    to get the root directory listing, then drill into subdirectories.
  4. Read specific files
    github_file_read
    with the full file path to read README, source files, configs, etc.
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.
逐步发现并浏览仓库:
  1. 列出仓库 — 使用
    github_repo_list
    指定所有者,查看其所有仓库。
  2. 获取详情 — 使用
    github_repo_info
    获取目标仓库的详细信息(描述、默认分支、开发语言、开放议题数量、许可证)。
  3. 浏览目录树 — 使用
    github_file_read
    指定路径
    /
    获取根目录列表,然后深入子目录。
  4. 读取特定文件 — 使用
    github_file_read
    指定完整文件路径,读取README、源码文件、配置文件等。
探索陌生项目时,先从README和包清单(package.json、Cargo.toml、pyproject.toml)入手,了解技术栈后再深入源码。

Workflow: Codebase Deep-Dive

代码库深入分析工作流

For large repositories where you need to answer questions across many files:
  1. Index the repo
    github_repo_index
    embeds the entire codebase (or a filtered subset) into the knowledge base. This may take a moment for large repos.
  2. 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."
针对需要跨多文件解答问题的大型仓库:
  1. 索引仓库 — 使用
    github_repo_index
    将整个代码库(或筛选后的子集)嵌入知识库。大型仓库可能需要一些时间完成索引。
  2. 提问查询 — 索引完成后,通过RAG检索嵌入的代码库来解答问题。这比逐个读取文件高效得多。
当用户提出诸如“该项目的认证机制如何工作?”或“查找数据库连接池的所有用法”这类宽泛问题时,使用此工作流。

Workflow: Code Contribution

代码贡献工作流

Make changes to a repository through the API:
  1. Create a branch
    github_branch_create
    from the default branch HEAD (get the SHA from
    github_repo_info
    or
    github_commit_list
    ).
  2. Write files
    github_file_write
    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.
  3. Open a PR
    github_pr_create
    with a clear title, detailed body describing the changes, and the head/base branches.
Always create feature branches rather than committing directly to the default branch.
通过API修改仓库:
  1. 创建分支 — 从默认分支的HEAD创建新分支(SHA可从
    github_repo_info
    github_commit_list
    获取)。
  2. 写入文件 — 使用
    github_file_write
    在新分支上创建或更新文件。每次调用都会生成一个提交。若需修改多个文件,可对同一分支执行连续写入操作。
  3. 发起PR — 使用
    github_pr_create
    创建清晰的标题、详细描述变更内容,并指定源/目标分支。
始终创建功能分支,而非直接提交到默认分支。

Workflow: PR Review

PR评审工作流

Review pull requests with specific, actionable feedback:
  1. Read the diff
    github_pr_diff
    to get the full unified diff of the PR.
  2. Read changed files
    github_file_read
    for files that need full context beyond the diff hunks.
  3. Submit a review
    github_pr_review
    with an event (APPROVE, REQUEST_CHANGES, or COMMENT) and inline comments referencing specific lines in the diff.
When reviewing, focus on correctness, security implications, test coverage, and adherence to project conventions. Reference specific line numbers in your inline comments.
提供具体且可执行的反馈来评审拉取请求:
  1. 查看差异 — 使用
    github_pr_diff
    获取PR的完整统一差异文件。
  2. 读取变更文件 — 使用
    github_file_read
    查看差异片段之外需要完整上下文的文件。
  3. 提交评审 — 使用
    github_pr_review
    选择事件类型(APPROVE、REQUEST_CHANGES或COMMENT),并添加引用差异中特定行的行内评论。
评审时重点关注正确性、安全影响、测试覆盖率以及是否符合项目规范。在行内评论中引用具体行号。

Workflow: Issue Triage

议题处理工作流

Organize and manage the issue backlog:
  1. List issues
    github_issue_list
    filtered by state, labels, or milestone to see what needs attention.
  2. Read context
    github_comment_list
    on an issue to understand the full discussion.
  3. Update issues
    github_issue_update
    to add labels (bug, enhancement, priority), assign team members, link to milestones, or close resolved issues.
  4. Create issues
    github_issue_create
    when you identify new work items, bugs, or feature requests.
When triaging, check for duplicate issues first using
github_search
before creating new ones.
整理并管理议题积压:
  1. 列出议题 — 使用
    github_issue_list
    按状态、标签或里程碑筛选,查看需要处理的议题。
  2. 查看上下文 — 使用
    github_comment_list
    查看议题下的完整讨论内容。
  3. 更新议题 — 使用
    github_issue_update
    添加标签(bug、enhancement、priority)、分配团队成员、关联里程碑或关闭已解决的议题。
  4. 创建议题 — 当发现新工作项、bug或功能请求时,使用
    github_issue_create
    创建议题。
处理议题时,先使用
github_search
检查是否存在重复议题,再创建新议题。

Workflow: Release Management

发布管理工作流

Cut releases with proper versioning and changelogs:
  1. Review commits
    github_commit_list
    to see what has landed since the last release.
  2. Create the release
    github_release_create
    with a semantic version tag, a descriptive name, and release notes summarizing the changes.
Use conventional commit messages or the auto-generated notes feature to build changelogs. Tag format should follow the project's convention (e.g.,
v1.2.0
or
1.2.0
).
通过规范的版本控制和变更日志创建发布版本:
  1. 查看提交记录 — 使用
    github_commit_list
    查看上次发布以来的所有提交。
  2. 创建发布版本 — 使用
    github_release_create
    指定语义化版本标签、描述性名称,以及总结变更内容的发布说明。
使用约定式提交信息或自动生成说明功能来构建变更日志。标签格式应遵循项目约定(如
v1.2.0
1.2.0
)。

Workflow: CI/CD

CI/CD工作流

Monitor and trigger GitHub Actions workflows:
  1. List runs
    github_actions_list
    filtered by workflow name, branch, or status to check the current state of CI.
  2. Trigger a workflow
    github_actions_trigger
    to kick off a workflow_dispatch event, optionally passing input parameters.
  3. Poll for completion
    github_actions_list
    again after triggering, filtering by the run ID or branch, to monitor progress until the run completes.
When a workflow fails, use
github_actions_list
to identify the failing run, then investigate the related commits and PR for debugging context.
监控并触发GitHub Actions工作流:
  1. 列出运行记录 — 使用
    github_actions_list
    按工作流名称、分支或状态筛选,查看CI的当前状态。
  2. 触发工作流 — 使用
    github_actions_trigger
    触发workflow_dispatch事件,可选择性传入输入参数。
  3. 轮询完成状态 — 触发后再次使用
    github_actions_list
    ,按运行ID或分支筛选,监控进度直到运行完成。
当工作流失败时,使用
github_actions_list
定位失败的运行记录,然后调查相关提交和PR以获取调试上下文。

Safety 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:
  1. GITHUB_TOKEN
    environment variable
  2. GH_TOKEN
    environment variable
  3. gh auth token
    CLI fallback (if
    gh
    is installed and authenticated)
Required scopes:
  • repo
    — full access to private repositories (read/write code, issues, PRs, releases, Actions)
  • public_repo
    — sufficient if you only work with public repositories
  • gist
    — needed for
    github_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工具通过以下来源的个人访问令牌进行身份认证,按顺序检查:
  1. GITHUB_TOKEN
    环境变量
  2. GH_TOKEN
    环境变量
  3. gh auth token
    CLI回退(若已安装并认证
    gh
所需权限范围:
  • repo
    — 私有仓库的完整访问权限(读写代码、议题、PR、发布版本、Actions)
  • public_repo
    — 仅处理公共仓库时足够
  • gist
    — 使用
    github_gist_create
    时需要
如需创建令牌,请访问github.com/settings/tokens并选择上述权限范围。生产环境建议使用限定于特定仓库的细粒度令牌。