Skip to content

Commit 3a86800

Browse files
beihailiclaude
andcommitted
chore(ci): apply review fixes to Claude Code Action workflow
Addresses findings from the /pr-review-toolkit:review-pr pass: - Invert fork check (`fork != false`) so missing/unknown field defaults to "treat as fork, skip" rather than running and silently failing to post. - Switch bot filter from `endsWith(user.login, '[bot]')` to `user.type == 'Bot'`. The `[bot]` suffix only catches bots whose login ends that way (dependabot, github-actions, renovate); the API-native `type` flag also covers codecov, snyk-bot, mergify, etc. - Drop `issues: write`. The workflow only posts to PRs and PR comments, so `pull-requests: write` is sufficient. Noted in a comment that this means Claude can't reply on standalone-issue threads until/unless we add it back. - Bump `actions/checkout` v4 -> v6 to match deploy.yml and lighthouse.yml. - Clarify the header comment: the `@claude` filter is inside the action's `trigger_phrase`, not at the workflow `on:` layer (the old comment read like GitHub itself gated the run). - Tighten the other inline comments with a clearer "without these guards" framing and remove the ambiguous "drop --max-turns lower" phrasing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 61cba69 commit 3a86800

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

.github/workflows/claude.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Claude Code Review
22

3-
# Triggers:
4-
# - pull_request opened/synchronize/reopened -> automatic first-pass review
5-
# - issue_comment / pull_request_review_comment containing @claude -> on-demand answer
3+
# Triggers (the action itself filters comments via `trigger_phrase: '@claude'` below —
4+
# this workflow runs on every matching event and short-circuits inside the action if
5+
# the body doesn't contain the trigger phrase):
6+
# - pull_request opened/synchronize/reopened -> automatic first-pass review
7+
# - issue_comment / pull_request_review_comment (created) -> on-demand answer
68
on:
79
pull_request:
810
types: [opened, synchronize, reopened]
@@ -11,31 +13,38 @@ on:
1113
pull_request_review_comment:
1214
types: [created]
1315

16+
# Minimal permissions. Note: dropping `issues: write` means @claude on a pure issue
17+
# (not a PR) comment can be read but not replied to. Add it back if/when we want
18+
# Claude to answer standalone-issue threads.
1419
permissions:
1520
contents: read
1621
pull-requests: write
17-
issues: write
1822

1923
jobs:
2024
claude:
21-
# Skip Dependabot PRs (dep bumps rarely benefit from LLM review and burn API budget).
22-
# Skip fork PRs (GITHUB_TOKEN can't write to forks, so the action would run and silently fail).
23-
# For comment events, skip ones authored by bots to avoid reply-loops with other integrations.
25+
# Without these guards:
26+
# - Dependabot PRs would burn API budget on dep bumps that rarely need LLM review
27+
# - fork PRs would run but silently fail to post (GITHUB_TOKEN can't write to forks);
28+
# we invert the check to `fork != false` so an unknown/missing field defaults to
29+
# "treat as fork, skip" rather than running and failing silently
30+
# - bot-authored comments could create reply loops; we use `user.type == 'Bot'`
31+
# (GitHub's native flag) instead of a `[bot]` suffix check to also catch
32+
# bots with non-suffixed logins (codecov, snyk-bot, mergify, etc.)
2433
if: >-
2534
!(github.event_name == 'pull_request' && (
2635
github.event.pull_request.user.login == 'dependabot[bot]' ||
27-
github.event.pull_request.head.repo.fork == true
36+
github.event.pull_request.head.repo.fork != false
2837
)) &&
29-
!(github.event.comment != null && endsWith(github.event.comment.user.login, '[bot]'))
38+
!(github.event.comment != null && github.event.comment.user.type == 'Bot')
3039
runs-on: ubuntu-latest
3140
timeout-minutes: 15
3241
steps:
33-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v6
3443
with:
3544
fetch-depth: 0
3645
- uses: anthropics/claude-code-action@v1
3746
with:
3847
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
3948
trigger_phrase: '@claude'
40-
# Pin to Opus 4.6; drop --max-turns lower if budget gets tight.
49+
# Reduce --max-turns (currently 5) if API spend climbs.
4150
claude_args: --model claude-opus-4-6 --max-turns 5

0 commit comments

Comments
 (0)