Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

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.

P1 Badge Grant the auto-review job PR write access

When this workflow runs on a pull request, the code-review plugin is expected to publish PR feedback, but the job token is limited to pull-requests: read. Anthropic's automatic PR review examples grant pull-requests: write and describe the expected output as posted PR comments (https://github.com/anthropics/claude-code-action/blob/main/docs/solutions.md#automatic-pr-code-review); with the current read scope, review/comment creation will be denied or produce a run with no PR feedback.

Useful? React with 👍 / 👎.

issues: read
id-token: write
Comment on lines +22 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1Insufficient permissions for Claude to write back to the PR

Both this workflow and claude.yml set pull-requests: read and issues: read, but Claude needs write access to post review comments, create branches, or push commits. The claude_code_oauth_token authenticates Claude with the AI backend; GitHub API operations (posting comments, creating reviews, pushing code) go through the job's GITHUB_TOKEN, which is governed by this permissions block. With only read on pull-requests and issues, any attempt by Claude to leave a comment or open a review will fail at runtime. At minimum, pull-requests: write and issues: write are required; contents: write is needed if Claude should be able to commit changes. The same issue applies to the identical permissions block in claude.yml (lines 21–26).

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/claude-code-review.yml
Line: 22-26
Comment:
**Insufficient permissions for Claude to write back to the PR**
Both this workflow and `claude.yml` set `pull-requests: read` and `issues: read`, but Claude needs write access to post review comments, create branches, or push commits. The `claude_code_oauth_token` authenticates Claude with the AI backend; GitHub API operations (posting comments, creating reviews, pushing code) go through the job's `GITHUB_TOKEN`, which is governed by this `permissions` block. With only `read` on `pull-requests` and `issues`, any attempt by Claude to leave a comment or open a review will fail at runtime. At minimum, `pull-requests: write` and `issues: write` are required; `contents: write` is needed if Claude should be able to commit changes. The same issue applies to the identical permissions block in `claude.yml` (lines 21–26).
How can I resolve this? If you propose a fix, please make it concise.


steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
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.

P2Third-party action pinned to a mutable @v1 tag

anthropics/claude-code-action@v1 resolves to whatever commit the upstream maintainer points that tag at. If the tag is force-pushed with a compromised version, every future run fetches and executes untrusted code with the CLAUDE_CODE_OAUTH_TOKEN secret in scope. GitHub's own hardening guide recommends pinning to a full commit SHA (e.g. anthropics/claude-code-action@<sha>) and verifying it periodically. The same applies to the identical reference in claude.yml (line 35).

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/claude-code-review.yml
Line: 36
Comment:
**Third-party action pinned to a mutable `@v1` tag**`anthropics/claude-code-action@v1` resolves to whatever commit the upstream maintainer points that tag at. If the tag is force-pushed with a compromised version, every future run fetches and executes untrusted code with the `CLAUDE_CODE_OAUTH_TOKEN` secret in scope. GitHub's own hardening guide recommends pinning to a full commit SHA (e.g. `anthropics/claude-code-action@<sha>`) and verifying it periodically. The same applies to the identical reference in `claude.yml` (line 35).
How can I resolve this? If you propose a fix, please make it concise.

with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
plugins: 'code-review@claude-code-plugins'
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options

50 changes: 50 additions & 0 deletions .github/workflows/claude.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

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')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
Comment on lines +15 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2No actor write-permission check — any commenter can trigger Claude

The trigger condition only checks whether the comment body contains @claude; it does not verify that the actor is a repository collaborator or has write access. On any public or organisation repo where outside users can comment on issues, this means an unauthenticated third party can invoke Claude (and consume the team's API quota) simply by posting a comment with @claude. Adding a check such as github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER' would restrict execution to trusted contributors.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/claude.yml
Line: 15-19
Comment:
**No actor write-permission check — any commenter can trigger Claude**
The trigger condition only checks whether the comment body contains `@claude`; it does not verify that the actor is a repository collaborator or has write access. On any public or organisation repo where outside users can comment on issues, this means an unauthenticated third party can invoke Claude (and consume the team's API quota) simply by posting a comment with `@claude`. Adding a check such as `github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER'` would restrict execution to trusted contributors.
How can I resolve this? If you propose a fix, please make it concise.

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
Comment on lines +22 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Grant the interactive Claude job write scopes

For @claude requests that ask Claude to reply, update files, or create PRs, this job only gives the action read access to contents, pull requests, and issues. The upstream interactive example grants contents: write, pull-requests: write, and issues: write for the same triggers (https://github.com/anthropics/claude-code-action/blob/main/examples/claude.yml), so in repositories with read-only defaults the workflow can start but Claude will fail when it tries to push changes or post comments.

Useful? React with 👍 / 👎.

id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read
Comment on lines +39 to +41

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2Duplicate actions: read declaration

actions: read is already declared in the job-level permissions block (line 26) and is redundantly restated under additional_permissions. The additional_permissions input is documented for granting permissions beyond what the workflow's token carries; listing one that is already granted there has no effect and is misleading.

Suggested change
# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read
# This is an optional setting that allows Claude to read CI results on PRs
#additional_permissions is used for permissions beyond what the job token provides;
# 'actions: read' is already granted in the job permissions block above.
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/claude.yml
Line: 39-41
Comment:
**Duplicate `actions: read` declaration**`actions: read` is already declared in the job-level `permissions` block (line 26) and is redundantly restated under `additional_permissions`. The `additional_permissions` input is documented for granting permissions beyond what the workflow's token carries; listing one that is already granted there has no effect and is misleading.
```suggestion # This is an optional setting that allows Claude to read CI results on PRs # additional_permissions is used for permissions beyond what the job token provides; # 'actions: read' is already granted in the job permissions block above.```
How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'

# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr *)'

Loading