Skip to content

Add Claude Code GitHub Workflow#6

Open
bharatr21 wants to merge 2 commits intomainfrom
add-claude-github-actions-1766179309583
Open

Add Claude Code GitHub Workflow#6
bharatr21 wants to merge 2 commits intomainfrom
add-claude-github-actions-1766179309583

Conversation

@bharatr21
Copy link
Copy Markdown
Owner

@bharatr21 bharatr21 commented Dec 19, 2025

🤖 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

  • New Features
    • Added automated code review workflow that triggers on pull request events
    • Integrated AI-powered code quality assessment with automated PR feedback
    • Added event-based activation for code review via comments and interactions

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 19, 2025

Walkthrough

Adds two GitHub Actions workflows to enable Claude AI-powered code review automation. The first workflow triggers on pull request events and posts code quality feedback via pull request comments. The second workflow listens for issue and pull request events and runs Claude Code integration when mentioned, with configurable permissions and action parameters.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.github/workflows/claude-code-review.yml, .github/workflows/claude.yml
Adds two new CI/CD automation workflows: claude-code-review.yml configures automated code review triggers on PR open/sync events with quality and security assessment, while claude.yml sets up event-driven Claude Code integration with conditional mention detection and customizable action parameters. Both include appropriate permission scoping (contents, pull-requests, issues, id-token).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Verify trigger conditions are correct and don't cause unintended automation
  • Validate permission scope is minimal and appropriate for each workflow's intended use
  • Confirm OAuth token and secret references are properly configured
  • Check that the claude_args string and prompt instructions align with intended behavior

Poem

🐰 Two workflows hop into place,
Claude reviews code at GitHub's grace,
With triggers set and permissions tight,
Our furry friend brings AI insight,
Automating quality, hop by hop! ✨

Pre-merge checks and finishing touches

✅ 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' accurately summarizes the main change: adding two GitHub Actions workflow files (.github/workflows/claude-code-review.yml and .github/workflows/claude.yml) to enable Claude Code integration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-claude-github-actions-1766179309583

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 (2)
.github/workflows/claude.yml (2)

20-26: Consider adding actions: read to the code-review workflow for consistency.

This workflow includes actions: read permission (line 26) to allow Claude to read CI results on PRs. The claude-code-review.yml workflow might also benefit from this permission to provide more comprehensive code reviews that consider CI status.

🔎 Suggested addition to claude-code-review.yml

Add to the permissions block in .github/workflows/claude-code-review.yml:

 permissions:
   contents: read
   pull-requests: read
   issues: read
   id-token: write
+  actions: read # Required for Claude to read CI results on PRs

46-49: Consider adding tool restrictions for security.

Unlike the claude-code-review.yml workflow (which specifies allowed-tools), this workflow has no explicit tool restrictions. This means Claude has broader access when invoked via @mentions.

While this flexibility may be intentional for interactive use, consider whether to:

  1. Add similar tool restrictions for consistency and security
  2. Document why this workflow has fewer restrictions than the automated code-review workflow

If unrestricted access is intentional, consider uncommenting line 49 and adding a permissive but still bounded configuration.

🔎 Example tool restriction configuration
# Option 1: Match code-review workflow restrictions
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

# Option 2: More permissive for interactive use (but still bounded)
claude_args: '--allowed-tools "Bash(gh *)"'
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 989b371 and ef57e88.

📒 Files selected for processing (2)
  • .github/workflows/claude-code-review.yml (1 hunks)
  • .github/workflows/claude.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.12)
  • GitHub Check: test-with-coverage
  • GitHub Check: test (3.11)
🔇 Additional comments (7)
.github/workflows/claude-code-review.yml (4)

1-12: Workflow trigger configuration looks good.

The pull_request trigger with opened and synchronize types is appropriate for automated code reviews. The optional path filters (currently commented) are useful for limiting reviews to specific file types if needed in the future.

Note: pull_request events from forks run with read-only permissions and secrets are not exposed to the fork's workflow, which provides good security isolation.


28-32: LGTM!

The checkout configuration with fetch-depth: 1 is appropriate for this workflow, as it only needs the current state of the code without full history.


54-56: Well-configured tool restrictions for security.

The allowed-tools configuration follows the principle of least privilege by:

  • Limiting to specific gh CLI commands
  • Allowing only read operations (view, list, diff, search) plus gh pr comment for posting feedback
  • Using wildcard patterns for flexibility while maintaining control

This is a good security practice for workflows that interact with external AI services.


21-26: Clarify authentication model and permissions strategy.

The Claude Code GitHub app officially requires read & write permissions for Contents, Issues, and Pull requests, but official workflow examples use read-only GitHub permissions when paired with oauth_token authentication. If this workflow uses claude_code_oauth_token instead of the default GitHub app token, the read-only permissions are correct because Claude updates its initial comment rather than posting multiple new comments. Otherwise, add pull-requests: write and issues: write to the permissions block. Document which authentication model this workflow uses for clarity.

.github/workflows/claude.yml (3)

14-19: LGTM! Conditional logic correctly filters for @claude mentions.

The conditional expression properly handles all four event types and checks the appropriate fields (comment.body, review.body, issue.body, issue.title) for @claude mentions. This prevents the workflow from running unnecessarily.


27-31: LGTM!

Standard checkout configuration appropriate for this workflow.


39-41: The additional_permissions setting is necessary—it's not redundant with job-level permissions.

The additional_permissions: actions: read is an action-level input that configures the Claude action's internal behavior, distinct from the job-level permissions key which controls the GITHUB_TOKEN scope. The action documentation indicates that additional_permissions enables specific permissions, currently supporting 'actions: read' for viewing workflow results. These operate at different levels and serve different purposes, so the setting should be retained.

Comment on lines +39 to +50
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}

Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage

Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
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

🏁 Script executed:

#!/bin/bash
# Check if CLAUDE.md exists in the repository
if [ -f "CLAUDE.md" ]; then
  echo "✓ CLAUDE.md exists"
  echo "Preview of contents:"
  head -n 20 CLAUDE.md
else
  echo "✗ CLAUDE.md not found in repository root"
  echo "Searching for similar files:"
  fd -i claude.md 2>/dev/null || echo "No similar files found"
fi

Repository: bharatr21/mcp-nvidia

Length of output: 133


Create CLAUDE.md or remove the reference from the prompt.

The workflow prompt references the repository's CLAUDE.md file for style and convention guidance, but this file does not exist. Either create CLAUDE.md with project-specific guidance for Claude, or remove the reference from the prompt.

🤖 Prompt for AI Agents
In .github/workflows/claude-code-review.yml around lines 39 to 50, the workflow
prompt references a non-existent CLAUDE.md file; either create that file with
repository-specific style/convention guidance for Claude or remove the reference
from the prompt. Fix option A: add a top-level CLAUDE.md containing the
project's coding style, review rules, expected tone, and any repository-specific
checks so the workflow can reference it. Fix option B: edit the workflow prompt
to remove the "Use the repository's CLAUDE.md for guidance on style and
conventions." line (or replace it with an inline summary of the guidance) so the
prompt no longer points to a missing file.

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

Add permission filtering to restrict Claude workflow triggers to authorized users.

The current triggers (issue_comment, pull_request_review_comment, issues, pull_request_review) allow any user to initiate the workflow, which bypasses GitHub's approval requirements for external contributors. This could enable unauthorized API quota consumption or analysis runs.

Implement a job-level condition to restrict execution to repository members:

if: |
  github.event.sender.type != 'Bot' &&
  (github.event_name == 'issues' || 
   github.event.comment.author_association == 'OWNER' ||
   github.event.comment.author_association == 'MEMBER' ||
   github.event.comment.author_association == 'COLLABORATOR')
🤖 Prompt for AI Agents
.github/workflows/claude.yml lines 3-11: the workflow currently triggers on
issue_comment, pull_request_review_comment, issues, and pull_request_review
without any permission filtering; add a job-level if condition on the workflow
jobs that prevents runs from bots and only allows repository
members/owners/collaborators for comment-triggered events (and allow the issues
event) by checking github.event.sender.type != 'Bot' and author_association
values (OWNER, MEMBER, COLLABORATOR) for comment events, and include
github.event_name == 'issues' as an allowed event; apply this if expression to
the top-level jobs that perform the Claude actions so unauthorized external
users cannot trigger the workflow.

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