Skip to content

Conversation

@KRRT7
Copy link
Collaborator

@KRRT7 KRRT7 commented Dec 23, 2025

User description

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


PR Type

Enhancement, Documentation


Description

  • Add Claude Code workflow for mentions

  • Add automated Claude PR review workflow

  • Configure minimal permissions and checkout

  • Define allowed GitHub CLI tools for reviews


Diagram Walkthrough

flowchart LR
  A["GitHub Events (@claude mentions / PR updates)"] -- "triggers" --> B[".github/workflows/claude.yml"]
  A -- "pull_request opened/sync" --> C[".github/workflows/claude-code-review.yml"]
  B -- "runs" --> D["anthropics/claude-code-action@v1"]
  C -- "runs" --> D
  D -- "posts feedback via gh CLI" --> E["PR/Issue comments"]
Loading

File Walkthrough

Relevant files
Enhancement
claude-code-review.yml
Automated Claude code review workflow                                       

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

  • Introduce automated Claude code review job.
  • Trigger on PR open and synchronize events.
  • Configure permissions and repo checkout.
  • Set prompt and allowed gh CLI tools.
+57/-0   
claude.yml
General Claude Code interaction workflow                                 

.github/workflows/claude.yml

  • Add Claude trigger for @claude mentions.
  • Define event filters across PRs and issues.
  • Grant actions read permission for CI context.
  • Provide optional prompt and claude_args hooks.
+50/-0   

@github-actions github-actions bot added the workflow-modified This PR modifies GitHub Actions workflows label Dec 23, 2025
@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 Security concerns

Secrets handling:
The workflows rely on secrets.ANTHROPIC_API_KEY and grant id-token: write. Ensure the secret is configured with least privilege at org/repo level and that OIDC is actually required. Review the allowed gh commands passed to the action; broad patterns (e.g., "gh pr list:", "gh search:") increase risk if the action were compromised. Narrow allowed_tools to only what’s necessary (e.g., "gh pr comment" for reviews).

⚡ Recommended focus areas for review

Permissions Scope

The workflow grants id-token: write which enables OIDC. Verify this is necessary for the action; if not required, reduce to least privilege to minimize attack surface.

permissions:
  contents: read
  pull-requests: read
  issues: read
  id-token: write
Allowed Tools Scope

The allowed tools include multiple gh commands with wildcards. Confirm these are all needed and consider narrowing the scope to only the commands required for posting a PR comment.

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:*)"'
Trigger Conditions

The conditional triggers depend on '@claude' string matching. Consider case-insensitive checks or trimming whitespace/newlines to avoid missed triggers; also ensure it won't trigger on quoted mentions or code blocks if that’s undesired.

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

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Minimize workflow token permissions

Reduce permissions to the minimum required to prevent unnecessary token scope
exposure. Unless OIDC or writing tokens are required, avoid id-token: write and only
keep read scopes needed by the action.

.github/workflows/claude-code-review.yml [22-27]

 permissions:
   contents: read
   pull-requests: read
   issues: read
-  id-token: write
Suggestion importance[1-10]: 7

__

Why: Correctly identifies and reduces potentially excessive permissions, notably id-token: write, improving security with minimal impact. Accurate match to the new hunk and reasonable improvement, though necessity depends on the action’s OIDC usage.

Medium
Remove unnecessary OIDC permission

Avoid granting id-token: write unless the action performs OIDC federation. If CI
results are the only extra need, keep actions: read and drop OIDC to reduce token
exposure.

.github/workflows/claude.yml [21-27]

 permissions:
   contents: read
   pull-requests: read
   issues: read
-  id-token: write
   actions: read # Required for Claude to read CI results on PRs
Suggestion importance[1-10]: 7

__

Why: Accurately targets the permissions block and suggests dropping id-token: write to minimize token scope, a solid security improvement if OIDC isn’t required. Contextually correct with clear impact.

Medium
Restrict allowed tool patterns

Constrain the allowed CLI patterns to only what the job needs to comment on the
current PR. Broad wildcards increase risk; restrict to gh pr view, gh pr diff, and
gh pr comment scoped to ${{ github.event.pull_request.number }}.

.github/workflows/claude-code-review.yml [38-56]

 with:
   anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
   prompt: |
     REPO: ${{ github.repository }}
     PR NUMBER: ${{ github.event.pull_request.number }}
     ...
-  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:*)"'
+  claude_args: '--allowed-tools "Bash(gh pr view:${{ github.event.pull_request.number }}),Bash(gh pr diff:${{ github.event.pull_request.number }}),Bash(gh pr comment:${{ github.event.pull_request.number }})"'
Suggestion importance[1-10]: 6

__

Why: Tightening claude_args reduces risk from broad gh scopes; concept is sound and relevant. However, the proposed interpolation inside the allowed-tools pattern may not be supported by the action’s parser and could break usage.

Low

@KRRT7 KRRT7 merged commit a959cd5 into main Dec 23, 2025
24 of 25 checks passed
@KRRT7 KRRT7 deleted the add-claude-github-actions-1766454705385 branch December 23, 2025 01:54
@aseembits93
Copy link
Contributor

@claude review this pull request

@claude
Copy link

claude bot commented Dec 23, 2025

Claude finished @aseembits93's task in 1m 0s —— View job


Code Review: Claude Code GitHub Workflows

I've completed a thorough review of the two workflow files added in this PR. Here's my detailed feedback:


Overview

This PR adds two workflows to integrate Claude Code into the repository:

  1. claude.yml - General Claude interaction via @mentions
  2. claude-code-review.yml - Automated code reviews on PR open/sync

🔒 Security Concerns

1. Excessive Permission: id-token: write (High Priority)

Both workflows (.github/workflows/claude.yml:25, .github/workflows/claude-code-review.yml:26)

The id-token: write permission enables OIDC token generation, which is typically used for cloud provider authentication (AWS, GCP, Azure). Unless the Claude Code action specifically requires OIDC federation, this permission should be removed to minimize the attack surface.

Recommendation:

permissions:
  contents: read
  pull-requests: read
  issues: read
  # Remove: id-token: write (unless OIDC is explicitly required)
  actions: read # Only in claude.yml

2. Overly Broad Tool Allowlist (Medium Priority)

claude-code-review.yml:56

The workflow grants Claude access to multiple gh commands with wildcards:

  • gh issue view:*, gh search:*, gh issue list:*, gh pr list:*

For a PR review workflow, Claude only needs to interact with the specific PR being reviewed. The broad wildcards increase risk if the action were compromised.

Recommendation:
Consider narrowing the scope to only what's necessary for PR reviews:

claude_args: '--allowed-tools "Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*)"'

If searching issues/PRs is genuinely needed for context, document why in a comment.


⚡ Functional Issues

3. Case-Sensitive Trigger Matching (Low Priority)

claude.yml:16-19

The @claude trigger uses case-sensitive string matching via contains(). This could miss mentions like @Claude or @CLAUDE.

Recommendation:
Consider case-insensitive matching or document that mentions must be lowercase:

# Option 1: Case-insensitive (more user-friendly)
contains(lower(github.event.comment.body), '@claude')

# Option 2: Document the requirement in PR description/README

4. Whitespace/Newline Sensitivity

The trigger will match @claude even in code blocks or quoted text. If this is undesired behavior, consider more sophisticated parsing or document this quirk for users.


📋 Best Practices & Improvements

5. Fetch Depth

Both workflows use fetch-depth: 1

This is appropriate for most cases, but if Claude needs full git history for analysis, consider increasing this or making it configurable.

6. Missing Branch Protection Context

The PR description mentions "Only users with write access to the repository can trigger the workflow," but this isn't enforced in the workflow itself. Consider documenting branch protection requirements or adding explicit checks.

7. Commented-Out Configuration

claude-code-review.yml has useful commented-out sections (path filters, author filters). Consider:

  • Adding a comment explaining when to enable these
  • Providing examples in a separate documentation file

✅ What's Done Well

  1. Clear Documentation: The PR description excellently explains what Claude Code is and how it works
  2. Minimal Checkout: Using fetch-depth: 1 is good for performance
  3. Explicit Prompt: claude-code-review.yml provides clear review criteria
  4. Reference to CLAUDE.md: Good practice to reference repo conventions
  5. Action Pinning: Using @v1 for the action (though consider @v1.x.x for more stability)

🎯 Summary Recommendations

Priority Order:

  1. High: Remove id-token: write unless OIDC is required (confirm with Claude Code action docs)
  2. Medium: Narrow allowed_tools scope in claude-code-review.yml to only PR-specific commands
  3. Low: Consider case-insensitive trigger matching for better UX
  4. Documentation: Add comments explaining the security model and when to use optional features

Final Verdict

This is a solid implementation that follows GitHub Actions best practices. The main concerns are security-related (excessive permissions, broad tool scope) rather than functional issues. Since this PR is already merged, I recommend creating a follow-up issue to address the security hardening suggestions above.

The automated reviewer's suggestions were accurate - particularly around permissions and allowed tools scope. I concur with those recommendations.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 2/5 workflow-modified This PR modifies GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants