Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
Add Claude Code GitHub Workflow#229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff 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 | ||
| issues: read | ||
| id-token: write | ||
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Both this workflow and Prompt To Fix With AIThis 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis 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 | ||
| Original file line number | Diff line number | Diff 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The trigger condition only checks whether the comment body contains Prompt To Fix With AIThis 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Prompt To Fix With AIThis 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 *)' | ||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 grantpull-requests: writeand 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 👍 / 👎.