Skip to content

Add Claude Code GitHub Workflow#82

Open
humancto wants to merge 2 commits into
mainfrom
add-claude-github-actions-1777943892381
Open

Add Claude Code GitHub Workflow#82
humancto wants to merge 2 commits into
mainfrom
add-claude-github-actions-1777943892381

Conversation

@humancto
Copy link
Copy Markdown
Owner

@humancto humancto commented May 5, 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!

Summary by CodeRabbit

  • Chores
    • Added GitHub Actions workflows to automate code review processes and enable Claude integration for pull request and issue interactions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

Two new GitHub Actions workflows are added: one automatically triggers Claude code review on pull request lifecycle events, and another enables on-demand Claude invocation via @claude mentions in issues and pull request reviews.

Changes

Automated Code Review on Pull Requests

Layer / File(s) Summary
Workflow Configuration
.github/workflows/claude-code-review.yml
New workflow triggers on PR events (opened, synchronize, ready_for_review, reopened) and runs a single claude-review job on ubuntu-latest with repository/PR read permissions and id-token: write.
Action Integration
.github/workflows/claude-code-review.yml
Job invokes anthropics/claude-code-action@v1 with code-review@claude-code-plugins plugin and a prompt targeting the specific PR URL using the CLAUDE_CODE_OAUTH_TOKEN secret.

On-Demand Claude via Mentions

Layer / File(s) Summary
Event Triggers & Conditional Gate
.github/workflows/claude.yml
New workflow listens to issue comments, PR review comments, issue open/assign, and PR review submission events. Job only executes when the triggering text contains @claude.
Permissions & Checkout
.github/workflows/claude.yml
Job grants read permissions for repository contents, PRs, and issues; id-token: write; and actions: read to allow Claude to inspect CI results. Checks out code with actions/checkout@v4.
Action Integration
.github/workflows/claude.yml
Invokes anthropics/claude-code-action@v1 using secrets.CLAUDE_CODE_OAUTH_TOKEN and configures additional_permissions to enable reading GitHub Actions results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit hops through GitHub's gate,
With Claude workflows, reviews are great!
Two paths of code, both fast and free,
Automated checks and mentions—how lovely! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides excellent context about Claude Code integration, how it works, security considerations, and usage instructions, but does not follow the repository's required template structure. Reformat the description to follow the repository's template with sections for Summary, Classification, Test plan, Rollback, and Refs, rather than custom sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding Claude Code GitHub workflows to enable AI code review and assistance integration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-claude-github-actions-1777943892381

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/claude-code-review.yml:
- Around line 30-36: The workflow uses tag refs for actions (actions/checkout@v4
and anthropics/claude-code-action@v1); replace each `uses:` entry with the
corresponding immutable 40-hex commit SHA for that repo (e.g.,
actions/checkout@<40-hex-sha> and anthropics/claude-code-action@<40-hex-sha>),
optionally appending a trailing comment with the human-readable tag (e.g., "#
v4" or "# v1") to satisfy the SHA-pin policy and unblock the dependabot-selftest
check.

In @.github/workflows/claude.yml:
- Around line 15-20: The trigger condition must be gated by a trusted-actor
check so only users with write access can invoke `@claude`; update the existing if
expression to require both the `@claude` mention and that the event actor’s
author_association is one of OWNER, MEMBER or COLLABORATOR. Concretely, for
comment/review/review_comment/issue branches add an extra clause using the
appropriate payload field (github.event.comment.author_association,
github.event.review.author_association, github.event.issue.author_association)
and require it equals 'OWNER' or 'MEMBER' or 'COLLABORATOR' (combine with ||),
so the final if only passes when a mention exists AND the actor has write-level
association.
- Around line 29-35: Replace the tag refs with pinned commit SHAs for the GitHub
Actions usages: change actions/checkout@v4 to the full 40-character commit SHA
for the actions/checkout repo and change anthropics/claude-code-action@v1 to the
full 40-character commit SHA for anthropics/claude-code-action; apply the same
replacements in both `.github/workflows/claude.yml` (the lines that reference
actions/checkout@v4 and anthropics/claude-code-action@v1) and
`.github/workflows/claude-code-review.yml` so both workflows use exact commit
SHAs instead of tag refs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dbea0861-73e5-4d57-8615-06bd47a3a5a6

📥 Commits

Reviewing files that changed from the base of the PR and between bc5fd67 and 1a0443e.

📒 Files selected for processing (2)
  • .github/workflows/claude-code-review.yml
  • .github/workflows/claude.yml

Comment on lines +30 to +36
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all workflow `uses:` entries are SHA-pinned
rg -nP '^\s*uses:\s*[^@\s]+@(?!(?:[0-9a-f]{40})\b).+' .github/workflows/*.yml
# Expected: no output

Repository: humancto/mango

Length of output: 372


🏁 Script executed:

# Check for dependabot or policy configuration files
find .github -type f -name "*.yml" -o -name "*.yaml" -o -name "*.json" | head -20

Repository: humancto/mango

Length of output: 677


🏁 Script executed:

# Search for any references to "dependabot-selftest" or SHA pinning policies
rg -i "dependabot-selftest|sha.?pin|immutable" .github/ || echo "No references found"

Repository: humancto/mango

Length of output: 1135


🏁 Script executed:

# Check all other workflows to see if SHA pinning is consistently applied
cat .github/workflows/claude.yml | head -40

Repository: humancto/mango

Length of output: 1359


🏁 Script executed:

# Read the dependabot-selftest.yml to understand the enforcement
cat .github/workflows/dependabot-selftest.yml

Repository: humancto/mango

Length of output: 2585


🏁 Script executed:

# Also check the dependabot.yml configuration
cat .github/dependabot.yml

Repository: humancto/mango

Length of output: 3808


🏁 Script executed:

# Verify the test script existence and understand assertion `#15`
head -60 scripts/dependabot-scripts-test.sh | grep -A 5 -B 5 "assertion"

Repository: humancto/mango

Length of output: 532


🏁 Script executed:

# Find assertion `#15` in the test script
rg -n "assertion.?15|uses:" scripts/dependabot-scripts-test.sh | head -30

Repository: humancto/mango

Length of output: 775


Pin action refs to immutable SHAs to unblock CI and harden supply chain.

Lines 30 and 36 use tag-pinned refs (@v4, @v1) and violate the enforced SHA-pin policy. This directly triggers the dependabot-selftest workflow failure (assertion #15 validates all uses: lines must be 40-hex SHAs with optional trailing # <ref> comments).

Suggested fix pattern
-        uses: actions/checkout@v4
+        uses: actions/checkout@<40-hex-commit-sha> # v4

-        uses: anthropics/claude-code-action@v1
+        uses: anthropics/claude-code-action@<40-hex-commit-sha> # v1
🧰 Tools
🪛 GitHub Actions: dependabot-selftest

[error] 30-30: Dependabot scripts check failed: workflow uses are not SHA-pinned with 40-hex. Found 'uses: actions/checkout@v4'.


[error] 36-36: Dependabot scripts check failed: workflow uses are not SHA-pinned with 40-hex. Found 'uses: anthropics/claude-code-action@v1'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude-code-review.yml around lines 30 - 36, The workflow
uses tag refs for actions (actions/checkout@v4 and
anthropics/claude-code-action@v1); replace each `uses:` entry with the
corresponding immutable 40-hex commit SHA for that repo (e.g.,
actions/checkout@<40-hex-sha> and anthropics/claude-code-action@<40-hex-sha>),
optionally appending a trailing comment with the human-readable tag (e.g., "#
v4" or "# v1") to satisfy the SHA-pin policy and unblock the dependabot-selftest
check.

Comment on lines +15 to +20
if: |
(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')))
runs-on: ubuntu-latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a trusted-actor gate to the @claude trigger condition.

Line 15–20 currently allows any user who can comment to invoke the workflow if they mention @claude. That does not enforce the stated “write-access only” behavior and can be abused for cost/noise.

Suggested fix
   claude:
     if: |
-      (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))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: |
(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')))
runs-on: ubuntu-latest
if: |
(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))
runs-on: ubuntu-latest
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude.yml around lines 15 - 20, The trigger condition
must be gated by a trusted-actor check so only users with write access can
invoke `@claude`; update the existing if expression to require both the `@claude`
mention and that the event actor’s author_association is one of OWNER, MEMBER or
COLLABORATOR. Concretely, for comment/review/review_comment/issue branches add
an extra clause using the appropriate payload field
(github.event.comment.author_association,
github.event.review.author_association, github.event.issue.author_association)
and require it equals 'OWNER' or 'MEMBER' or 'COLLABORATOR' (combine with ||),
so the final if only passes when a mention exists AND the actor has write-level
association.

Comment on lines +29 to +35
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all workflow `uses:` entries are SHA-pinned
rg -nP '^\s*uses:\s*[^@\s]+@(?!(?:[0-9a-f]{40})\b).+' .github/workflows/*.yml
# Expected: no output

Repository: humancto/mango

Length of output: 372


Pin GitHub Actions by full commit SHA (required by current CI policy).

Lines 29 and 35 in .github/workflows/claude.yml use tag refs (@v4, @v1) instead of 40-hex SHAs. The same issue exists in .github/workflows/claude-code-review.yml at lines 30 and 36. This is failing dependabot-selftest and should be treated as a merge blocker.

Suggested fix pattern
-      - name: Checkout repository
-        uses: actions/checkout@v4
+      - name: Checkout repository
+        uses: actions/checkout@<40-hex-commit-sha> # v4

...
-      - name: Run Claude Code
-        id: claude
-        uses: anthropics/claude-code-action@v1
+      - name: Run Claude Code
+        id: claude
+        uses: anthropics/claude-code-action@<40-hex-commit-sha> # v1
🧰 Tools
🪛 GitHub Actions: dependabot-selftest

[error] 29-29: Dependabot scripts check failed: workflow uses are not SHA-pinned with 40-hex. Found 'uses: actions/checkout@v4'.


[error] 35-35: Dependabot scripts check failed: workflow uses are not SHA-pinned with 40-hex. Found 'uses: anthropics/claude-code-action@v1'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude.yml around lines 29 - 35, Replace the tag refs with
pinned commit SHAs for the GitHub Actions usages: change actions/checkout@v4 to
the full 40-character commit SHA for the actions/checkout repo and change
anthropics/claude-code-action@v1 to the full 40-character commit SHA for
anthropics/claude-code-action; apply the same replacements in both
`.github/workflows/claude.yml` (the lines that reference actions/checkout@v4 and
anthropics/claude-code-action@v1) and `.github/workflows/claude-code-review.yml`
so both workflows use exact commit SHAs instead of tag refs.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a0443e2cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Grant pull-request write scope for code-review job

This workflow configures pull-requests: read, but the Claude Code review flow is expected to publish PR feedback; with a read-only token, review comments cannot be created, so the automated review run can complete without delivering actionable output. Anthropic’s own automated review examples for anthropics/claude-code-action use pull-requests: write for this reason, so this permission setting makes the new review workflow effectively non-functional on real PRs.

Useful? React with 👍 / 👎.

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

Choose a reason for hiding this comment

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

P1 Badge Enable write scopes for interactive Claude workflow

The @claude workflow is wired to respond to issue/PR mentions, but contents, pull-requests, and issues are all set to read-only, which prevents Claude from posting responses/comments or making repo updates requested via mentions. In practice this causes triggered runs to be unable to perform the core actions users expect from this workflow; the action’s documented baseline permissions are write-level for these scopes.

Useful? React with 👍 / 👎.

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.

1 participant