feat: Claude Code PR review & @claude comment Actions#3
Conversation
- Auto review on PR open/sync using Opus model with inline comments - @claude trigger in PR comments/reviews for on-demand assistance - Confidence scoring (≥75) to minimize false positives - Progress tracking, git blame analysis, full file context reading Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lishuceo
left a comment
There was a problem hiding this comment.
PR Review: Claude Code PR Review & @claude Comment Actions
总体评价
这是一个高质量的 PR。Prompt 工程做得很好——confidence scoring、false positive filters、分步 review 流程都是经过思考的设计。整体可以合并,有几个小点值得注意。
Action 运行状态
从 CI 日志看到本次 action 因 workflow validation 被跳过:
Skipping action due to workflow validation: Workflow file must exist and have identical content to the version on the repository's default branch.
这是预期行为——claude-code-action@v1 要求 workflow 文件已存在于 default branch(安全机制,防止 PR 注入恶意 workflow)。合并到 main 后才会生效。 PR body 的 test plan 第一项 "Verify this PR itself triggers the review action" 实际上无法通过,建议更新。
亮点
- Confidence scoring (≥75) — 有效减少 false positive 噪音,这是很多 AI review 方案缺失的
- False positive filters — 明确列出不报告的类别(pre-existing issues, style nitpicks, hypothetical problems),指导性很强
concurrency: cancel-in-progress— PR review 有并发控制,push 新 commit 会取消旧 review,避免浪费- Draft PR 跳过 —
if: !github.event.pull_request.draft,正确 fetch-depth: 0— 拉全量 git history,git blame和git log才能工作- $10 budget cap — 合理的单次上限
- 分步 review prompt — Setup → Process → What to Look For → Output Format,结构清晰
需关注的问题
详见 inline comments。
| # | 严重度 | 问题 |
|---|---|---|
| 1 | Medium | claude-comment.yml 缺少 concurrency 控制 |
| 2 | Low | --model opus shorthand 可能随 CLI 版本变化 |
| 3 | Info | Test plan 第一项因 workflow validation 机制无法验证 |
| 4 | Info | 无每日预算上限,write 权限用户可反复触发 |
🤖 Reviewed by Claude Code
| actions: read | ||
|
|
||
| jobs: | ||
| respond: |
There was a problem hiding this comment.
[Medium] 缺少 concurrency 控制
pr-review.yml 有 concurrency: cancel-in-progress: true,但 claude-comment.yml 没有。如果有人快速发多条 @claude 评论,会同时触发多个 action 实例,可能导致:
- 重复回复
- 并发超出 API budget
- 竞争写同一个 PR comment
建议加上:
concurrency:
group: claude-comment-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: true或者如果希望每条 @claude 评论都得到回复(不取消),至少加 cancel-in-progress: false 做队列化。
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| track_progress: true | ||
| claude_args: | | ||
| --model opus |
There was a problem hiding this comment.
[Low] --model opus shorthand 建议改为完整 model ID
Claude Code CLI 支持 opus 作为 shorthand,但它解析为当前最新的 Opus 模型。如果未来 CLI 更新改变了 shorthand 映射,review 质量可能突然变化且不易察觉。
建议显式指定完整 model ID:
--model claude-opus-4-6这样 review 结果在不同时间点保持一致,也方便回溯。
|
|
||
| jobs: | ||
| respond: | ||
| if: | |
There was a problem hiding this comment.
[Info] issue_comment 事件在 fork PR 上的行为
issue_comment 事件的 GITHUB_TOKEN 权限由 base repo 决定(不是 fork),所以 fork PR 的评论也能正常触发。但 actions/checkout@v4 默认 checkout 的是 base repo 的代码,不是 fork 的 PR 分支。
对于 fork PR 的 @claude 请求,Claude 读到的代码可能不包含 PR 的变更。如果需要支持 fork PR,checkout step 需要改为:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}不过 claude-code-action@v1 可能内部已处理此问题,如果只在自有仓库使用可以忽略。
| claude_args: | | ||
| --model opus | ||
| --max-budget-usd 10 | ||
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr checks:*),Bash(git log:*),Bash(git blame:*),Bash(git diff:*),Read,Glob,Grep" |
There was a problem hiding this comment.
[Info] allowedTools 白名单完整性
当前白名单:
mcp__github_inline_comment__create_inline_comment
Bash(gh pr comment:*)
Bash(gh pr diff:*)
Bash(gh pr view:*)
Bash(gh pr checks:*)
Bash(git log:*)
Bash(git blame:*)
Bash(git diff:*)
Read, Glob, Grep
看起来很完整。几个观察:
Write/Edit未列入,意味着 Claude 不能修改代码文件(只能 review,不能 auto-fix)。这是故意的且合理的——review bot 不应该修改代码。Bash(git show:*)可能会用到(查看特定 commit 内容),但Read+git diff基本可以覆盖。Bash(gh api:*)未列入,限制了 Claude 对 GitHub API 的访问范围。这是好的安全限制。
- Add concurrency control to claude-comment workflow (cancel-in-progress: false for queue behavior) - Use explicit model ID claude-opus-4-6 instead of opus shorthand Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
* feat: add Claude Code PR review and @claude comment GitHub Actions - Auto review on PR open/sync using Opus model with inline comments - @claude trigger in PR comments/reviews for on-demand assistance - Confidence scoring (≥75) to minimize false positives - Progress tracking, git blame analysis, full file context reading Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address PR review feedback - Add concurrency control to claude-comment workflow (cancel-in-progress: false for queue behavior) - Use explicit model ID claude-opus-4-6 instead of opus shorthand Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: use opus alias to always track latest model Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
New Files
.github/workflows/pr-review.yml— Auto PR review.github/workflows/claude-comment.yml— @claude comment responsePrerequisites
Add
ANTHROPIC_API_KEYto repo Settings → Secrets → ActionsTest Plan
@claude what does this PR do?to test comment response🤖 Generated with Claude Code