Skip to content

Restore Claude Assistant workflow#8

Merged
jiejuncai-ly merged 3 commits into
lex-mainfrom
codex/restore-claude-workflow
Jun 5, 2026
Merged

Restore Claude Assistant workflow#8
jiejuncai-ly merged 3 commits into
lex-mainfrom
codex/restore-claude-workflow

Conversation

@jiejuncai-ly

Copy link
Copy Markdown

Restores the Claude Assistant workflow for automatic PR review and @claude interactions.\n\nValidation:\n- Ran actionlint against .github/workflows/claude.yaml\n- Confirmed anthropics/claude-code-action@v1 exposes the workflow inputs used here\n- Uses ubuntu-latest so the job is not blocked on unavailable self-hosted runners

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Claude finished @jiejuncai-ly's task in 1m 59s —— View job


Review 结论

有条件通过 — 2 个 P1 权限问题建议合并前修复。

问题及建议

  • [P1] .github/workflows/claude.yaml:33contents: write 权限过宽。该 workflow 的职责是 review + 评论,pull-requests: writeissues: write 已足够,contents: write 允许 Claude action 向仓库直接提交/推送代码。如遭 prompt injection,攻击者可借此写入恶意代码。建议:改为 contents: read;若 action 确实需要提交操作,在 PR 描述中显式说明原因。

  • [P1] .github/workflows/claude.yaml:47-60(Interactive 步骤):无 --allowedTools 约束。PR Review 步骤限制了工具集(仅 gh pr comment/diff/view + inline comment),但交互步骤对所有非 PR 事件(issue 评论、review 评论、issues opened/assigned)没有任何工具限制,任何有评论权限的用户都可触发无限制 Bash 执行。建议:为交互步骤也添加合理的 --allowedTools 白名单。

  • [P2] .github/workflows/claude.yaml:101-103:PR Review 步骤的 claude_args 使用 YAML literal block |,两个 flag(--system-prompt--allowedTools)用换行分隔。若 action 将整个多行字符串作为单一参数传入 CLI,两个 flag 将被合并为一个损坏的参数。建议:确认 action 支持多行 claude_args;或改用 >- 折叠换行,确保两个 flag 被正确解析为独立参数。

  • [P2] .github/workflows/claude.yaml:83,101CLAUDE_REVIEW_STANDARDS 在 PR Review 步骤中被发送两次——一次嵌入在 prompt 字段(第 83 行),一次通过 claude_args--system-prompt 传入(第 101 行)。建议:选择一种投递方式,避免重复。如果 claude-code-action@v1 提供原生的 system_prompt 输入参数,优先使用该参数,比在 claude_args 中手拼 --system-prompt 更健壮。

  • [P2] .github/workflows/claude.yaml:21pull_request: synchronize 触发器会在每次向 PR 推送新提交时发起完整 review,活跃 PR 可能产生大量重复评论。建议:添加 concurrency 配置(group: pr-review-${{ github.event.pull_request.number }}cancel-in-progress: true)限制并发,避免噪音。

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Claude finished @jiejuncai-ly's task in 3m 50s —— View job


Review 完成

  • 读取 PR diff 和工作流文件
  • 输出 review 结论

:上一次 Claude job 的评论(P1: contents: write、P1: Interactive 步骤缺少 --allowedTools、P2: claude_args 使用 |、P2: 缺少 concurrency)均与当前文件内容不符——实际文件已正确使用 contents: read、Interactive 步骤有 --allowedToolsclaude_args 使用 >-、且已配置 concurrency。以下为基于实际代码的准确 review。


Review 结论

有条件通过 — 1 个 P1 需合并前确认,3 个 P2 可后续优化。

问题及建议

  • [P1] .github/workflows/claude.yaml:64,104--system-prompt "${{ env.CLAUDE_REVIEW_STANDARDS }}" 通过 claude_args 传入,同时 PR Review 步骤还提供了 prompt: input。claude-code-action@v1 同时接收 prompt input 与 claude_args --system-prompt 时的优先级/合并行为未在本 PR 中验证,system prompt 可能被静默丢弃。另外,若未来 CLAUDE_REVIEW_STANDARDS 内容包含 " 字符,参数解析将静默损坏。建议:确认 action 是否提供原生 system_prompt: input 参数,优先使用该参数替代 claude_args --system-prompt,更健壮且无歧义。Fix this →

  • [P2] .github/workflows/claude.yaml:60-61,78-79:两个 step 的 additional_permissions: actions: read 与 job 级 permissions.actions: read(第 40 行)重复声明。建议移除两处 additional_permissions 块,或保留其中一处并添加注释说明用途区别。

  • [P2] .github/workflows/claude.yaml:63-65CLAUDE_REVIEW_STANDARDS code review 导向的系统提示被注入所有非 PR 的 @claude 交互,包括 issues: opened/assignedissue_comment 事件。用户执行 review 无关任务时(如"帮我设计接口"),review 格式约束会干扰输出。建议:为 Interactive 步骤区分事件类型的 system prompt,或在注释中说明此为有意设计。

  • [P2] .github/workflows/claude.yaml:45fetch-depth: 1 浅克隆在 PR review 场景下隐式依赖 action 使用 gh pr diff(不受 git 历史深度影响)。若 action 内部 fallback 到 git diff origin/base...HEAD,base branch 不可达会静默失败。建议增加注释标注此依赖,或改用 fetch-depth: 0

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Claude finished @jiejuncai-ly's task in 2m 0s —— View job


  • 读取 PR diff 和工作流文件
  • 输出 review 结论

Review 结论

有条件通过 — 1 个 P1 建议合并前确认,2 个 P2 可后续优化。

问题及建议

  • [P1] .github/workflows/claude.yaml:61--system-prompt "${{ env.CLAUDE_REVIEW_STANDARDS }}" 通过 claude_args: >- 传入。CLAUDE_REVIEW_STANDARDS 折叠后是含空格的长字符串(如"Next.js、React 和 LiveKit"),能否正确传递取决于 claude-code-action@v1 处理 claude_args 的方式——若 action 用 exec() 分割空白而非 shell 解析,"..." 为字面量,系统提示将在第一个空格处截断且静默失败。PR 描述仅确认了 action inputs 可用,未验证含空格的 --system-prompt 参数。建议:确认 action 是否支持原生 system_prompt: input 参数(优先使用),或在 CI 日志中验证系统提示被完整传入。Fix this →

  • [P2] .github/workflows/claude.yaml:61 vs 82:两个步骤传递审查标准的方式不一致——Interactive 步骤经 --system-prompt(系统提示槽)传入,PR Review 步骤经 prompt: 字段(用户消息槽)内联插值。两种方式对 Claude 行为的优先级不同,可能导致 Interactive 和 PR Review 的输出格式出现细微差异。建议统一为同一种传递方式。

  • [P2] .github/workflows/claude.yaml:88prompt: 字段整体为中文,但第 88 行 - Only post GitHub comments - don't submit review text as messages. 为英文,风格不一致。建议改为中文:- 只通过 GitHub 评论输出结果,不要以普通消息形式回复。

@jiejuncai-ly

jiejuncai-ly commented Jun 5, 2026

Copy link
Copy Markdown
Author

Follow-up on the latest Claude P1:

  • anthropics/claude-code-action@v1 does not expose a native system_prompt input in action.yml, so there is no supported direct replacement for the Interactive step.
  • The action parses claude_args with shell-quote in base-action/src/parse-sdk-options.ts, not with naive whitespace splitting.
  • Its base-action/test/parse-shell-args.test.ts includes a real-world case for --system-prompt 'You are helpful' and expects the full multi-word prompt as one argument.
  • PR Review no longer combines prompt: with --system-prompt; only the Interactive step uses --system-prompt, because interactive @claude requests must leave prompt unset so the user comment remains the task.

So the quoted --system-prompt "${{ env.CLAUDE_REVIEW_STANDARDS }}" path is supported by the action parser, and the latest GitHub run also completed successfully.

@jiejuncai-ly jiejuncai-ly merged commit 9d4e0e5 into lex-main Jun 5, 2026
2 checks passed
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