Skip to content

Add Claude Code GitHub Workflow - #2

Merged
JoeMatt merged 2 commits into
masterfrom
add-claude-github-actions-1774473633714
Mar 25, 2026
Merged

Add Claude Code GitHub Workflow#2
JoeMatt merged 2 commits into
masterfrom
add-claude-github-actions-1774473633714

Conversation

@JoeMatt

@JoeMatt JoeMatt commented Mar 25, 2026

Copy link
Copy Markdown
Member

🤖 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:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

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

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

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!

Copilot AI review requested due to automatic review settings March 25, 2026 21:20
@JoeMatt
JoeMatt merged commit 8d9c6a9 into master Mar 25, 2026
3 of 4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 @claude is 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.

Comment on lines +3 to +11
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +6
on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
# Optional: Only run on specific file changes

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +25
pull-requests: read
issues: read

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Suggested change
pull-requests: read
issues: read
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +24
pull-requests: read
issues: read

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Suggested change
pull-requests: read
issues: read
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +19
(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')))

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
(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)
)

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +19
(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')))

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
(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')))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants