Add Claude Code GitHub Workflow#3523
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8479c08679
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (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'))) |
There was a problem hiding this comment.
Restrict Claude invocation to trusted users
In repositories where non-members can open issues or comments, this condition only checks for @claude and does not verify actor trust (author_association/write access), so any external user can trigger paid Claude runs by posting a mention. Add an explicit permission gate (for example OWNER/MEMBER/COLLABORATOR) before calling the action to prevent untrusted triggering.
Useful? React with 👍 / 👎.
| id: claude-review | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
There was a problem hiding this comment.
Guard review workflow when OAuth secret is absent
This job unconditionally uses secrets.CLAUDE_CODE_OAUTH_TOKEN on pull_request events, but fork-origin PR runs do not receive repository secrets, so external-contributor PRs will fail on open/synchronize/reopen due to a missing token. Add a same-repo PR guard (or redesign with a safe pull_request_target flow) so fork PRs don't produce persistent failing checks.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds GitHub Actions workflows to integrate the Anthropic “Claude Code” agent into the repo, enabling automated responses to @claude mentions and an optional automated PR code review run.
Changes:
- Added a
Claude Codeworkflow that triggers on issue/PR comment/review events when@claudeis present. - Added a
Claude Code Reviewworkflow that runs a code-review plugin automatically on PR events.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| .github/workflows/claude.yml | New workflow to run Claude Code based on @claude mentions in issues/comments/reviews. |
| .github/workflows/claude-code-review.yml | New workflow to run Claude Code Review plugin automatically on PR lifecycle events. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write |
There was a problem hiding this comment.
The workflow permissions are read-only for pull-requests and issues. If the intent is for Claude to reply with comments / reviews (as described in the PR), it will likely be blocked by token permissions. Either adjust the workflow permissions to allow the intended write operations (principle of least privilege, e.g. issues/pull-requests write only if needed) or update the PR description to match a read-only integration.
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, ready_for_review, reopened] | ||
| # Optional: Only run on specific file changes |
There was a problem hiding this comment.
This workflow runs on pull_request events. For PRs from forks, secrets.CLAUDE_CODE_OAUTH_TOKEN will not be provided, so the job will still start and then fail inside the action (noisy CI). Add a job-level guard to skip forked PRs (e.g. check github.event.pull_request.head.repo.fork == false) or otherwise short-circuit when the secret is missing.
| pull-requests: read | ||
| issues: read | ||
| id-token: write |
There was a problem hiding this comment.
pull-requests and issues permissions are set to read. If the code-review plugin is expected to leave review comments or PR feedback, it will likely need pull-requests: write (and possibly issues: write for issue comments). Please confirm the required permissions for anthropics/claude-code-action in this mode and tighten to the minimum set that still allows it to post results.
| pull-requests: read | |
| issues: read | |
| id-token: write | |
| pull-requests: write |
| (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'))) |
There was a problem hiding this comment.
The job can be triggered by any issue/PR commenter who types "@claude". Because this workflow uses a repository secret (CLAUDE_CODE_OAUTH_TOKEN) and requests an OIDC token (id-token: write), an untrusted external user could trigger the job and potentially prompt the agent to exfiltrate secrets. Add an explicit trust gate (e.g., allow only OWNER/MEMBER/COLLABORATOR author_association, or restrict to specific usernames/teams) before running the Claude step, and consider removing the issues trigger if you only want comment-driven runs.
| (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'))) | |
| ( | |
| github.event_name == 'issue_comment' && | |
| contains(github.event.comment.body, '@claude') && | |
| contains('OWNER,MEMBER,COLLABORATOR', github.event.comment.author_association) | |
| ) || | |
| ( | |
| github.event_name == 'pull_request_review_comment' && | |
| contains(github.event.comment.body, '@claude') && | |
| contains('OWNER,MEMBER,COLLABORATOR', github.event.comment.author_association) | |
| ) || | |
| ( | |
| github.event_name == 'pull_request_review' && | |
| contains(github.event.review.body, '@claude') && | |
| contains('OWNER,MEMBER,COLLABORATOR', github.event.review.author_association) | |
| ) || | |
| ( | |
| github.event_name == 'issues' && | |
| ( | |
| contains(github.event.issue.body, '@claude') || | |
| contains(github.event.issue.title, '@claude') | |
| ) && | |
| contains('OWNER,MEMBER,COLLABORATOR', github.event.issue.author_association) | |
| ) |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Installing Claude Code GitHub App
This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.
What is Claude Code?
Claude Code is an AI coding agent that can help with:
How it works
Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.
Important Notes
Security
There's more information in the Claude Code action repo.
After merging this PR, let's try mentioning @claude in a comment on any PR to get started!