Skip to content

Add Claude Code GitHub Workflow - #16

Merged
rosh2004 merged 3 commits into
mainfrom
add-claude-github-actions-1774147844132
Mar 22, 2026
Merged

Add Claude Code GitHub Workflow#16
rosh2004 merged 3 commits into
mainfrom
add-claude-github-actions-1774147844132

Conversation

@rosh2004

@rosh2004 rosh2004 commented Mar 22, 2026

Copy link
Copy Markdown
Owner

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


Note

Medium Risk
Adds new GitHub Actions that run third-party automation with id-token: write and a repository secret, so misconfiguration could impact repo security or leak credentials despite the actor/author gating.

Overview
Adds two new GitHub Actions workflows to integrate anthropics/claude-code-action@v1.

claude.yml runs Claude on-demand when comments/reviews/issues contain @claude (gated to github.actor == 'rosh2004') and grants read access plus actions: read and id-token: write.

claude-code-review.yml triggers automated PR reviews on PR events (also gated to PRs opened by rosh2004) using the code-review plugin and a fixed review prompt, authenticated via CLAUDE_CODE_OAUTH_TOKEN.

Written by Cursor Bugbot for commit b8599c2. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • New Features
    • Automated AI code review: Pull requests now receive AI-powered reviews automatically when created or updated.
    • On-demand AI assistance: Mention the AI in comments, issues, or pull request review threads to request analysis and suggestions.

@vercel

vercel Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
portfolio Ready Ready Preview, Comment Mar 22, 2026 3:12am

@coderabbitai

coderabbitai Bot commented Mar 22, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b741db7f-4a5b-46d6-b45e-d20bab44e49e

📥 Commits

Reviewing files that changed from the base of the PR and between ee0c33f and b8599c2.

📒 Files selected for processing (2)
  • .github/workflows/claude-code-review.yml
  • .github/workflows/claude.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/claude.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/claude-code-review.yml

📝 Walkthrough

Walkthrough

Two GitHub Actions workflows were added to invoke the Claude Code Action: one runs automated code reviews on PR lifecycle events, the other runs Claude in response to @claude mentions in issues/comments/reviews.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.​github/workflows/claude-code-review.yml, .​github/workflows/claude.yml
Added two workflows. claude-code-review.yml triggers on PR events (opened, synchronize, ready_for_review, reopened) and runs anthropics/claude-code-action@v1 for code reviews (conditioned on the PR author). claude.yml triggers on issue/comment/review events when @claude appears and runs the Claude action; both workflows use actions/checkout@v4/@vX with shallow fetch, set limited permissions, and consume secrets.CLAUDE_CODE_OAUTH_TOKEN.

Sequence Diagram(s)

sequenceDiagram
  participant User as User (author/commenter)
  participant GitHub as GitHub Events
  participant Runner as Actions Runner
  participant Repo as Repository (checkout)
  participant Claude as Claude Service

  User->>GitHub: open PR / add comment with `@claude`
  GitHub->>Runner: trigger workflow (claude-code-review / claude)
  Runner->>Repo: actions/checkout (fetch-depth:1)
  Runner->>Claude: anthropics/claude-code-action@v1 (with token & plugins)
  Claude-->>Runner: review result / response
  Runner->>GitHub: post comment or PR review with Claude output
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through commits with ears aflutter,

Claudes on the watch, catching each mutter.
PRs sing soft, comments gleam like dew,
Automation carrots, a review rendezvous. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Claude Code GitHub Workflow' directly and clearly summarizes the main change: adding new GitHub Actions workflows to integrate Claude Code.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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-1774147844132

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/claude-code-review.yml:
- Line 26: Remove the unnecessary OIDC permission by deleting the "id-token:
write" entry when using the claude_code_oauth_token OAuth flow; update the
workflow permissions block so it does not request id-token and instead only
declares the specific repository permissions required (e.g., contents, issues,
pull-requests) to follow least-privilege—ensure references to "id-token: write"
are removed and that the workflow still authenticates via
"claude_code_oauth_token".
- Line 30: Replace the mutable action tags with immutable SHAs: locate the
workflow step that references actions/checkout@v4 and change it to the full
commit SHA for that actions/checkout release, and similarly locate the step
using anthropics/claude-code-action@v1 and replace it with that action's full
commit SHA; ensure you pin both uses to their respective full commit SHAs (not
tags) in the .github/workflows/claude-code-review.yml file so the workflow
references an immutable commit.

In @.github/workflows/claude.yml:
- Line 29: Replace mutable GitHub Action tags with immutable commit SHAs: change
the uses entry that currently has "actions/checkout@v4" to
"actions/checkout@<commit-sha>" and similarly replace
"anthropics/claude-code-action@v1" with
"anthropics/claude-code-action@<commit-sha>" (use the specific commit SHAs from
each repository's release/commit you want to pin), updating the two uses lines
in the workflow so they reference the exact commit SHAs instead of version tags.
- Around line 15-20: Current trigger condition only checks for the '@claude'
token and allows any commenter to run the workflow; add an authorization gate by
requiring a trusted actor association or explicit allowlist. Update the if
expression to also check github.event.comment.author_association (and
github.event.review.author_association / github.event.issue.author_association
as applicable) is in a set like ['OWNER','MEMBER','COLLABORATOR'] or that
github.actor is in an explicit allowlist variable, so only trusted actors can
trigger the workflow when '@claude' is present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c4538f2-6236-478f-a5f3-f89947216abf

📥 Commits

Reviewing files that changed from the base of the PR and between cc104fa and ee0c33f.

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

contents: read
pull-requests: read
issues: read
id-token: write

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 | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

For anthropics/claude-code-action, when using claude_code_oauth_token, is permissions: id-token: write required? Please cite the official docs and minimum recommended permissions.

💡 Result:

No, permissions: id-token: write is not required when using claude_code_oauth_token in anthropics/claude-code-action. This permission is specifically needed for OIDC authentication with the default GitHub App (Claude app) or cloud providers like Bedrock/Vertex, where the action requests an OIDC token to exchange for a GitHub app token. The claude_code_oauth_token is an alternative authentication method for Anthropic/Claude (for Pro/Max users, generated via claude setup-token), which bypasses the need for API keys and OIDC flows entirely. It passes the OAuth token directly to Claude Code execution via environment variable CLAUDE_CODE_OAUTH_TOKEN, handling only Claude API auth, not GitHub token generation. Minimum recommended permissions (from official docs/setup.md and examples): For repository access (contents, issues, PRs), use: permissions: contents: write issues: write pull-requests: write actions: read # Optional, for viewing workflow results via additional_permissions input No id-token: write needed. If using a custom GitHub App token via github_token input, generate it separately with actions/create-github-app-token and omit OIDC perms. Official sources confirming: - action.yml lists claude_code_oauth_token separately from OIDC flags (use_bedrock, use_vertex). - FAQ explicitly ties id-token: write to "default GitHub App authentication" (OIDC), with workaround to provide github_token instead. - Setup docs recommend repo perms for Contents/Issues/PRs when using custom apps, no OIDC mention for direct auth. - OAuth added via PR #236 as API key alternative, no GitHub auth changes.

Citations:


Remove id-token: write permission when using claude_code_oauth_token.

The id-token: write permission is only required for OIDC authentication with the default GitHub App. When using claude_code_oauth_token (OAuth alternative), the OIDC flow is bypassed entirely. According to the official documentation and action configuration, this permission should be removed to follow the principle of least privilege. If repository access (contents, issues, PRs) is needed, include only those permissions instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/claude-code-review.yml at line 26, Remove the unnecessary
OIDC permission by deleting the "id-token: write" entry when using the
claude_code_oauth_token OAuth flow; update the workflow permissions block so it
does not request id-token and instead only declares the specific repository
permissions required (e.g., contents, issues, pull-requests) to follow
least-privilege—ensure references to "id-token: write" are removed and that the
workflow still authenticates via "claude_code_oauth_token".


steps:
- name: Checkout repository
uses: actions/checkout@v4

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all workflows use immutable SHAs instead of tags.
rg -n --type=yaml 'uses:\s*[^@]+@v?[0-9]+(\.[0-9]+)?$' .github/workflows

Repository: rosh2004/portfolio

Length of output: 375


Pin third-party actions to immutable SHAs to reduce supply-chain risk.

Lines 30 and 36 use mutable version tags (@v4 and @v1 respectively). Replace these with full commit SHAs:

  • Line 30: actions/checkout@v4actions/checkout@<full-commit-sha>
  • Line 36: anthropics/claude-code-action@v1anthropics/claude-code-action@<full-commit-sha>

Mutable tags can be changed without notice, allowing attackers to inject malicious code through action updates.

Suggested fix
-      - name: Checkout repository
-        uses: actions/checkout@v4
+      - name: Checkout repository
+        uses: actions/checkout@<full-commit-sha>
@@
-      - name: Run Claude Code Review
-        id: claude-review
-        uses: anthropics/claude-code-action@v1
+      - name: Run Claude Code Review
+        id: claude-review
+        uses: anthropics/claude-code-action@<full-commit-sha>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/claude-code-review.yml at line 30, Replace the mutable
action tags with immutable SHAs: locate the workflow step that references
actions/checkout@v4 and change it to the full commit SHA for that
actions/checkout release, and similarly locate the step using
anthropics/claude-code-action@v1 and replace it with that action's full commit
SHA; ensure you pin both uses to their respective full commit SHAs (not tags) in
the .github/workflows/claude-code-review.yml file so the workflow references an
immutable commit.

Comment thread .github/workflows/claude.yml
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate all unpinned GitHub Action references.
rg -n --type=yaml 'uses:\s*[^@]+@v?[0-9]+(\.[0-9]+)?$' .github/workflows

Repository: rosh2004/portfolio

Length of output: 375


Pin GitHub Actions to immutable commit SHAs.

Lines 29 and 35 use mutable version tags (v4 and v1). Replace with specific commit SHAs:

  • actions/checkout@v4actions/checkout@<commit-sha>
  • anthropics/claude-code-action@v1anthropics/claude-code-action@<commit-sha>

This prevents unexpected behavior from tag mutations and improves supply chain security.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/claude.yml at line 29, Replace mutable GitHub Action tags
with immutable commit SHAs: change the uses entry that currently has
"actions/checkout@v4" to "actions/checkout@<commit-sha>" and similarly replace
"anthropics/claude-code-action@v1" with
"anthropics/claude-code-action@<commit-sha>" (use the specific commit SHAs from
each repository's release/commit you want to pin), updating the two uses lines
in the workflow so they reference the exact commit SHAs instead of version tags.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing concurrency group causes duplicate code reviews

Medium Severity

The workflow triggers on synchronize (every push to a PR) but has no concurrency group with cancel-in-progress: true. When a developer pushes multiple commits in quick succession, multiple code review runs will execute simultaneously for the same PR, producing duplicate review comments and wasting API credits. This is a known issue with claude-code-action on synchronize events. A concurrency group keyed on the PR number would cancel stale runs.

Additional Locations (1)
Fix in Cursor Fix in Web

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rosh2004
rosh2004 merged commit be8e658 into main Mar 22, 2026
4 of 5 checks passed
@rosh2004
rosh2004 deleted the add-claude-github-actions-1774147844132 branch March 22, 2026 11:38
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