Add Claude Code GitHub Workflow#1
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces GitHub Actions workflows to integrate the Anthropic Claude Code agent into the repository, enabling AI-assisted actions via mentions and (optionally) automated PR review.
Changes:
- Adds a mention-triggered Claude Code workflow for issues, PR review comments, and PR reviews.
- Adds an automated Claude-based code review workflow that runs on pull request lifecycle events.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
.github/workflows/claude.yml |
New workflow to run Claude Code when @claude is detected in supported event payloads. |
.github/workflows/claude-code-review.yml |
New workflow to run an automatic Claude code review plugin on PR events. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (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 workflow can be triggered by any commenter who mentions @claude (including on PRs from forks). This contradicts the PR description’s claim that only users with write access can trigger it, and it risks untrusted users consuming API quota or attempting prompt-injection. Add an explicit gate in the job if: (e.g., require author_association to be OWNER/MEMBER/COLLABORATOR, or check repository permissions) before running the action.
| (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(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || | |
| (github.event_name == 'pull_request_review_comment' && | |
| contains(github.event.comment.body, '@claude') && | |
| contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || | |
| (github.event_name == 'pull_request_review' && | |
| contains(github.event.review.body, '@claude') && | |
| contains(fromJSON('["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(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)) |
| pull-requests: read | ||
| issues: read |
There was a problem hiding this comment.
Job-level permissions are read-only (contents, pull-requests, issues). If you expect Claude to post PR/issue comments, create branches, or push commits as described in the PR body, this will prevent using the workflow GITHUB_TOKEN for those operations. Either grant the minimal required write permissions (e.g., issues: write, pull-requests: write, and/or contents: write) or adjust the PR description/expected capabilities accordingly.
| pull-requests: read | |
| issues: read | |
| pull-requests: write | |
| issues: write |
|
|
||
| - name: Run Claude Code | ||
| id: claude | ||
| uses: anthropics/claude-code-action@v1 |
There was a problem hiding this comment.
The workflow uses a third-party action (anthropics/claude-code-action@v1) pinned to a moving tag. To reduce supply-chain risk, pin to a specific commit SHA (optionally keeping the tag in a comment for readability).
| uses: anthropics/claude-code-action@v1 | |
| uses: anthropics/claude-code-action@<FULL_40_CHAR_COMMIT_SHA> # v1 |
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, ready_for_review, reopened] | ||
| # Optional: Only run on specific file changes |
There was a problem hiding this comment.
PR description states the integration is triggered by mentioning @claude in an issue/PR comment, but this workflow runs automatically on every PR open/synchronize/ready_for_review/reopen. Either update the PR description to reflect the always-on automatic review behavior, or add an if: condition (or adjust triggers) so it only runs when intended.
| 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 relies on secrets.CLAUDE_CODE_OAUTH_TOKEN but is triggered via the pull_request event. For PRs from forks, repository secrets are not provided, which will cause the job to fail/no-op and add noise to CI. Consider gating to same-repo PRs (e.g., head.repo.full_name == github.repository) or switching to a safe alternative pattern if you need to support forked PRs.
|
|
||
| - name: Run Claude Code Review | ||
| id: claude-review | ||
| uses: anthropics/claude-code-action@v1 |
There was a problem hiding this comment.
The workflow uses a third-party action (anthropics/claude-code-action@v1) pinned to a moving tag. To reduce supply-chain risk, pin to a specific commit SHA (optionally keeping the tag in a comment for readability).
| uses: anthropics/claude-code-action@v1 | |
| uses: anthropics/claude-code-action@<FULL_LENGTH_COMMIT_SHA> # pin reviewed v1 release commit |
| pull-requests: read | ||
| issues: read |
There was a problem hiding this comment.
Job permissions are read-only (pull-requests: read, issues: read). If the code-review plugin is expected to post review comments or PR comments back to GitHub, it will likely require pull-requests: write (and possibly issues: write). Confirm the action’s requirements and grant the minimal necessary permissions so the workflow can publish results.
| pull-requests: read | |
| issues: read | |
| pull-requests: write | |
| issues: write |
🤖 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 (@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 (@claude) in a comment on any PR to get started!