Skip to content

Add Claude Code GitHub Workflow#1

Open
wangdiues wants to merge 2 commits intomainfrom
add-claude-github-actions-1778243466988
Open

Add Claude Code GitHub Workflow#1
wangdiues wants to merge 2 commits intomainfrom
add-claude-github-actions-1778243466988

Conversation

@wangdiues
Copy link
Copy Markdown
Owner

@wangdiues wangdiues commented May 8, 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 automated code review integration to the CI/CD pipeline for pull requests.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

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

Project Deployment Actions Updated (UTC)
layguel360-v0 Ready Ready Preview, Comment May 8, 2026 0:33am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Two GitHub Actions workflows are added to enable Claude-powered code review. The first workflow runs automatically when pull requests are created or updated. The second workflow responds to @claude mentions in pull request comments, review comments, issues, and reviews, providing on-demand code review feedback.

Changes

Claude Code Review Integration

Layer / File(s) Summary
Automatic PR Review Workflow
.github/workflows/claude-code-review.yml
Workflow triggers on PR opened, synchronize, ready_for_review, reopened events. Job runs on ubuntu-latest with read permissions and id-token: write. Repository is checked out and anthropics/claude-code-action@v1 is invoked with the code-review plugin, using CLAUDE_CODE_OAUTH_TOKEN secret and the current PR URL.
Interactive Comment-Triggered Review
.github/workflows/claude.yml
Workflow triggers on issue_comment, pull_request_review_comment, issues, and pull_request_review events. Job execution is gated by an if condition checking for @claude in the triggering text. Minimal permissions are set: contents, pull-requests, issues read access; id-token: write; actions: read for CI access. Repository is checked out with actions/checkout@v4 and shallow fetch. anthropics/claude-code-action@v1 is invoked with CLAUDE_CODE_OAUTH_TOKEN and additional_permissions for reading CI results.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 Two workflows hop into the fold,
Auto-review and chat-driven, bold!
PR triggers dance, @claude commands shine,
Code reviews flow—a magical sign!
Integration complete, the review loop's fine! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 concisely describes the main change: adding new GitHub Actions workflows for Claude Code 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-1778243466988

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

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

🧹 Nitpick comments (1)
.github/workflows/claude.yml (1)

8-10: ⚡ Quick win

Remove issues.assigned to prevent duplicate Claude runs.

With the current condition, re-assigning an issue that already contains @claude retriggers the workflow even without a new request.

♻️ Suggested simplification
   issues:
-    types: [opened, assigned]
+    types: [opened]
🤖 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 8 - 10, The workflow is being
retriggered by the issues.assigned event; remove the 'assigned' entry from the
issues.types list so the workflow only runs on new issue opens (e.g., keep
types: [opened]) or replace the issues trigger with a single event that excludes
reassignment; update the .github/workflows/claude.yml file to delete 'assigned'
(reference: the issues.types array in the workflow) to prevent duplicate Claude
runs.
🤖 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 14-21: The claude-review job can fail on forked PRs because
secrets.CLAUDE_CODE_OAUTH_TOKEN aren’t available; update the claude-review job
to skip runs for forked PRs by adding a job-level conditional that ensures the
PR’s head repo matches the base repository (or that the PR is not from a fork)
before using secrets. Modify the claude-review job (refer to the claude-review
job name and the use of secrets.CLAUDE_CODE_OAUTH_TOKEN) to include an if
condition that only runs when github.event.pull_request.head.repo.full_name ==
github.repository (or an equivalent check for non-fork PRs) so the job is
skipped for forked pull requests.
- Around line 29-37: Replace mutable action tags with pinned full commit SHAs:
find the uses lines "uses: actions/checkout@v4" and "uses:
anthropics/claude-code-action@v1" in the workflow and substitute each tag with
the corresponding full-length commit SHA for the released commit you want to pin
(do the same change in the other workflow that uses these actions). Ensure you
update both occurrences (checkout and anthropics action) and verify the SHAs
correspond to the exact release commit you intend to lock to before committing.

---

Nitpick comments:
In @.github/workflows/claude.yml:
- Around line 8-10: The workflow is being retriggered by the issues.assigned
event; remove the 'assigned' entry from the issues.types list so the workflow
only runs on new issue opens (e.g., keep types: [opened]) or replace the issues
trigger with a single event that excludes reassignment; update the
.github/workflows/claude.yml file to delete 'assigned' (reference: the
issues.types array in the workflow) to prevent duplicate Claude runs.
🪄 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

Run ID: 6f5d402c-ed9a-4d6d-8746-25eded9bbd25

📥 Commits

Reviewing files that changed from the base of the PR and between 032d154 and c503b18.

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

Comment on lines +14 to +21
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'

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

🧩 Analysis chain

🏁 Script executed:

cat -n .github/workflows/claude-code-review.yml

Repository: wangdiues/layguel360-v0

Length of output: 1808


Skip this job for forked PRs to avoid secret-missing failures.

This workflow uses secrets.CLAUDE_CODE_OAUTH_TOKEN on pull_request; fork-origin PR runs will not have that secret and will fail noisily.

🛡️ Suggested guard
 jobs:
   claude-review:
+    if: ${{ !github.event.pull_request.head.repo.fork }}
📝 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
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'
runs-on: ubuntu-latest
claude-review:
if: ${{ !github.event.pull_request.head.repo.fork }}
# 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'
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-code-review.yml around lines 14 - 21, The
claude-review job can fail on forked PRs because secrets.CLAUDE_CODE_OAUTH_TOKEN
aren’t available; update the claude-review job to skip runs for forked PRs by
adding a job-level conditional that ensures the PR’s head repo matches the base
repository (or that the PR is not from a fork) before using secrets. Modify the
claude-review job (refer to the claude-review job name and the use of
secrets.CLAUDE_CODE_OAUTH_TOKEN) to include an if condition that only runs when
github.event.pull_request.head.repo.full_name == github.repository (or an
equivalent check for non-fork PRs) so the job is skipped for forked pull
requests.

Comment on lines +29 to +37
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
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:

# Check if the workflow files exist
fd -t f "claude.*\.yml" .github/workflows/

Repository: wangdiues/layguel360-v0

Length of output: 137


🏁 Script executed:

# Read the claude-code-review.yml file around lines 29-37
if [ -f .github/workflows/claude-code-review.yml ]; then
  echo "=== claude-code-review.yml (lines 20-45) ==="
  sed -n '20,45p' .github/workflows/claude-code-review.yml
fi

Repository: wangdiues/layguel360-v0

Length of output: 983


🏁 Script executed:

# Check all workflow files for these actions
if [ -f .github/workflows/claude.yml ]; then
  echo "=== claude.yml (all) ==="
  cat -n .github/workflows/claude.yml
fi

Repository: wangdiues/layguel360-v0

Length of output: 2328


🌐 Web query:

GitHub Actions best practices pin to commit SHA security

💡 Result:

Best practice: pin third-party GitHub Actions to a full-length (40-character) commit SHA in your workflow (e.g., actions/checkout@) rather than to tags like @v4, and use GitHub policies to enforce SHA pinning so unpinned actions fail. Why pin to commit SHA - GitHub’s “secure use” guidance states that pinning an action to a full-length commit SHA is “currently the only way to use an action as an immutable release,” and that it helps mitigate backdoor risk because an attacker would need to generate a SHA-1 collision for a valid Git object payload. It also instructs you to verify the SHA comes from the action’s repository and not a fork.[1] - GitHub also notes that tag pinning is convenient but less secure because a tag can be moved or deleted if a bad actor gains access to the action’s repository.[1] How to do it in practice 1) Replace tag references with full SHA in the workflow YAML. - Example pattern: uses: actions/checkout@ [1] 2) Add a short comment next to the SHA showing which tag/version it corresponds to (this keeps reviews maintainable). (This is commonly recommended; GitHub’s docs emphasize full SHA pinning and verification.) [2][1] 3) Verify the SHA is from the action’s upstream repository, not a fork.[1] Enforce it org/repo-wide (recommended) - GitHub added an “allowed actions policy” feature to enforce SHA pinning: it recommends workflows pin dependency versions to a specific commit SHA to prevent malicious code in updated branches/tags from being used automatically, and administrators can enforce SHA pinning through an “allowed actions policy.” The policy checks for a full commit SHA and workflows that use an action that isn’t pinned will fail.[3] Net answer to your query - “Pin to commit SHA” is the correct security best practice; use full-length commit SHAs (not shortened SHAs, not tags) and enforce SHA pinning with GitHub’s allowed-actions policy.[1][3]

Citations:


🌐 Web query:

actions/checkout v4 pinning commit SHA recommendations

💡 Result:

Recommendation (secure + actionable): pin actions/checkout v4 to an immutable full-length commit SHA (not a mutable tag like v4). Example: - uses: actions/checkout@<FULL_COMMIT_SHA> # v4.x.y (pin to the commit that implements the v4.x.y tag you tested) Why: 1) Pinning to a full-length commit SHA is the only way to make a GitHub Action reference immutable, mitigating the risk that the tag could move to different code later [1]. 2) Using tags like @v4 is mutable because a tag is effectively a pointer to a specific SHA that can change [1]. How to find the exact SHA for the v4 release you want: - Go to the actions/checkout repo and open the tag you’re targeting (e.g., the v4.x.y release tag), then copy the commit SHA the tag points to; the changelog/release pages show the specific v4.x.y release you can pin [2][3]. Notes specific to actions/checkout v4: - By default it checks out only a single commit: the ref/SHA that triggered the workflow (set fetch-depth: 0 if you need full history) [4]. - The action outputs include the checked-out commit SHA (useful for auditing/pinning checks) [5]. What commit SHA should you pin to “right now”? - This requires choosing a specific v4.x.y release (e.g., v4.2.0 vs another v4 patch), then pinning to the SHA that tag resolves to; the sources retrieved here confirm the correct method but don’t provide the exact SHA value for a chosen v4.x.y in the query results. If you tell me which v4 patch you want (or whether “latest v4.x.y” is acceptable), I can look up the corresponding tag’s commit SHA and give you the exact one-line YAML.

Citations:


🌐 Web query:

anthropic claude-code-action v1 pinning SHA support

💡 Result:

Yes, Anthropic's claude-code-action v1 supports pinning to a commit SHA for secure usage in GitHub workflows. Users commonly pin it like uses: anthropics/claude-code-action@a3ff61d47aa5118a43b33ae44c4087d9eb51111a # v1 to meet organization requirements for immutable references and prevent supply chain attacks [1][2]. This is a standard GitHub Actions best practice, and the repository has implemented internal pinning of its nested actions (e.g., PR #1293 to pin to commit SHAs [3], issue #15 resolved by pinning dependencies [4]). Official docs show usage with @v1 but do not prohibit or restrict SHA pinning, and community examples confirm it works [5][6][7]. Specific SHAs like 01e756b34ef7a1447e9508f674143b07d20c2631 have been used as workarounds for bugs [2]. The repo has 174 releases under v1.x (latest v1.0.110 as of 2026-04-29 [5]), allowing precise pinning to tested commits.

Citations:


Pin GitHub Actions to immutable commit SHAs.

Both actions/checkout@v4 and anthropics/claude-code-action@v1 use mutable tags. GitHub's security guidance states that pinning to full-length commit SHAs is the only way to use actions as immutable releases and mitigates supply-chain drift risk. Apply the same fix to .github/workflows/claude.yml.

🔒 Suggested hardening diff
       - name: Checkout repository
-        uses: actions/checkout@v4
+        uses: actions/checkout@<full-length-checkout-sha> # v4 release commit
         with:
           fetch-depth: 1

       - name: Run Claude Code Review
         id: claude-review
-        uses: anthropics/claude-code-action@v1
+        uses: anthropics/claude-code-action@<full-length-claude-action-sha> # v1 release commit
         with:
           claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
🤖 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 29 - 37, Replace
mutable action tags with pinned full commit SHAs: find the uses lines "uses:
actions/checkout@v4" and "uses: anthropics/claude-code-action@v1" in the
workflow and substitute each tag with the corresponding full-length commit SHA
for the released commit you want to pin (do the same change in the other
workflow that uses these actions). Ensure you update both occurrences (checkout
and anthropics action) and verify the SHAs correspond to the exact release
commit you intend to lock to before committing.

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