Skip to content

Add Claude Code GitHub Workflow - #7411

Merged
sfmskywalker merged 2 commits into
mainfrom
add-claude-github-actions-1776883231902
Apr 22, 2026
Merged

Add Claude Code GitHub Workflow#7411
sfmskywalker merged 2 commits into
mainfrom
add-claude-github-actions-1776883231902

Conversation

@sfmskywalker

Copy link
Copy Markdown
Member

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

@sfmskywalker
sfmskywalker merged commit 8ee0b43 into main Apr 22, 2026
11 checks passed
@sfmskywalker
sfmskywalker deleted the add-claude-github-actions-1776883231902 branch April 22, 2026 18:40
@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces two GitHub Actions workflows: claude.yml for on-demand Claude Code assistance triggered by @claude mentions, and claude-code-review.yml for automated PR review on every open/sync event.

  • Both workflows grant only read permissions on contents, pull-requests, and issues, but Claude's core functionality (creating comments, commits, and branches) requires write access on those scopes — without this fix, all write operations will fail with a 403.
  • claude-code-review.yml similarly needs pull-requests: write to post review output.

Confidence Score: 3/5

Not safe to merge — both workflows will fail to perform any write operations due to missing permissions, making the Claude integration non-functional after merge.

Two P1 findings: both workflows lack the write permissions required for Claude to post comments, create commits, or create branches. The PR description explicitly calls these out as core features, but they will all fail silently or with 403 errors until permissions are corrected.

Both .github/workflows/claude.yml and .github/workflows/claude-code-review.yml need their permissions blocks updated before merging.

Important Files Changed

Filename Overview
.github/workflows/claude.yml Adds Claude Code on-demand workflow triggered by @claude mentions; missing write permissions on contents/pull-requests/issues will prevent Claude from creating comments, commits, or branches
.github/workflows/claude-code-review.yml Adds automated Claude Code Review on every PR open/sync event; missing pull-requests: write will prevent the action from posting any review output

Sequence Diagram

sequenceDiagram
    participant User
    participant GitHub
    participant claude_yml as claude.yml workflow
    participant review_yml as claude-code-review.yml workflow
    participant ClaudeAction as anthropics/claude-code-action@v1
    participant AnthropicAPI as Anthropic API

    User->>GitHub: Comment with @claude on issue/PR
    GitHub->>claude_yml: Trigger (issue_comment / pr_review_comment)
    claude_yml->>ClaudeAction: Run with CLAUDE_CODE_OAUTH_TOKEN
    ClaudeAction->>AnthropicAPI: Authenticate and send context
    AnthropicAPI-->>ClaudeAction: Response + actions
    ClaudeAction->>GitHub: Create comment / commit / branch (needs write perms ⚠️)

    User->>GitHub: Open or update PR
    GitHub->>review_yml: Trigger (pull_request opened/synchronize)
    review_yml->>ClaudeAction: Run with plugin code-review
    ClaudeAction->>AnthropicAPI: Authenticate and send PR diff
    AnthropicAPI-->>ClaudeAction: Review output
    ClaudeAction->>GitHub: Post PR review comment (needs pull-requests: write ⚠️)
Loading

Reviews (1): Last reviewed commit: ""Claude Code Review workflow"" | Re-trigger Greptile

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Missing write permissions will break core functionality

The PR description states Claude will create comments, branches, and commits, but the permissions block grants only read on contents, pull-requests, and issues. GitHub Actions' GITHUB_TOKEN will be used by the action, and without write grants it cannot post issue/PR comments, push commits, or create branches — the primary use cases described. The action will either silently fail or throw a 403 when attempting any write operation.

Required additions:

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

Comment on lines +22 to +26
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Missing pull-requests: write prevents posting review comments

The review workflow needs to post comments on PRs but pull-requests is set to read. Without write access the action cannot publish any review output and will silently produce no visible result.

Suggested change
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
permissions:
contents: read
pull-requests: write
issues: read
id-token: write

Comment on lines +39 to +41
# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Redundant actions: read in additional_permissions

actions: read is already declared in the job-level permissions block on line 26, so specifying it again as an action input is redundant. The additional_permissions input is interpreted by the action itself and may have no effect at the workflow level — the job-level declaration is what GitHub enforces.

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
Contributor

Choose a reason for hiding this comment

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

P2 Actions not pinned to immutable SHAs

Both actions/checkout@v4 and anthropics/claude-code-action@v1 use mutable version tags. If a tag is moved (intentionally or via a supply chain compromise), the workflow will silently pick up different code. Pin to a full commit SHA for security, e.g.:

uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4
uses: anthropics/claude-code-action@<full-sha>  # v1

This applies to the same two uses: lines in claude-code-review.yml as well.

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