Skip to content

Add Claude Code GitHub Workflow#11

Merged
JoeMatt merged 2 commits into
mainfrom
add-claude-github-actions-1774059247267
Mar 21, 2026
Merged

Add Claude Code GitHub Workflow#11
JoeMatt merged 2 commits into
mainfrom
add-claude-github-actions-1774059247267

Conversation

@JoeMatt
Copy link
Copy Markdown
Member

@JoeMatt JoeMatt commented Mar 21, 2026

🤖 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 21, 2026 02:14
@JoeMatt JoeMatt merged commit e505efd into main Mar 21, 2026
2 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

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 the Anthropic “Claude Code” GitHub Action into this repository, enabling automated agent runs (comment-driven and PR-driven) using a repository secret.

Changes:

  • Introduces an on-demand workflow (claude.yml) that triggers when “@claude” is detected in several event payloads.
  • Adds an automatic PR workflow (claude-code-review.yml) intended to run a code-review plugin on PR 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 that runs Claude Code based on @claude detection across issue/comment/review events.
.github/workflows/claude-code-review.yml New workflow that runs an automated Claude-based code review on PR open/sync/reopen events.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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')))
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The job can be triggered by anyone who can create an issue or comment containing “@claude”. Since this workflow uses a repository secret (CLAUDE_CODE_OAUTH_TOKEN), it should explicitly restrict execution to trusted actors (e.g., OWNER/MEMBER/COLLABORATOR) or otherwise verify the commenter has write permission before running.

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') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')) ||
(github.event_name == 'pull_request_review_comment' &&
contains(github.event.comment.body, '@claude') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')) ||
(github.event_name == 'pull_request_review' &&
contains(github.event.review.body, '@claude') &&
(github.event.review.author_association == 'OWNER' ||
github.event.review.author_association == 'MEMBER' ||
github.event.review.author_association == 'COLLABORATOR')) ||
(github.event_name == 'issues' &&
(contains(github.event.issue.body, '@claude') ||
contains(github.event.issue.title, '@claude')) &&
(github.event.issue.author_association == 'OWNER' ||
github.event.issue.author_association == 'MEMBER' ||
github.event.issue.author_association == 'COLLABORATOR'))

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

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

contains(github.event.review.body, '@claude') and contains(github.event.issue.body, '@claude') can fail when the body is null/empty (e.g., an approval-only review, or an issue without a description). Consider coercing to an empty string (e.g., ...body || '') before calling contains.

Suggested change
(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 == '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 uses AI. Check for mistakes.
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]
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The PR description says the workflow runs when Claude is mentioned in PR/issue comments, but this workflow also triggers on issues (opened/assigned) and pull_request_review (submitted). If the intent is “mention in a comment only”, consider removing those triggers or updating the description to match the actual behavior.

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
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

This workflow runs on every PR open/sync/reopen, which doesn’t match the PR description’s “run when @claude is mentioned” behavior and could create significant usage/cost. Consider gating execution (label, opt-in comment trigger, or author filter) if you want this to be on-demand.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +38
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

On pull_request events from forks, repository secrets (including CLAUDE_CODE_OAUTH_TOKEN) aren’t provided, so this job will fail noisily for external contributions. Consider adding an if: guard to only run when github.event.pull_request.head.repo.full_name == github.repository (and optionally when the PR is not a draft).

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +26
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The PR description states Claude can create comments/branches/commits, but the workflow permissions grant only read access (contents, pull-requests, issues). If the action relies on the job’s GITHUB_TOKEN for repo interactions, it won’t be able to write back results. Consider granting the minimal required write permissions (or documenting that a separate GitHub token/app is used instead).

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +26
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The PR description states Claude can create comments/branches/commits, but this job’s permissions are read-only (contents, pull-requests, issues). If the action uses the job token for posting results or creating commits, it won’t be able to do so with the current permissions. Consider granting only the specific write scopes needed (or documenting alternative auth).

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