Skip to content

Add Claude Code GitHub Workflow - #29

Merged
dragon-fish merged 2 commits into
masterfrom
add-claude-github-actions-1791382693917
Oct 7, 2026
Merged

dragon-fish merged 2 commits into
masterfrom
add-claude-github-actions-1791382693917

Conversation

@dragon-fish

@dragon-fish dragon-fish commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

🤖 Installing Claude Code GitHub App

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

What is Claude Code?

Claude Code is an AI coding agent that can help with:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

How it works

Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.

Important Notes

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

There's more information in the Claude Code action repo.

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!

Sourcery 摘要

添加 GitHub Actions 工作流,用于自动执行 Claude Code 拉取请求审查以及按需提供代码库协助。

新功能:

  • 为新建、更新、重新打开或标记为准备审查的拉取请求,添加自动执行 Claude Code 审查的功能。
  • 允许代码库用户在议题和拉取请求评论或审查中提及 @claude,以调用 Claude Code。

CI:

  • 为 Claude Code 工作流配置 GitHub Actions 权限和身份验证,包括访问拉取请求上下文和 CI 结果的权限。
Original summary in English

Summary by Sourcery

Add GitHub Actions workflows for automated Claude Code pull request reviews and on-demand repository assistance.

New Features:

  • Add automated Claude Code review runs for pull requests as they are opened, updated, reopened, or marked ready for review.
  • Enable repository users to invoke Claude Code from issue and pull request comments or reviews by mentioning @claude.

CI:

  • Configure GitHub Actions permissions and authentication for Claude Code workflows, including access to pull request context and CI results.

@sourcery-ai

sourcery-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

审查者指南

介绍两个集成 Claude Code 的 GitHub Actions 工作流:一个会自动审查拉取请求并发布行内评论,另一个会使用仓库的 OAuth 密钥和限定范围的 GitHub 权限,响应 issues 和拉取请求讨论中看似经过授权的 @claude 提及。

@claude 提及处理流程图

sequenceDiagram
    actor User
    participant GitHub
    participant Workflow as claude.yml
    participant Action as ClaudeCodeAction
    participant Repository

    User->>GitHub: 创建包含 @claude 的 issue 或拉取请求讨论评论
    GitHub->>Workflow: issue_comment / pull_request_review_comment / pull_request_review / issues
    Workflow->>Workflow: contains(event text, @claude)
    Workflow->>Action: 运行 Claude Code
    Action->>Repository: 读取仓库和讨论上下文
    Action-->>GitHub: 响应请求
Loading

自动拉取请求审查流程图

sequenceDiagram
    participant GitHub
    participant Workflow as claude-code-review.yml
    participant Action as ClaudeCodeAction
    participant PullRequest

    GitHub->>Workflow: pull_request opened / synchronize / ready_for_review / reopened
    Workflow->>Action: 运行 /code-review:code-review
    Action->>PullRequest: 读取拉取请求上下文
    Action->>PullRequest: create_inline_comment
Loading

文件级变更

变更 详细信息 文件
添加一个事件驱动的工作流,用于在拉取请求上执行 Claude 辅助的自动代码审查。
  • 在选定的拉取请求生命周期事件上运行。
  • 检出仓库,并使用已配置的 OAuth 密钥调用 Claude Code action。
  • 加载 code-review 插件,并将审查操作限制为创建行内评论。
  • 授予对仓库、拉取请求和 issue 元数据的读取权限,以及 OIDC 令牌访问权限。
.github/workflows/claude-code-review.yml
添加一个由提及触发的工作流,用于处理来自 issues 和审查的交互式 Claude Code 请求。
  • 监听 issue、issue-comment、pull-request-review 和 pull-request-review-comment 事件。
  • 仅当相关标题、正文或审查文本中出现 @claude 时才执行。
  • 使用仓库、拉取请求、issue、Actions-read 和 OIDC 权限调用 Claude Code。
  • 使用已配置的 OAuth 密钥,同时将自定义提示词和工具配置保留为可选项。
.github/workflows/claude.yml

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,以根据该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,以随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果你已经处理完所有评论并且不想再看到它们,这会非常有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,以忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义你的使用体验

访问你的控制面板:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南及其他功能。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Introduces two GitHub Actions workflows that integrate Claude Code: one automatically reviews pull requests and posts inline comments, while the other responds to authorized-looking @claude mentions across issues and pull request discussions using the repository’s OAuth secret and scoped GitHub permissions.

Sequence diagram for @claude mention handling

sequenceDiagram
    actor User
    participant GitHub
    participant Workflow as claude.yml
    participant Action as ClaudeCodeAction
    participant Repository

    User->>GitHub: Create issue or pull request discussion comment containing @claude
    GitHub->>Workflow: issue_comment / pull_request_review_comment / pull_request_review / issues
    Workflow->>Workflow: contains(event text, @claude)
    Workflow->>Action: Run Claude Code
    Action->>Repository: Read repository and discussion context
    Action-->>GitHub: Respond to the request
Loading

Sequence diagram for automated pull request review

sequenceDiagram
    participant GitHub
    participant Workflow as claude-code-review.yml
    participant Action as ClaudeCodeAction
    participant PullRequest

    GitHub->>Workflow: pull_request opened / synchronize / ready_for_review / reopened
    Workflow->>Action: Run /code-review:code-review
    Action->>PullRequest: Read pull request context
    Action->>PullRequest: create_inline_comment
Loading

File-Level Changes

Change Details Files
Adds an event-driven workflow for automated Claude-assisted code review on pull requests.
  • Runs on selected pull request lifecycle events.
  • Checks out the repository and invokes the Claude Code action with the configured OAuth secret.
  • Loads the code-review plugin and restricts the review action to inline comment creation.
  • Grants read access to repository, pull request, and issue metadata plus OIDC token access.
.github/workflows/claude-code-review.yml
Adds a mention-triggered workflow for interactive Claude Code requests from issues and reviews.
  • Listens for issue, issue-comment, pull-request-review, and pull-request-review-comment events.
  • Gates execution on @claude appearing in the relevant title, body, or review text.
  • Invokes Claude Code with repository, pull request, issue, Actions-read, and OIDC permissions.
  • Uses the configured OAuth secret while leaving custom prompt and tool configuration optional.
.github/workflows/claude.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ipe-plugin-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: bdaac8a
Status: ✅  Deploy successful!
Preview URL: https://808058de.plugin-registry.pages.dev
Branch Preview URL: https://add-claude-github-actions-17.plugin-registry.pages.dev

View logs

@dragon-fish
dragon-fish merged commit b5ef34f into master Oct 7, 2026
2 of 3 checks passed
@dragon-fish
dragon-fish deleted the add-claude-github-actions-1791382693917 branch October 7, 2026 14:20

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好——我发现了 8 个问题

面向 AI Agent 的提示词
请处理本次代码审查中的评论:

## 单条评论

### 评论 1
<location path=".github/workflows/claude.yml" line_range="16" />
<code_context>
+jobs:
+  claude:
+    if: |
+      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
+      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
+      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
</code_context>
<issue_to_address>
**未经授权的用户可以启动 Claude 运行**

当没有仓库写入权限的用户在 issue、拉取请求评论、审查评论或新 issue 中提及 `@claude` 时,`claude` job 的条件只检查是否包含该提及,却没有检查发送者的权限。因此,外部用户可以使用 `CLAUDE_CODE_OAUTH_TOKEN` 启动一次运行,并提交 Agent 请求,消耗仓库的 Claude 使用量。

在启动 job 之前,要求事件发送者具有仓库写入权限。

另见 `.github/workflows/claude.yml:19`。
</issue_to_address>

### 评论 2
<location path=".github/workflows/claude.yml" line_range="35" />
<code_context>
+
+      - name: Run Claude Code Review
+        id: claude-review
+        uses: anthropics/claude-code-action@v1
+        with:
+          claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
</code_context>
<issue_to_address>
**Claude 拥有不受限制的 shell 访问权限**

当 Claude 处理要求其运行 shell 命令的提示词时,Claude Code 的默认工具包括 `Bash`,而此工作流没有对这些工具进行限制。因此,提示词可以在运行器上执行任意命令,这违背了仅限仓库操作的既定限制,并可能暴露 job 可用的凭据。

为此工作流配置严格的工具允许列表,并避免向 Claude 可以运行的子进程暴露凭据。

另见 `.github/workflows/claude.yml:49`。
</issue_to_address>

### 评论 3
<location path=".github/workflows/claude-code-review.yml" line_range="24" />
<code_context>
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: read
+      issues: read
+      id-token: write
</code_context>
<issue_to_address>
**审查评论永远不会出现**

当 Claude 尝试发布审查评论或回复时,`claude-code-review` 工作流授予其 GitHub token 对拉取请求和 issue 的仅读权限,因此请求的评论和回复写入操作会失败,用户看不到发布结果。

为审查工作流授予拉取请求和 issue 所需的写入权限。

另见 `.github/workflows/claude.yml:23-25`。
</issue_to_address>

### 评论 4
<location path=".github/workflows/claude-code-review.yml" line_range="4" />
<code_context>
+name: Claude Code Review
+
+on:
+  pull_request:
+    types: [opened, synchronize, ready_for_review, reopened]
+    # Optional: Only run on specific file changes
</code_context>
<issue_to_address>
**来自 fork 的审查无法启动**

当拉取请求来自 fork 时,GitHub 会阻止由 fork PR 触发的 `pull_request` 工作流访问仓库机密,导致 `CLAUDE_CODE_OAUTH_TOKEN` 为空;审查 action 无法进行身份验证,因此 fork PR 不会收到自动审查。

通过可信工作流运行 fork 审查,使其能够访问 OAuth token,同时不会将该 token 暴露给由 fork 控制的代码。

另见 `.github/workflows/claude-code-review.yml:5`、`.github/workflows/claude-code-review.yml:38`。
</issue_to_address>

### 评论 5
<location path=".github/workflows/claude.yml" line_range="23-24" />
<code_context>
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: read
+      issues: read
+      id-token: write
+
</code_context>
<issue_to_address>
**Claude 回复永远不会出现**

当 Claude 尝试发布 issue 回复或内联审查评论时,`claude` 工作流授予其 GitHub token 对 issue 和拉取请求的仅读权限,因此请求的评论写入操作会失败,用户看不到回复或内联评论。

为工作流授予 issue 和拉取请求所需的写入权限。

另见 `.github/workflows/claude-code-review.yml:23-27`。
</issue_to_address>

### 评论 6
<location path=".github/workflows/claude.yml" line_range="38" />
<code_context>
+name: Claude Code Review
+
+on:
+  pull_request:
</code_context>
<issue_to_address>
**API 密钥无法通过 OAuth 身份验证**

当配置的 secret 包含 Anthropic API 密钥而不是 Claude Code OAuth token 时,action 会通过 `claude_code_oauth_token` 输入接收该 secret。因此,按照描述存储在其中的 Anthropic API 密钥并不是预期的 OAuth 凭据,Claude 身份验证会失败。

在该 secret 中存储 Claude Code OAuth token,或使用 API 密钥配置 action 的 API 密钥输入项。

另见 `.github/workflows/claude-code-review.yml:38`。
</issue_to_address>

### 评论 7
<location path=".github/workflows/claude.yml" line_range="8-9" />
<code_context>
+    types: [created]
+  pull_request_review_comment:
+    types: [created]
+  issues:
+    types: [opened, assigned]
+  pull_request_review:
+    types: [submitted]
</code_context>
<issue_to_address>
**Issue 中的提及会触发重复运行**

当包含 `@claude` 的 issue 在打开后被分配时,`issues` 订阅会分别针对 `opened` 和 `assigned` 启动一次运行,因此未发生变化的提及会再次启动运行,并可能产生重复回复或重复操作。

除非希望分配操作启动新运行,否则请从 issue 事件类型中移除 `assigned`。
</issue_to_address>

### 评论 8
<location path=".github/workflows/claude.yml" line_range="22" />
<code_context>
+
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: read
+      issues: read
</code_context>
<issue_to_address>
**无法推送代码变更**

当请求要求 Claude 提交或推送代码变更时,Claude 编码 job 获得的 GitHub token 仅具有 `contents: read` 权限,因此无法向仓库推送分支或提交变更。代码编辑请求因此不会留下调用者可使用的变更。

如果需要写入仓库,请授予 job `contents: write` 权限;或者将工作流限制为不需要持久化代码变更的请求。
</issue_to_address>

Sourcery 评估

需要人工审查。 请先处理 8 个发现的问题。此外,此变更引入了一个使用 OAuth secret 和 id-token: write 权限的外部 GitHub Action,并允许来自 issue 或审查评论的提示词调用它;任何错误都可能暴露仓库上下文或凭据,或消耗工作流的信任边界。回滚可以阻止后续运行,但已经触发的运行所造成的 token 使用或数据暴露无法撤销。

阻塞性问题:.github/workflows/claude.yml:16、.github/workflows/claude.yml:35、.github/workflows/claude-code-review.yml:24、.github/workflows/claude-code-review.yml:4、.github/workflows/claude.yml:24,以及另外 3 个问题


Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享它们 ✨
Original comment in English

Hey - I've found 8 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/claude.yml" line_range="16" />
<code_context>
+jobs:
+  claude:
+    if: |
+      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
+      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
+      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
</code_context>
<issue_to_address>
**Unauthorized users start Claude runs**

When a user without repository write access mentions `@claude` in an issue or pull request comment, review, or new issue, the `claude` job condition checks for the mention but not the sender’s permissions, so an outsider starts a run with `CLAUDE_CODE_OAUTH_TOKEN` and can submit agent requests that consume the repository’s Claude usage.

Require the event’s sender to have repository write access before starting the job.

Also at `.github/workflows/claude.yml:19`.
</issue_to_address>

### Comment 2
<location path=".github/workflows/claude.yml" line_range="35" />
<code_context>
+
+      - name: Run Claude Code Review
+        id: claude-review
+        uses: anthropics/claude-code-action@v1
+        with:
+          claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
</code_context>
<issue_to_address>
**Claude has unrestricted shell access**

When claude processes a prompt that asks it to run shell commands, claude Code’s default tools include `Bash`, and this workflow does not restrict them; a prompt can therefore run arbitrary commands on the runner, contrary to the stated limitation to repository operations, and expose credentials available to the job.

Configure a restrictive tool allowlist for this workflow and avoid exposing credentials to subprocesses Claude can run.

Also at `.github/workflows/claude.yml:49`.
</issue_to_address>

### Comment 3
<location path=".github/workflows/claude-code-review.yml" line_range="24" />
<code_context>
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: read
+      issues: read
+      id-token: write
</code_context>
<issue_to_address>
**Review comments never appear**

When claude attempts to publish a review comment or reply, the `claude-code-review` workflow gives its GitHub token only read access to pull requests and issues, so the requested comment and reply writes fail and users see no posted result.

Grant the review workflow the required write permissions for pull requests and issues.

Also at `.github/workflows/claude.yml:23-25`.
</issue_to_address>

### Comment 4
<location path=".github/workflows/claude-code-review.yml" line_range="4" />
<code_context>
+name: Claude Code Review
+
+on:
+  pull_request:
+    types: [opened, synchronize, ready_for_review, reopened]
+    # Optional: Only run on specific file changes
</code_context>
<issue_to_address>
**Fork reviews fail to start**

When the pull request comes from a fork, gitHub withholds repository secrets from `pull_request` workflows triggered by fork PRs, leaving `CLAUDE_CODE_OAUTH_TOKEN` empty; the review action cannot authenticate, so fork PRs receive no automated review.

Run fork reviews through a trusted workflow that can access the OAuth token without exposing it to fork-controlled code.

Also at `.github/workflows/claude-code-review.yml:5`, `.github/workflows/claude-code-review.yml:38`.
</issue_to_address>

### Comment 5
<location path=".github/workflows/claude.yml" line_range="23-24" />
<code_context>
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: read
+      issues: read
+      id-token: write
+
</code_context>
<issue_to_address>
**Claude replies never appear**

When claude tries to post an issue reply or inline review comment, the `claude` workflow gives its GitHub token only read access to issues and pull requests, so the requested comment writes fail and users see no replies or inline comments.

Grant the workflow the required write permissions for issues and pull requests.

Also at `.github/workflows/claude-code-review.yml:23-27`.
</issue_to_address>

### Comment 6
<location path=".github/workflows/claude.yml" line_range="38" />
<code_context>
+name: Claude Code Review
+
+on:
+  pull_request:
</code_context>
<issue_to_address>
**API key fails OAuth authentication**

When the configured secret contains an Anthropic API key rather than a Claude Code OAuth token, the action receives the secret through its `claude_code_oauth_token` input, so an Anthropic API key stored there as described is not the expected OAuth credential and Claude authentication fails.

Store a Claude Code OAuth token in that secret or configure the action’s API-key input with an API key.

Also at `.github/workflows/claude-code-review.yml:38`.
</issue_to_address>

### Comment 7
<location path=".github/workflows/claude.yml" line_range="8-9" />
<code_context>
+    types: [created]
+  pull_request_review_comment:
+    types: [created]
+  issues:
+    types: [opened, assigned]
+  pull_request_review:
+    types: [submitted]
</code_context>
<issue_to_address>
**Issue mentions trigger duplicate runs**

When an issue containing `@claude` is assigned after it is opened, the `issues` subscription starts a run for both `opened` and `assigned`, so the unchanged mention starts another run and can produce duplicate responses or repeated actions.

Remove `assigned` from the issue event types unless assignment is intended to start a new run.
</issue_to_address>

### Comment 8
<location path=".github/workflows/claude.yml" line_range="22" />
<code_context>
+
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: read
+      issues: read
</code_context>
<issue_to_address>
**Code changes cannot be pushed**

When a request requires Claude to commit or push code changes, the Claude coding job receives a GitHub token with `contents: read`, so it cannot push a branch or commit changes to the repository. Code-editing requests therefore leave no changes for the caller to use.

Grant the job `contents: write` when repository writes are intended, or constrain the workflow to requests that do not require persisted code changes.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 8 findings to address first, and this adds an externally supplied GitHub Action with an OAuth secret and id-token: write permission, and allows prompts from issue or review comments to invoke it; a mistake could expose repository context or credentials or consume the workflow's trust boundary. Reverting stops future runs, but any token use or data exposure from an already-triggered run cannot be undone.

Blocking findings: .github/workflows/claude.yml:16, .github/workflows/claude.yml:35, .github/workflows/claude-code-review.yml:24, .github/workflows/claude-code-review.yml:4, .github/workflows/claude.yml:24, and 3 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · 未经授权的用户可以启动 Claude 运行

当没有仓库写入权限的用户在 issue、拉取请求评论、审查评论或新 issue 中提及 @claude 时,claude job 的条件只检查是否包含该提及,却没有检查发送者的权限。因此,外部用户可以使用 CLAUDE_CODE_OAUTH_TOKEN 启动一次运行,并提交 Agent 请求,消耗仓库的 Claude 使用量。

在启动 job 之前,要求事件发送者具有仓库写入权限。

另见 .github/workflows/claude.yml:19。

面向 AI Agent 的提示词
在 `.github/workflows/claude.yml` 第 16 行:

**未经授权的用户可以启动 Claude 运行**

当没有仓库写入权限的用户在 issue、拉取请求评论、审查评论或新 issue 中提及 `@claude` 时,`claude` job 的条件只检查是否包含该提及,却没有检查发送者的权限。因此,外部用户可以使用 `CLAUDE_CODE_OAUTH_TOKEN` 启动一次运行,并提交 Agent 请求,消耗仓库的 Claude 使用量。

在启动 job 之前,要求事件发送者具有仓库写入权限。

另见 `.github/workflows/claude.yml:19`。
Original comment in English

🟠 High · Unauthorized users start Claude runs

When a user without repository write access mentions @claude in an issue or pull request comment, review, or new issue, the claude job condition checks for the mention but not the sender’s permissions, so an outsider starts a run with CLAUDE_CODE_OAUTH_TOKEN and can submit agent requests that consume the repository’s Claude usage.

Require the event’s sender to have repository write access before starting the job.

Also at .github/workflows/claude.yml:19.

Prompt for AI agents
In `.github/workflows/claude.yml` at line 16:

**Unauthorized users start Claude runs**

When a user without repository write access mentions `@claude` in an issue or pull request comment, review, or new issue, the `claude` job condition checks for the mention but not the sender’s permissions, so an outsider starts a run with `CLAUDE_CODE_OAUTH_TOKEN` and can submit agent requests that consume the repository’s Claude usage.

Require the event’s sender to have repository write access before starting the job.

Also at `.github/workflows/claude.yml:19`.


- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · Claude 拥有不受限制的 shell 访问权限

当 Claude 处理要求其运行 shell 命令的提示词时,Claude Code 的默认工具包括 Bash,而此工作流没有对这些工具进行限制。因此,提示词可以在运行器上执行任意命令,这违背了仅限仓库操作的既定限制,并可能暴露 job 可用的凭据。

为此工作流配置严格的工具允许列表,并避免向 Claude 可以运行的子进程暴露凭据。

另见 .github/workflows/claude.yml:49。

面向 AI Agent 的提示词
在 `.github/workflows/claude.yml` 第 35 行:

**Claude 拥有不受限制的 shell 访问权限**

当 Claude 处理要求其运行 shell 命令的提示词时,Claude Code 的默认工具包括 `Bash`,而此工作流没有对这些工具进行限制。因此,提示词可以在运行器上执行任意命令,这违背了仅限仓库操作的既定限制,并可能暴露 job 可用的凭据。

为此工作流配置严格的工具允许列表,并避免向 Claude 可以运行的子进程暴露凭据。

另见 `.github/workflows/claude.yml:49`。
Original comment in English

🟠 High · Claude has unrestricted shell access

When claude processes a prompt that asks it to run shell commands, claude Code’s default tools include Bash, and this workflow does not restrict them; a prompt can therefore run arbitrary commands on the runner, contrary to the stated limitation to repository operations, and expose credentials available to the job.

Configure a restrictive tool allowlist for this workflow and avoid exposing credentials to subprocesses Claude can run.

Also at .github/workflows/claude.yml:49.

Prompt for AI agents
In `.github/workflows/claude.yml` at line 35:

**Claude has unrestricted shell access**

When claude processes a prompt that asks it to run shell commands, claude Code’s default tools include `Bash`, and this workflow does not restrict them; a prompt can therefore run arbitrary commands on the runner, contrary to the stated limitation to repository operations, and expose credentials available to the job.

Configure a restrictive tool allowlist for this workflow and avoid exposing credentials to subprocesses Claude can run.

Also at `.github/workflows/claude.yml:49`.

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · 审查评论永远不会出现

当 Claude 尝试发布审查评论或回复时,claude-code-review 工作流授予其 GitHub token 对拉取请求和 issue 的仅读权限,因此请求的评论和回复写入操作会失败,用户看不到发布结果。

为审查工作流授予拉取请求和 issue 所需的写入权限。

另见 .github/workflows/claude.yml:23-25。

面向 AI Agent 的提示词
在 `.github/workflows/claude-code-review.yml` 第 24 行:

**审查评论永远不会出现**

当 Claude 尝试发布审查评论或回复时,`claude-code-review` 工作流授予其 GitHub token 对拉取请求和 issue 的仅读权限,因此请求的评论和回复写入操作会失败,用户看不到发布结果。

为审查工作流授予拉取请求和 issue 所需的写入权限。

另见 `.github/workflows/claude.yml:23-25`。
Original comment in English

🟠 High · Review comments never appear

When claude attempts to publish a review comment or reply, the claude-code-review workflow gives its GitHub token only read access to pull requests and issues, so the requested comment and reply writes fail and users see no posted result.

Grant the review workflow the required write permissions for pull requests and issues.

Also at .github/workflows/claude.yml:23-25.

Prompt for AI agents
In `.github/workflows/claude-code-review.yml` at line 24:

**Review comments never appear**

When claude attempts to publish a review comment or reply, the `claude-code-review` workflow gives its GitHub token only read access to pull requests and issues, so the requested comment and reply writes fail and users see no posted result.

Grant the review workflow the required write permissions for pull requests and issues.

Also at `.github/workflows/claude.yml:23-25`.

name: Claude Code Review

on:
pull_request:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · 来自 fork 的审查无法启动

当拉取请求来自 fork 时,GitHub 会阻止由 fork PR 触发的 pull_request 工作流访问仓库机密,导致 CLAUDE_CODE_OAUTH_TOKEN 为空;审查 action 无法进行身份验证,因此 fork PR 不会收到自动审查。

通过可信工作流运行 fork 审查,使其能够访问 OAuth token,同时不会将该 token 暴露给由 fork 控制的代码。

另见 .github/workflows/claude-code-review.yml:5、.github/workflows/claude-code-review.yml:38。

面向 AI Agent 的提示词
在 `.github/workflows/claude-code-review.yml` 第 4 行:

**来自 fork 的审查无法启动**

当拉取请求来自 fork 时,GitHub 会阻止由 fork PR 触发的 `pull_request` 工作流访问仓库机密,导致 `CLAUDE_CODE_OAUTH_TOKEN` 为空;审查 action 无法进行身份验证,因此 fork PR 不会收到自动审查。

通过可信工作流运行 fork 审查,使其能够访问 OAuth token,同时不会将该 token 暴露给由 fork 控制的代码。

另见 `.github/workflows/claude-code-review.yml:5`、`.github/workflows/claude-code-review.yml:38`。
Original comment in English

🟠 High · Fork reviews fail to start

When the pull request comes from a fork, gitHub withholds repository secrets from pull_request workflows triggered by fork PRs, leaving CLAUDE_CODE_OAUTH_TOKEN empty; the review action cannot authenticate, so fork PRs receive no automated review.

Run fork reviews through a trusted workflow that can access the OAuth token without exposing it to fork-controlled code.

Also at .github/workflows/claude-code-review.yml:5, .github/workflows/claude-code-review.yml:38.

Prompt for AI agents
In `.github/workflows/claude-code-review.yml` at line 4:

**Fork reviews fail to start**

When the pull request comes from a fork, gitHub withholds repository secrets from `pull_request` workflows triggered by fork PRs, leaving `CLAUDE_CODE_OAUTH_TOKEN` empty; the review action cannot authenticate, so fork PRs receive no automated review.

Run fork reviews through a trusted workflow that can access the OAuth token without exposing it to fork-controlled code.

Also at `.github/workflows/claude-code-review.yml:5`, `.github/workflows/claude-code-review.yml:38`.

Comment on lines +23 to +24
pull-requests: read
issues: read

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · Claude 回复永远不会出现

当 Claude 尝试发布 issue 回复或内联审查评论时,claude 工作流授予其 GitHub token 对 issue 和拉取请求的仅读权限,因此请求的评论写入操作会失败,用户看不到回复或内联评论。

为工作流授予 issue 和拉取请求所需的写入权限。

另见 .github/workflows/claude-code-review.yml:23-27。

面向 AI Agent 的提示词
在 `.github/workflows/claude.yml` 第 23-24 行:

**Claude 回复永远不会出现**

当 Claude 尝试发布 issue 回复或内联审查评论时,`claude` 工作流授予其 GitHub token 对 issue 和拉取请求的仅读权限,因此请求的评论写入操作会失败,用户看不到回复或内联评论。

为工作流授予 issue 和拉取请求所需的写入权限。

另见 `.github/workflows/claude-code-review.yml:23-27`。
Original comment in English

🟠 High · Claude replies never appear

When claude tries to post an issue reply or inline review comment, the claude workflow gives its GitHub token only read access to issues and pull requests, so the requested comment writes fail and users see no replies or inline comments.

Grant the workflow the required write permissions for issues and pull requests.

Also at .github/workflows/claude-code-review.yml:23-27.

Prompt for AI agents
In `.github/workflows/claude.yml` at lines 23-24:

**Claude replies never appear**

When claude tries to post an issue reply or inline review comment, the `claude` workflow gives its GitHub token only read access to issues and pull requests, so the requested comment writes fail and users see no replies or inline comments.

Grant the workflow the required write permissions for issues and pull requests.

Also at `.github/workflows/claude-code-review.yml:23-27`.

uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · API 密钥无法通过 OAuth 身份验证

当配置的 secret 包含 Anthropic API 密钥而不是 Claude Code OAuth token 时,action 会通过 claude_code_oauth_token 输入接收该 secret。因此,按照描述存储在其中的 Anthropic API 密钥并不是预期的 OAuth 凭据,Claude 身份验证会失败。

在该 secret 中存储 Claude Code OAuth token,或使用 API 密钥配置 action 的 API 密钥输入项。

另见 .github/workflows/claude-code-review.yml:38。

面向 AI Agent 的提示词
在 `.github/workflows/claude.yml` 第 38 行:

**API 密钥无法通过 OAuth 身份验证**

当配置的 secret 包含 Anthropic API 密钥而不是 Claude Code OAuth token 时,action 会通过 `claude_code_oauth_token` 输入接收该 secret。因此,按照描述存储在其中的 Anthropic API 密钥并不是预期的 OAuth 凭据,Claude 身份验证会失败。

在该 secret 中存储 Claude Code OAuth token,或使用 API 密钥配置 action 的 API 密钥输入项。

另见 `.github/workflows/claude-code-review.yml:38`。
Original comment in English

🟠 High · API key fails OAuth authentication

When the configured secret contains an Anthropic API key rather than a Claude Code OAuth token, the action receives the secret through its claude_code_oauth_token input, so an Anthropic API key stored there as described is not the expected OAuth credential and Claude authentication fails.

Store a Claude Code OAuth token in that secret or configure the action’s API-key input with an API key.

Also at .github/workflows/claude-code-review.yml:38.

Prompt for AI agents
In `.github/workflows/claude.yml` at line 38:

**API key fails OAuth authentication**

When the configured secret contains an Anthropic API key rather than a Claude Code OAuth token, the action receives the secret through its `claude_code_oauth_token` input, so an Anthropic API key stored there as described is not the expected OAuth credential and Claude authentication fails.

Store a Claude Code OAuth token in that secret or configure the action’s API-key input with an API key.

Also at `.github/workflows/claude-code-review.yml:38`.

Comment on lines +8 to +9
issues:
types: [opened, assigned]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 中 · Issue 中的提及会触发重复运行

当包含 @claude 的 issue 在打开后被分配时,issues 订阅会分别针对 opened 和 assigned 启动一次运行,因此未发生变化的提及会再次启动运行,并可能产生重复回复或重复操作。

除非希望分配操作启动新运行,否则请从 issue 事件类型中移除 assigned。

面向 AI Agent 的提示词
在 `.github/workflows/claude.yml` 第 8-9 行:

**Issue 中的提及会触发重复运行**

当包含 `@claude` 的 issue 在打开后被分配时,`issues` 订阅会分别针对 `opened` 和 `assigned` 启动一次运行,因此未发生变化的提及会再次启动运行,并可能产生重复回复或重复操作。

除非希望分配操作启动新运行,否则请从 issue 事件类型中移除 `assigned`。
Original comment in English

🟡 Medium · Issue mentions trigger duplicate runs

When an issue containing @claude is assigned after it is opened, the issues subscription starts a run for both opened and assigned, so the unchanged mention starts another run and can produce duplicate responses or repeated actions.

Remove assigned from the issue event types unless assignment is intended to start a new run.

Prompt for AI agents
In `.github/workflows/claude.yml` at lines 8-9:

**Issue mentions trigger duplicate runs**

When an issue containing `@claude` is assigned after it is opened, the `issues` subscription starts a run for both `opened` and `assigned`, so the unchanged mention starts another run and can produce duplicate responses or repeated actions.

Remove `assigned` from the issue event types unless assignment is intended to start a new run.

(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: read

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 高 · 无法推送代码变更

当请求要求 Claude 提交或推送代码变更时,Claude 编码 job 获得的 GitHub token 仅具有 contents: read 权限,因此无法向仓库推送分支或提交变更。代码编辑请求因此不会留下调用者可使用的变更。

如果需要写入仓库,请授予 job contents: write 权限;或者将工作流限制为不需要持久化代码变更的请求。

面向 AI Agent 的提示词
在 `.github/workflows/claude.yml` 第 22 行:

**无法推送代码变更**

当请求要求 Claude 提交或推送代码变更时,Claude 编码 job 获得的 GitHub token 仅具有 `contents: read` 权限,因此无法向仓库推送分支或提交变更。代码编辑请求因此不会留下调用者可使用的变更。

如果需要写入仓库,请授予 job `contents: write` 权限;或者将工作流限制为不需要持久化代码变更的请求。
Original comment in English

🟠 High · Code changes cannot be pushed

When a request requires Claude to commit or push code changes, the Claude coding job receives a GitHub token with contents: read, so it cannot push a branch or commit changes to the repository. Code-editing requests therefore leave no changes for the caller to use.

Grant the job contents: write when repository writes are intended, or constrain the workflow to requests that do not require persisted code changes.

Prompt for AI agents
In `.github/workflows/claude.yml` at line 22:

**Code changes cannot be pushed**

When a request requires Claude to commit or push code changes, the Claude coding job receives a GitHub token with `contents: read`, so it cannot push a branch or commit changes to the repository. Code-editing requests therefore leave no changes for the caller to use.

Grant the job `contents: write` when repository writes are intended, or constrain the workflow to requests that do not require persisted code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant