Add Claude Code GitHub Workflow - #2
Conversation
There was a problem hiding this comment.
Pull request overview
Adds GitHub Actions workflows to integrate Anthropic’s Claude Code into the repo, enabling automated Claude runs either when mentioned in issues/PRs or as an automatic PR code-review workflow.
Changes:
- Add a comment/issue-triggered workflow to run Claude Code when
@claudeis detected. - Add a PR-triggered workflow to run a Claude Code “code review” plugin on PR events.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
.github/workflows/claude.yml |
Introduces an @claude-triggered workflow for issues/PR comments/reviews. |
.github/workflows/claude-code-review.yml |
Introduces an automatic Claude-driven PR review workflow on PR lifecycle events. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] |
There was a problem hiding this comment.
The workflow listens to issues events (opened/assigned), which means an issue containing @claude in the title/body can trigger runs without any comment mention, and can be retriggered by re-assigning. If the intent is “run only when @claude is mentioned in a comment” (per the PR description), consider removing the issues trigger and relying on issue_comment only (or tightening the issues types/condition).
| 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 job uses secrets.CLAUDE_CODE_OAUTH_TOKEN but is triggered by the pull_request event. For PRs coming from forks, GitHub Actions does not provide repository secrets, so this will reliably fail (and can create noisy red checks). Add an if: guard to skip forked PRs (or otherwise handle missing secrets), or switch to a safer alternative that meets your security requirements.
| pull-requests: read | ||
| issues: read |
There was a problem hiding this comment.
Both workflows set pull-requests, issues, and contents permissions to read. If the Claude action is expected to leave results as PR/issue comments or open PRs/commits (as described in the PR text), these permissions will prevent using GITHUB_TOKEN to write back. Consider granting the minimal required write permissions (e.g., pull-requests: write, issues: write, and contents: write only if you want it to push commits).
| pull-requests: read | |
| issues: read | |
| pull-requests: write | |
| issues: write |
| pull-requests: read | ||
| issues: read |
There was a problem hiding this comment.
permissions are read-only for contents, pull-requests, and issues. If the Claude action needs to post comments back to PRs/issues or push commits/branches, it won’t be able to do so via GITHUB_TOKEN with these settings. Consider granting only the specific write permissions you need (e.g., issues: write / pull-requests: write, and contents: write only if allowing commits).
| pull-requests: read | |
| issues: read | |
| pull-requests: write | |
| issues: 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 is triggered by issue/PR comments and has access to repository secrets, but there’s no restriction on who can trigger it. This makes it possible for non-collaborators (depending on repo settings) to invoke the workflow just by mentioning @claude. Add an author trust check (e.g., require author_association in OWNER/MEMBER/COLLABORATOR or check team/org membership) to the job if: so only trusted users can trigger 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(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) | |
| ) |
| (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 mention detection is case-sensitive (contains(..., '@claude')), so valid GitHub mentions like @Claude won’t trigger the workflow even though GitHub treats usernames case-insensitively. Consider normalizing the body/title with toLower(...) (or equivalent) before calling contains.
| (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(toLower(github.event.comment.body), '@claude')) || | |
| (github.event_name == 'pull_request_review_comment' && contains(toLower(github.event.comment.body), '@claude')) || | |
| (github.event_name == 'pull_request_review' && contains(toLower(github.event.review.body), '@claude')) || | |
| (github.event_name == 'issues' && (contains(toLower(github.event.issue.body), '@claude') || contains(toLower(github.event.issue.title), '@claude'))) |
🤖 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!