Skip to content

Add Claude Code GitHub Workflow#2384

Merged
rjpower merged 6 commits intomainfrom
add-claude-github-actions-1768845234712
Jan 20, 2026
Merged

Add Claude Code GitHub Workflow#2384
rjpower merged 6 commits intomainfrom
add-claude-github-actions-1768845234712

Conversation

@rjpower
Copy link
Collaborator

@rjpower rjpower commented Jan 19, 2026

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

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

Copilot AI review requested due to automatic review settings January 19, 2026 17:54
Copy link
Contributor

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

This PR adds GitHub Actions workflows to integrate Claude Code, an AI coding assistant, into the repository. The integration allows users to interact with Claude by mentioning @claude in comments, and also provides automated code review capabilities on pull requests.

Changes:

  • Added .github/workflows/claude.yml for on-demand Claude interactions via @claude mentions in issues and PR comments
  • Added .github/workflows/claude-code-review.yml for automatic Claude code reviews on all pull requests

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/claude.yml Workflow that triggers Claude when @claude is mentioned in PR comments, issue comments, reviews, or new issues
.github/workflows/claude-code-review.yml Workflow that automatically runs Claude code reviews on all pull requests when opened, synchronized, or reopened

Comment on lines 22 to 24
contents: read
pull-requests: read
issues: read
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The permissions for this workflow are insufficient for Claude to perform its intended functions. According to the PR description, Claude should be able to "create comments, branches, and commits", but the current permissions only allow read access.

The workflow needs write permissions added:

  • contents: write - to create branches and commits
  • pull-requests: write - to create/update PR comments
  • issues: write - to create/update issue comments

Without these permissions, Claude will fail when attempting to write any changes or responses back to the repository.

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

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

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The permissions for this automated code review workflow are insufficient. The workflow only has read permissions, but needs write permissions to post review comments and feedback.

Add write permissions:

  • pull-requests: write - to post review comments
  • issues: write - to create comments on the PR

Without these permissions, Claude will be unable to post its code review feedback.

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

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with co pilot here, seems like these permissions are too strict?

Comment on lines 14 to 19
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

This workflow will run automatically on every pull request (opened, synchronize, ready_for_review, reopened) without any filtering. This could result in:

  1. Unnecessary Claude API costs for every PR
  2. Potential noise from automated reviews on all PRs, including trivial ones
  3. Slower PR workflows due to waiting for automated reviews

Consider uncommenting and configuring the author filter (lines 15-19) to limit automatic reviews to specific users or first-time contributors, or add path filtering (lines 6-11) to only review relevant code changes. Alternatively, you could remove this workflow entirely and only use the @claude mention workflow for on-demand reviews.

Copilot uses AI. Check for mistakes.
Changes:
- claude-code-review.yml: Auto-trigger only for PRs from repo writers, manual trigger via @claude-review
- claude.yml: Restrict @claude mentions to repo writers only
- Both workflows now check author_association (OWNER, MEMBER, COLLABORATOR)
Copy link
Contributor

@yonromai yonromai left a comment

Choose a reason for hiding this comment

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

Awesome! I actually started hacking on this this weekend, you beat me to it! :shipit: :shipit:

Comment on lines 24 to 25
pull-requests: read
issues: read
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with co pilot here, seems like these permissions are too strict?

claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
plugins: 'code-review@claude-code-plugins'
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ steps.pr-number.outputs.number }}'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Why not follow the /review convention in the CLI and the GH action doc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good to me, we can change it.

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I wonder if we should > 100 (or 0 + potentially a file filter). I end up using claude to look into the git history a bunch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These were the defaults from Claude. I'm not against tweaking it, but I don't know if it has consequences for the actions? Maybe let's start with this and see if we run into issues?

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ditto ^

- Change permissions from read to write for contents, pull-requests, issues
  (required for Claude to comment and push changes to PR branches)
- Change review trigger from @claude-review to /review
- Increase fetch-depth from 1 to 10 for recent git history access
@rjpower
Copy link
Collaborator Author

rjpower commented Jan 20, 2026

Adjusted permissions and set the fetch limit to 10 to see how that goes..

Users can trigger code reviews via @claude in the main workflow
(e.g., "@claude review this PR" or "@claude /review").
@rjpower rjpower enabled auto-merge (squash) January 20, 2026 17:29
@rjpower rjpower merged commit 4ecb27d into main Jan 20, 2026
7 of 8 checks passed
@rjpower rjpower deleted the add-claude-github-actions-1768845234712 branch January 20, 2026 17:31
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.

4 participants